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

150 lines 5.25 kB
/** * Control Parser Implementation * * Walks LogicalForm control tree and extracts field/action metadata. * Uses visitor pattern for flexible tree traversal. */ import type { IControlParser, IControlVisitor, IControlWalker } from '../core/interfaces.js'; import type { LogicalForm, Control, FieldMetadata, ActionMetadata, ControlType, RepeaterMetadata } from '../types/bc-types.js'; /** * Implementation of IControlParser. * Extracts fields and actions from LogicalForm control tree. */ export declare class ControlParser implements IControlParser { private readonly walker; constructor(walker?: IControlWalker); /** * Walks control tree and returns all controls with their paths. * * @param logicalForm - The form to parse * @returns Flat array of all controls with controlPath property */ walkControls(logicalForm: LogicalForm): readonly (Control & { controlPath?: string; })[]; /** * Extracts field metadata from controls. * * @param controls - Array of controls to parse * @returns Array of field metadata */ extractFields(controls: readonly Control[]): readonly FieldMetadata[]; /** * Extracts action metadata from controls. * * @param controls - Array of controls to parse * @returns Array of action metadata */ extractActions(controls: readonly Control[]): readonly ActionMetadata[]; /** * Extracts repeater (subpage) metadata from controls. * Repeaters contain line items (e.g., Sales Lines on Sales Order). * * Handles two patterns: * 1. fhc-wrapped subpages (Document lines): fhc (Part name) → lf (Subform) → rc/lrc (Grid) * 2. Standalone rc/lrc repeaters (List pages) * * @param controls - Array of controls to parse * @returns Array of repeater metadata with column information */ extractRepeaters(controls: readonly (Control & { controlPath?: string; })[]): readonly RepeaterMetadata[]; /** * Finds the nested grid (rc/lrc) control within an fhc control. * BC structure: fhc → lf (with IsPart/IsSubForm) → rc/lrc * * @param fhcControl - The Form Heading Control (Part wrapper) * @returns The nested rc/lrc grid control with controlPath, or undefined */ private findNestedGrid; /** * Recursively searches for rc/lrc control in a subtree. * * @param control - Control to search within * @returns First rc/lrc control found with controlPath, or undefined */ private findGridInSubtree; /** * Checks if control type is a field control. */ private isFieldControl; /** * Checks if control type is an action control. */ private isActionControl; /** * Converts a control to field metadata. */ private controlToFieldMetadata; /** * Converts a control to action metadata. */ private controlToActionMetadata; /** * Converts a repeater control to repeater metadata with column information. * Passive consumer: reads enriched Columns array if present (from cache), * otherwise extracts columns from the Children array of the repeater control. */ private controlToRepeaterMetadata; } /** * Implementation of IControlWalker. * Walks LogicalForm tree using visitor pattern. */ export declare class ControlWalker implements IControlWalker { /** * Walks control tree with a visitor. * * @param logicalForm - The form to walk * @param visitor - Visitor to apply to each control */ walk(logicalForm: LogicalForm, visitor: IControlVisitor): void; /** * Recursively walks a control and its children. * Also walks special action arrays: HeaderActions (/ha[N]) and Actions (/a[N]). * * CRITICAL: Walk HeaderActions/Actions BEFORE Children * BC puts canonical action controls in HeaderActions/Actions arrays. * The same actions may also appear in Children (for UI layout), but those * paths don't trigger navigation. We must find HeaderActions/Actions first. */ private walkControl; } /** * Visitor that collects controls of a specific type. */ export declare class TypeFilterVisitor implements IControlVisitor { private readonly types; private readonly controls; constructor(types: readonly ControlType[]); visit(control: Control, _depth?: number, path?: string): boolean; getControls(): readonly (Control & { controlPath?: string; })[]; } /** * Visitor that finds a control by ID. */ export declare class FindByIdVisitor implements IControlVisitor { private readonly controlId; private foundControl?; constructor(controlId: string); visit(control: Control): boolean; getControl(): Control | undefined; } /** * Visitor that collects control statistics. */ export declare class StatisticsVisitor implements IControlVisitor { private readonly typeCounts; private totalControls; private maxDepth; visit(control: Control, depth: number): boolean; getStatistics(): { totalControls: number; maxDepth: number; typeCounts: ReadonlyMap<ControlType, number>; }; } //# sourceMappingURL=control-parser.d.ts.map