UNPKG

@mcp-consultant-tools/powerplatform-data

Version:

MCP server for PowerPlatform data CRUD operations (operational use)

568 lines 22.6 kB
export interface PowerPlatformConfig { organizationUrl: string; clientId: string; clientSecret: string; tenantId: string; } export interface ApiCollectionResponse<T> { value: T[]; [key: string]: any; } export declare class PowerPlatformService { private config; private msalClient; private accessToken; private tokenExpirationTime; constructor(config: PowerPlatformConfig); /** * Get an access token for the PowerPlatform API */ private getAccessToken; /** * Make an authenticated request to the PowerPlatform API * Extended to support all HTTP methods for write operations */ private makeRequest; /** * Get metadata about an entity * @param entityName The logical name of the entity */ getEntityMetadata(entityName: string): Promise<any>; /** * Get metadata about entity attributes/fields * @param entityName The logical name of the entity */ getEntityAttributes(entityName: string): Promise<ApiCollectionResponse<any>>; /** * Get metadata about a specific entity attribute/field * @param entityName The logical name of the entity * @param attributeName The logical name of the attribute */ getEntityAttribute(entityName: string, attributeName: string): Promise<any>; /** * Get one-to-many relationships for an entity * @param entityName The logical name of the entity */ getEntityOneToManyRelationships(entityName: string): Promise<ApiCollectionResponse<any>>; /** * Get many-to-many relationships for an entity * @param entityName The logical name of the entity */ getEntityManyToManyRelationships(entityName: string): Promise<ApiCollectionResponse<any>>; /** * Get all relationships (one-to-many and many-to-many) for an entity * @param entityName The logical name of the entity */ getEntityRelationships(entityName: string): Promise<{ oneToMany: ApiCollectionResponse<any>; manyToMany: ApiCollectionResponse<any>; }>; /** * Get a global option set definition by name * @param optionSetName The name of the global option set * @returns The global option set definition */ getGlobalOptionSet(optionSetName: string): Promise<any>; /** * Get a specific record by entity name (plural) and ID * @param entityNamePlural The plural name of the entity (e.g., 'accounts', 'contacts') * @param recordId The GUID of the record * @returns The record data */ getRecord(entityNamePlural: string, recordId: string): Promise<any>; /** * Query records using entity name (plural) and a filter expression * @param entityNamePlural The plural name of the entity (e.g., 'accounts', 'contacts') * @param filter OData filter expression (e.g., "name eq 'test'") * @param maxRecords Maximum number of records to retrieve (default: 50) * @returns Filtered list of records */ queryRecords(entityNamePlural: string, filter: string, maxRecords?: number): Promise<ApiCollectionResponse<any>>; /** * Create a new record in Dataverse * @param entityNamePlural The plural name of the entity (e.g., 'accounts', 'contacts') * @param data Record data as JSON object (field names must match logical names) * @returns Created record with ID and OData context */ createRecord(entityNamePlural: string, data: Record<string, any>): Promise<any>; /** * Update an existing record in Dataverse * @param entityNamePlural The plural name of the entity (e.g., 'accounts', 'contacts') * @param recordId The GUID of the record to update * @param data Partial record data to update (only fields being changed) * @returns Updated record (if Prefer header used) or void */ updateRecord(entityNamePlural: string, recordId: string, data: Record<string, any>): Promise<any>; /** * Delete a record from Dataverse * @param entityNamePlural The plural name of the entity (e.g., 'accounts', 'contacts') * @param recordId The GUID of the record to delete * @returns Void (successful deletion returns 204 No Content) */ deleteRecord(entityNamePlural: string, recordId: string): Promise<void>; /** * Get all plugin assemblies in the environment * @param includeManaged Include managed assemblies (default: false) * @param maxRecords Maximum number of assemblies to return (default: 100) * @returns List of plugin assemblies with basic information */ getPluginAssemblies(includeManaged?: boolean, maxRecords?: number): Promise<any>; /** * Get a plugin assembly by name with all related plugin types, steps, and images * @param assemblyName The name of the plugin assembly * @param includeDisabled Include disabled steps (default: false) * @returns Complete plugin assembly information with validation */ getPluginAssemblyComplete(assemblyName: string, includeDisabled?: boolean): Promise<any>; /** * Get all plugins that execute on a specific entity, organized by message and execution order * @param entityName The logical name of the entity * @param messageFilter Optional filter by message name (e.g., "Create", "Update") * @param includeDisabled Include disabled steps (default: false) * @returns Complete plugin pipeline for the entity */ getEntityPluginPipeline(entityName: string, messageFilter?: string, includeDisabled?: boolean): Promise<any>; /** * Get plugin trace logs with filtering * @param options Filtering options for trace logs * @returns Filtered trace logs with parsed exception details */ getPluginTraceLogs(options: { entityName?: string; messageName?: string; correlationId?: string; pluginStepId?: string; exceptionOnly?: boolean; hoursBack?: number; maxRecords?: number; }): Promise<any>; private getOperationTypeName; private extractExceptionType; private extractExceptionMessage; /** * Get all Power Automate flows (cloud flows) in the environment * @param activeOnly Only return activated flows (default: false) * @param maxRecords Maximum number of flows to return (default: 100) * @returns List of Power Automate flows with basic information */ getFlows(activeOnly?: boolean, maxRecords?: number): Promise<any>; /** * Get a specific Power Automate flow with its complete definition * @param flowId The GUID of the flow (workflowid) * @returns Complete flow information including the flow definition JSON */ getFlowDefinition(flowId: string): Promise<any>; /** * Get flow run history for a specific Power Automate flow * @param flowId The GUID of the flow (workflowid) * @param maxRecords Maximum number of runs to return (default: 100) * @returns List of flow runs with status, start time, duration, and error details */ getFlowRuns(flowId: string, maxRecords?: number): Promise<any>; /** * Get all classic Dynamics workflows in the environment * @param activeOnly Only return activated workflows (default: false) * @param maxRecords Maximum number of workflows to return (default: 100) * @returns List of classic workflows with basic information */ getWorkflows(activeOnly?: boolean, maxRecords?: number): Promise<any>; /** * Get a specific classic workflow with its complete XAML definition * @param workflowId The GUID of the workflow (workflowid) * @returns Complete workflow information including the XAML definition */ getWorkflowDefinition(workflowId: string): Promise<any>; /** * Get all business rules in the environment * @param activeOnly Only return activated business rules (default: false) * @param maxRecords Maximum number of business rules to return (default: 100) * @returns List of business rules with basic information */ getBusinessRules(activeOnly?: boolean, maxRecords?: number): Promise<any>; /** * Get a specific business rule with its complete XAML definition * @param workflowId The GUID of the business rule (workflowid) * @returns Complete business rule information including the XAML definition */ getBusinessRule(workflowId: string): Promise<any>; /** * Get all model-driven apps in the environment * @param activeOnly Only return active apps (default: false) * @param maxRecords Maximum number of apps to return (default: 100) * @returns List of model-driven apps with basic information */ getApps(activeOnly?: boolean, maxRecords?: number, includeUnpublished?: boolean, solutionUniqueName?: string): Promise<any>; /** * Get a specific model-driven app by ID * @param appId The GUID of the app (appmoduleid) * @returns Complete app information including publisher details */ getApp(appId: string): Promise<any>; /** * Get all components (entities, forms, views, sitemaps) associated with an app * @param appId The GUID of the app (appmoduleid) * @returns List of app components with type information */ getAppComponents(appId: string): Promise<any>; /** * Get the sitemap for a specific app * @param appId The GUID of the app (appmoduleid) * @returns Sitemap information including XML */ getAppSitemap(appId: string): Promise<any>; /** * Create a new model-driven app * @param appDefinition The app definition object * @param solutionUniqueName Optional solution to add the app to * @returns The created app information including ID */ createApp(appDefinition: any, solutionUniqueName?: string): Promise<any>; /** * Create a sitemap from simplified configuration (no XML knowledge required) * @param config Simplified sitemap configuration * @param solutionUniqueName Optional solution to add the sitemap to * @returns The created sitemap information including ID and XML */ createSimpleSitemap(config: any, solutionUniqueName?: string): Promise<any>; /** * Add entities to an app by modifying the sitemap XML * @param appId The GUID of the app * @param entityNames Array of entity logical names to add * @returns Result of the operation */ addEntitiesToApp(appId: string, entityNames: string[]): Promise<any>; /** * Validate an app before publishing * @param appId The GUID of the app * @returns Validation result with any issues found */ validateApp(appId: string): Promise<any>; /** * Publish an app to make it available to users * @param appId The GUID of the app * @returns Result of the publish operation */ publishApp(appId: string): Promise<any>; /** * Helper to escape XML special characters */ private escapeXml; /** * Create a new custom entity (table) * @param entityDefinition The entity definition object * @param solutionUniqueName Optional solution to add the entity to * @returns The created entity metadata */ createEntity(entityDefinition: any, solutionUniqueName?: string): Promise<any>; /** * Update an existing entity * @param metadataId The MetadataId of the entity * @param updates The properties to update * @param solutionUniqueName Optional solution context */ updateEntity(metadataId: string, updates: any, solutionUniqueName?: string): Promise<void>; /** * Delete a custom entity * @param metadataId The MetadataId of the entity to delete */ deleteEntity(metadataId: string): Promise<void>; /** * Update entity icon using Fluent UI System Icon * @param entityLogicalName The logical name of the entity * @param iconFileName The Fluent UI icon file name (e.g., 'people_community_24_filled.svg') * @param solutionUniqueName Optional solution to add the web resource to * @returns Result with web resource ID and icon vector name */ updateEntityIcon(entityLogicalName: string, iconFileName: string, solutionUniqueName?: string): Promise<any>; /** * Create a new attribute on an entity * @param entityLogicalName The logical name of the entity * @param attributeDefinition The attribute definition object * @param solutionUniqueName Optional solution to add the attribute to * @returns The created attribute metadata */ createAttribute(entityLogicalName: string, attributeDefinition: any, solutionUniqueName?: string): Promise<any>; /** * Update an existing attribute * @param entityLogicalName The logical name of the entity * @param attributeLogicalName The logical name of the attribute * @param updates The properties to update * @param solutionUniqueName Optional solution context */ updateAttribute(entityLogicalName: string, attributeLogicalName: string, updates: any, solutionUniqueName?: string): Promise<void>; /** * Delete an attribute * @param entityLogicalName The logical name of the entity * @param attributeMetadataId The MetadataId of the attribute to delete */ deleteAttribute(entityLogicalName: string, attributeMetadataId: string): Promise<void>; /** * Create a picklist attribute using a global option set * @param entityLogicalName The logical name of the entity * @param attributeDefinition The attribute definition (must reference a global option set) * @param solutionUniqueName Optional solution to add the attribute to * @returns The created attribute metadata */ createGlobalOptionSetAttribute(entityLogicalName: string, attributeDefinition: any, solutionUniqueName?: string): Promise<any>; /** * Create a one-to-many relationship * @param relationshipDefinition The relationship definition * @param solutionUniqueName Optional solution to add the relationship to */ createOneToManyRelationship(relationshipDefinition: any, solutionUniqueName?: string): Promise<any>; /** * Create a many-to-many relationship * @param relationshipDefinition The relationship definition * @param solutionUniqueName Optional solution to add the relationship to */ createManyToManyRelationship(relationshipDefinition: any, solutionUniqueName?: string): Promise<any>; /** * Delete a relationship * @param metadataId The MetadataId of the relationship to delete */ deleteRelationship(metadataId: string): Promise<void>; /** * Update a relationship * Note: Most relationship properties are immutable, only labels can be updated * @param metadataId The MetadataId of the relationship * @param updates The properties to update (typically labels) */ updateRelationship(metadataId: string, updates: any): Promise<void>; /** * Get detailed information about a relationship * @param metadataId The MetadataId of the relationship * @returns The relationship metadata */ getRelationshipDetails(metadataId: string): Promise<any>; /** * Publish all customizations */ publishAllCustomizations(): Promise<void>; /** * Publish specific customizations * @param parameterXml The ParameterXml specifying what to publish */ publishXml(parameterXml: string): Promise<void>; /** * Create a global option set * @param optionSetDefinition The option set definition * @param solutionUniqueName Optional solution to add the option set to */ createGlobalOptionSet(optionSetDefinition: any, solutionUniqueName?: string): Promise<any>; /** * Delete a global option set * @param metadataId The MetadataId of the option set to delete */ deleteGlobalOptionSet(metadataId: string): Promise<void>; /** * Update a global option set */ updateGlobalOptionSet(metadataId: string, updates: any, solutionUniqueName?: string): Promise<void>; /** * Add a value to a global option set */ addOptionSetValue(optionSetName: string, value: number, label: string, solutionUniqueName?: string): Promise<any>; /** * Update an option set value */ updateOptionSetValue(optionSetName: string, value: number, label: string, solutionUniqueName?: string): Promise<void>; /** * Delete an option set value */ deleteOptionSetValue(optionSetName: string, value: number): Promise<void>; /** * Reorder option set values */ reorderOptionSetValues(optionSetName: string, values: number[], solutionUniqueName?: string): Promise<void>; /** * Create a form (systemform) */ createForm(form: any, solutionUniqueName?: string): Promise<any>; /** * Update a form */ updateForm(formId: string, updates: any, solutionUniqueName?: string): Promise<void>; /** * Delete a form */ deleteForm(formId: string): Promise<void>; /** * Get forms for an entity */ getForms(entityLogicalName: string): Promise<any>; /** * Create a view (savedquery) */ createView(view: any, solutionUniqueName?: string): Promise<any>; /** * Update a view */ updateView(viewId: string, updates: any, solutionUniqueName?: string): Promise<void>; /** * Delete a view */ deleteView(viewId: string): Promise<void>; /** * Get views for an entity */ getViews(entityLogicalName: string): Promise<any>; /** * Activate a form (set statecode=1) * @param formId The systemformid (GUID) */ activateForm(formId: string): Promise<void>; /** * Deactivate a form (set statecode=0) * @param formId The systemformid (GUID) */ deactivateForm(formId: string): Promise<void>; /** * Set a view as the default view for its entity * @param viewId The savedqueryid (GUID) */ setDefaultView(viewId: string): Promise<void>; /** * Get the FetchXML from a view * @param viewId The savedqueryid (GUID) * @returns The view with FetchXML */ getViewFetchXml(viewId: string): Promise<any>; /** * Create a web resource */ createWebResource(webResource: any, solutionUniqueName?: string): Promise<any>; /** * Update a web resource */ updateWebResource(webResourceId: string, updates: any, solutionUniqueName?: string): Promise<void>; /** * Delete a web resource */ deleteWebResource(webResourceId: string): Promise<void>; /** * Get web resource */ getWebResource(webResourceId: string): Promise<any>; /** * Get web resources by name pattern */ getWebResources(nameFilter?: string): Promise<any>; /** * Get web resource content (base64 encoded) * @param webResourceId The webresourceid (GUID) * @returns The web resource with content field */ getWebResourceContent(webResourceId: string): Promise<any>; /** * Get web resource dependencies * @param webResourceId The webresourceid (GUID) * @returns List of dependencies */ getWebResourceDependencies(webResourceId: string): Promise<any>; /** * Create a publisher */ createPublisher(publisher: any): Promise<any>; /** * Get publishers */ getPublishers(): Promise<any>; /** * Create a solution */ createSolution(solution: any): Promise<any>; /** * Get solutions */ getSolutions(): Promise<any>; /** * Get solution by unique name */ getSolution(uniqueName: string): Promise<any>; /** * Add component to solution */ addComponentToSolution(solutionUniqueName: string, componentId: string, componentType: number, addRequiredComponents?: boolean, includedComponentSettingsValues?: string): Promise<void>; /** * Remove component from solution */ removeComponentFromSolution(solutionUniqueName: string, componentId: string, componentType: number): Promise<void>; /** * Get solution components */ getSolutionComponents(solutionUniqueName: string): Promise<any>; /** * Export solution */ exportSolution(solutionName: string, managed?: boolean): Promise<any>; /** * Import solution */ importSolution(customizationFile: string, publishWorkflows?: boolean, overwriteUnmanagedCustomizations?: boolean): Promise<any>; /** * Delete a solution */ deleteSolution(solutionId: string): Promise<void>; /** * Publish specific entity */ publishEntity(entityLogicalName: string): Promise<void>; /** * Publish specific component */ publishComponent(componentId: string, componentType: number): Promise<void>; /** * Check for unpublished customizations */ checkUnpublishedChanges(): Promise<any>; /** * Check component dependencies */ checkDependencies(componentId: string, componentType: number): Promise<any>; /** * Check if component can be deleted */ checkDeleteEligibility(componentId: string, componentType: number): Promise<{ canDelete: boolean; dependencies: any[]; }>; /** * Preview unpublished changes * Returns all components that have unpublished customizations */ previewUnpublishedChanges(): Promise<any>; /** * Check dependencies for a specific component * @param componentId The component ID (GUID) * @param componentType The component type code * @returns Dependency information */ checkComponentDependencies(componentId: string, componentType: number): Promise<any>; /** * Validate solution integrity * Checks for missing dependencies and other issues * @param solutionUniqueName The unique name of the solution * @returns Validation results */ validateSolutionIntegrity(solutionUniqueName: string): Promise<any>; /** * Validate schema name */ validateSchemaName(schemaName: string, prefix: string): { valid: boolean; errors: string[]; }; /** * Get entity customization information */ getEntityCustomizationInfo(entityLogicalName: string): Promise<any>; /** * Check if entity has dependencies */ checkEntityDependencies(entityLogicalName: string): Promise<any>; /** * Helper to generate GUID */ private generateGuid; } //# sourceMappingURL=PowerPlatformService.d.ts.map