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.4 kB
/** * LoadForm Helpers for BC Page Loading * * Implements the complete LoadForm solution based on WebSocket capture analysis. * See: LOADFORM_SOLUTION_COMPLETE.md for full documentation. */ import type { Control } from '../types/bc-types.js'; /** * Child form information extracted from response */ export interface ChildFormInfo { serverId: string; container: Control; form: Control; } /** * Result of extracting ServerIds from form structure */ export interface ServerIdsExtractResult { shellFormId: string; childFormIds: ChildFormInfo[]; } /** * Decompress BC server response if compressed. * * BC compresses responses using gzip in base64 encoding: * - First response: `payload.compressedResult` * - Subsequent responses: `payload.params[0].compressedData` * * @param payload - Raw response payload from BC * @returns Decompressed data or null if not compressed */ export declare function decompressResponse(payload: unknown): unknown; /** Handler structure for form lookups */ interface FormHandler { parameters?: readonly unknown[]; } /** * Find the handler containing form structure in response array. * * The form structure handler contains: * - parameters[1].ServerId (shell form) * - parameters[1].Children (array of child controls/forms) * * @param response - Array of handlers from BC response * @returns Form structure handler or null if not found */ export declare function findFormStructureHandler(response: unknown[]): FormHandler | null; /** * Extract ServerIds from form structure. * * Pattern: response[handler].parameters[1] contains: * - ServerId: Shell/container form ID * - Children[N].Children[0].ServerId: Child form IDs * * @param response - Array of handlers from BC response * @returns Shell form ID and array of child forms * @throws Error if form structure not found */ export declare function extractServerIds(response: unknown[]): ServerIdsExtractResult; /** * Determine if a child form should be LoadForm'd. * * Pattern (100% validated with Page 22): * LoadForm if ALL of: * 1. container.Visible !== false (not explicitly hidden) * 2. EITHER: * a) form.DelayedControls exists, OR * b) container.ExpressionProperties exists * * @param child - Child form info from extractServerIds() * @returns true if form should be loaded */ export declare function shouldLoadForm(child: ChildFormInfo): boolean; /** * Filter child forms by LoadForm criteria. * * @param childForms - Array of child forms from extractServerIds() * @returns Filtered array of forms that should be loaded */ export declare function filterFormsToLoad(childForms: ChildFormInfo[]): ChildFormInfo[]; /** LoadForm interaction structure */ interface LoadFormInteraction { interactionName: string; formId: string; controlPath: string; callbackId: string; namedParameters: { delayed: boolean; openForm: boolean; loadData: boolean; }; } /** * Create LoadForm interaction parameters. * * Standard parameters used by BC web client: * - delayed: true * - openForm: true * - loadData: true * * @param formId - ServerId to load * @param callbackId - Unique callback ID * @returns LoadForm interaction object */ export declare function createLoadFormInteraction(formId: string, callbackId: string): LoadFormInteraction; export {}; //# sourceMappingURL=loadform-helpers.d.ts.map