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
121 lines • 4.03 kB
JavaScript
/**
* Business Central WebSocket Protocol Types
*
* Precise TypeScript interfaces derived from decompiled BC .NET assemblies.
* TypeAlias annotations in C# define the JSON `t` discriminator values.
*
* @see Microsoft.Dynamics.Framework.UI.Client namespace in decompiled code
*/
import { isPropertyChangesType, isPropertyChangeType, isDataRefreshChangeType, isDataRowInsertedType, isFormToShowChangeType, isDialogToShowChangeType, isMessageToShowChangeType, isDataRowUpdatedType, isDataRowRemovedType, BC_CHANGE_TYPES, } from './bc-type-discriminators.js';
// ============================================================================
// Type Guards
// ============================================================================
/**
* Type guard for DataRefreshChange.
* Uses centralized BC_CHANGE_TYPES mapping to handle all variants.
*/
export function isDataRefreshChange(change) {
return isDataRefreshChangeType(change.t);
}
/**
* Type guard for DataRowInsertedChange.
* Uses centralized BC_CHANGE_TYPES mapping to handle all variants.
*/
export function isDataRowInsertedChange(change) {
return isDataRowInsertedType(change.t);
}
/**
* Type guard for PropertyChange.
* Uses centralized BC_CHANGE_TYPES mapping to handle all variants (lcpch, prch, PropertyChange).
*/
export function isPropertyChange(change) {
return isPropertyChangeType(change.t);
}
/**
* Type guard for PropertyChanges (batch).
* Uses centralized BC_CHANGE_TYPES mapping to handle all variants (lcpchs, prc, PropertyChanges).
*/
export function isPropertyChanges(change) {
return isPropertyChangesType(change.t);
}
/**
* Type guard for FormToShowChange.
* Uses centralized BC_CHANGE_TYPES mapping.
*/
export function isFormToShowChange(change) {
return isFormToShowChangeType(change.t);
}
/**
* Type guard for DialogToShowChange.
* Uses centralized BC_CHANGE_TYPES mapping.
*/
export function isDialogToShowChange(change) {
return isDialogToShowChangeType(change.t);
}
/**
* Type guard for MessageToShowChange.
* Uses centralized BC_CHANGE_TYPES mapping.
*/
export function isMessageToShowChange(change) {
return isMessageToShowChangeType(change.t);
}
/**
* Type guard for control changes (has ControlReference).
*/
export function isControlChange(change) {
return 'ControlReference' in change;
}
/**
* Type guard for data row changes.
* Uses centralized BC_CHANGE_TYPES mapping to handle all variants.
*/
export function isDataRowChange(change) {
// Use centralized mapping for all data row change types
return isDataRowInsertedType(change.t) ||
isDataRowRemovedType(change.t) ||
isDataRowUpdatedType(change.t) ||
isDataRefreshChangeType(change.t) ||
// These types don't have separate matchers yet, check directly against mapping
BC_CHANGE_TYPES.DataRowPropertyChange.includes(change.t) ||
BC_CHANGE_TYPES.DataRowBookmarkChange.includes(change.t);
}
// ============================================================================
// Control Type Guards
// ============================================================================
/**
* Type guard for LogicalForm.
*/
export function isLogicalForm(control) {
return control.t === 'lf';
}
/**
* Type guard for RepeaterControl.
*/
export function isRepeaterControl(control) {
return control.t === 'rc';
}
/**
* Type guard for RepeaterColumnControl.
*/
export function isRepeaterColumnControl(control) {
return control.t === 'rcc';
}
/**
* Type guard for ActionControl.
*/
export function isActionControl(control) {
return control.t === 'ac';
}
/**
* Type guard for container controls.
*/
export function isContainerControl(control) {
return ['gc', 'stackc', 'stackgc', 'fhc', 'lf'].includes(control.t);
}
/**
* Type guard for data entry controls.
*/
export function isDataEntryControl(control) {
return ['sc', 'bc', 'dc', 'i32c', 'dtc', 'sec', 'i16c', 'i64c', 'nuc', 'pc'].includes(control.t);
}
//# sourceMappingURL=bc-protocol-types.js.map