A Power Platform Toolbox (PPTB) extension for exploring, visualizing, and documenting Power Automate Cloud Flows. Features interactive Mermaid diagram generation, multiple export formats (SVG, CSV, Markdown), advanced filtering, zoom controls, and seamles
npm install @cyco77/pptb-flow-documentation-generator
![]()
A Power Platform Tool Box (PPTB) tool for viewing and documenting Power Automate Cloud Flows. This tool provides an intuitive interface to explore flow definitions, visualize them as interactive Mermaid diagrams, and export documentation in multiple formats.
!Plugin Documentation Generator - Dark Theme
!Plugin Documentation Generator - Light Theme
- š Flow List View - View all Cloud Flows in your Dynamics 365 environment in a sortable table
- Sortable columns with visual arrow indicators (ascending/descending)
- Optimized column widths for better data visibility
- Click any row to open details in a side drawer
- š Advanced Filtering - Real-time search by flow name and description
- š Interactive Mermaid Diagrams - Visualize flow logic with auto-generated Mermaid flowcharts
- š¼ļø Multiple View Modes:
- Diagram View: Interactive flowchart visualization with zoom controls
- Mermaid Code: View and copy the raw Mermaid syntax (formatted with line breaks)
- JSON View: Inspect the original flow definition data
- š Advanced Zoom Controls:
- Zoom range from 50% to 1000%
- Interactive slider for precise control
- +/- buttons for quick adjustments
- Mouse wheel zoom with Ctrl/Cmd modifier
- Reset button to return to 100%
- š¤ Multiple Export Formats:
- Export flow list as CSV file
- Copy flow list to clipboard as CSV
- Copy flow list as Markdown table with flow details
- Export individual flow diagrams as SVG file
- Copy individual flow diagrams as SVG to clipboard
- šØ Modern Theme Support:
- Automatic light/dark theme switching based on PPTB settings
- Fresh, modern color palette for light mode diagrams (Material Design)
- Optimized dark mode styling
- š¢ Visual Notifications - Toast notifications for all operations
- š Event Logging - Track all operations and API calls in real-time
- š Real-time Updates - Automatic refresh on connection changes
- ā
React 18 with TypeScript
- ā
Fluent UI React Components v9 for consistent Microsoft design
- ā
Mermaid.js for diagram rendering
- ā
Vite for fast development and optimized builds
- ā
Power Platform Toolbox API integration
- ā
Dataverse API for querying flow data
- ā
Custom hooks for state management
- ā
Centralized logging service
- ā
Hot Module Replacement (HMR) for development
```
pptb-flow-documentation-generator/
āāā src/
ā āāā components/
ā ā āāā AssemblySteps.tsx # (Legacy component)
ā ā āāā EventLog.tsx # Real-time event log display
ā ā āāā Filter.tsx # Text filtering for flow list
ā ā āāā FlowDetails.tsx # Flow detail view with Mermaid diagram
ā ā āāā Overview.tsx # Flow list table view
ā ā āāā ToolBar.tsx # Action buttons toolbar
ā āāā hooks/
ā ā āāā useConnection.ts # Dataverse connection management
ā ā āāā useToolboxAPI.ts # PPTB API integration
ā ā āāā useToolboxEvents.ts # PPTB event subscription
ā āāā mappers/
ā ā āāā flowDefinitionMapper.ts # Map API responses to flow models
ā āāā services/
ā ā āāā dataverseService.ts # Dataverse API queries
ā ā āāā loggerService.ts # Centralized logging singleton
ā āāā types/
ā ā āāā flowDefinition.ts # Flow definition type definitions
ā āāā utils/
ā ā āāā exportUtils.ts # Export and clipboard utilities
ā ā āāā Flow2MermaidConverter.ts # Convert flow JSON to Mermaid syntax
ā āāā App.tsx # Main application component
ā āāā main.tsx # Entry point
ā āāā index.css # Global styling
āāā dist/ # Build output
āāā index.html
āāā package.json
āāā tsconfig.json
āāā vite.config.ts
- Node.js >= 18.0.0
- npm or yarn
- Power Platform Toolbox installed
1. Clone the repository:
`bash`
git clone
cd pptb-flow-documentation-generator
2. Install dependencies:
`bash`
npm install
Start development server with HMR:
`bash`
npm run dev
The tool will be available at http://localhost:5173
Build the tool in watch mode for continuous updates:
`bash`
npm run watch
Build the optimized production version:
`bash`
npm run build
The output will be in the dist/ directory.
Preview the production build locally:
`bash`
npm run preview
1. Build the tool:
`bash`
npm run build
2. Package the tool (creates npm-shrinkwrap.json):
`bash`
npm run finalize-package
3. Install in Power Platform Toolbox using the PPTB interface
4. Connect to a Dataverse environment
5. Launch the tool to view and document your Cloud Flows
#### Flow List View
- Searchable Table: View all flows with sortable columns (Name, Description, State, Created On, Modified On)
- Click column headers to sort
- Visual arrow indicators show sort direction (ascending/descending)
- Optimized column widths: Name (25%), Description (35%), State (10%), Dates (15% each)
- Text Filter: Real-time search across flow names and descriptions
- Action Buttons:
- Copy CSV: Copy flow list to clipboard in CSV format
- Copy Markdown: Copy flow list as a Markdown table with flow details
- Export CSV: Download flow list as a CSV file
- Flow Selection: Click any row to open the detailed view in a side drawer (80% viewport width, max 1400px)
#### Flow Detail View (Drawer)
- Flow Information:
- Flow name displayed in drawer header
- State, Workflow ID, Created On, Modified On in fixed details section
- View Mode Tabs (combined with context-aware controls in single row):
- Diagram: Interactive Mermaid flowchart with modern styling and zoom controls
- Mermaid Code: View and copy the raw Mermaid syntax (formatted with line breaks after semicolons)
- JSON: Inspect the complete flow definition
- Context-Aware Controls:
- Diagram View: Zoom slider (50%-1000%), +/- buttons, reset button, Copy SVG button, Export SVG button
- Mermaid View: Copy to Clipboard button
- JSON View: Copy to Clipboard button
- Mouse Wheel Zoom: Hold Ctrl (Windows/Linux) or Cmd (Mac) and scroll to zoom in/out
- Scrollable Content: Only the diagram/code/JSON area scrolls, header and controls remain fixed
#### Event Log
- Monitor all operations and API calls
- Color-coded log levels (info, success, warning, error)
- Auto-scrolls to show latest entries
The tool demonstrates various Power Platform Toolbox and Dataverse API features:
`typescript
// Get current connection
const connection = await window.toolboxAPI.getConnection();
console.log(connection.connectionUrl);
// Listen for connection changes
window.toolboxAPI.onToolboxEvent((event, payload) => {
if (event === "connection:updated") {
// Refresh data with new connection
}
});
`
`typescriptworkflows?$select=workflowid,name,description,createdon,modifiedon,statecode,clientdata&$filter=category eq 5
// Query Cloud Flows (workflows)
const flows = await window.dataverseAPI.executeQuery(
`
);
`typescript`
await window.toolboxAPI.utils.showNotification({
title: "Export Successful",
body: "Exported 15 plugin assembly steps",
type: "success",
duration: 3000,
});
`typescript
// Save CSV file
await window.toolboxAPI.utils.saveFile("flow_definitions.csv", csvContent);
// Save SVG diagram
await window.toolboxAPI.utils.saveFile("flow_diagram.svg", svgString);
// Copy to clipboard
await window.toolboxAPI.utils.copyToClipboard(content);
`
`typescript
// Get current theme
const theme = await window.toolboxAPI.utils.getCurrentTheme();
// Returns 'light' or 'dark'
// Listen for theme changes
window.toolboxAPI.onToolboxEvent((event) => {
if (event === "settings:updated") {
updateThemeBasedOnSettings();
}
});
`
`typescript
// Subscribe to all PPTB events
window.toolboxAPI.onToolboxEvent((event, payload) => {
console.log("Event:", event);
console.log("Data:", payload.data);
// Handle specific events
switch (event) {
case "connection:created":
case "connection:updated":
refreshConnection();
break;
case "connection:deleted":
clearData();
break;
}
});
`
- useConnection: Manages Dataverse connection state and refresh logic
- useToolboxAPI: Provides PPTB API access with theme management
- useToolboxEvents: Subscribes to PPTB events and handles callbacks
- loggerService: Singleton service for centralized logging with callback pattern
- Methods: info(), success(), warning(), error()
- Eliminates prop drilling for logging across components
- dataverseService: Handles all Dataverse API queries
- Queries Cloud Flow definitions (workflows)
- Maps raw API responses to typed models
- exportFlowDefinitionsToCSV: Export flow list to CSV file
- copyFlowDefinitionsAsCSV: Copy flow list as CSV to clipboard
- copyFlowDefinitionsAsMarkdown: Copy flows as Markdown table format
- handleExportSVG: Export individual flow diagram as SVG file
- handleCopySVG: Copy individual flow diagram as SVG to clipboard
All export functions support optional notifications for user feedback and use the Power Platform Toolbox API for file operations and clipboard access.
- Flow2MermaidConverter: Converts Power Automate flow JSON definitions to Mermaid flowchart syntax
- Parses flow actions, triggers, and control structures
- Generates clean, readable Mermaid diagrams
- Supports branching, loops, and nested conditions
Full TypeScript coverage with:
- Interface definitions for all data models
- Type-safe API responses
- Strongly typed component props
- PPTB API types from @pptb/types package
The tool uses a custom Vite configuration for PPTB compatibility:
- IIFE format: Bundles as Immediately Invoked Function Expression for iframe compatibility
- Single bundle: Uses inlineDynamicImports to avoid module loading issues with file:// URLstype="module"
- HTML transformation: Custom plugin removes and moves scripts to end of body
- Chunk size limit: Set to 1000 kB to accommodate Fluent UI bundle size
`typescript`
{
workflowid: string;
name: string;
description: string | null;
createdon: Date;
modifiedon: Date;
statecode: number; // 0=Draft, 1=Active, 2=Inactive
clientdata: string; // JSON string of flow definition
}
If you encounter chunk size warnings:
- The tool uses IIFE format which requires a single bundle
- Chunk size limit is configured in vite.config.ts
- This is expected for Fluent UI and Mermaid.js components
- Ensure you're connected to a Dataverse environment in PPTB
- Check the Event Log for connection-related errors
- Verify permissions to read workflow data
- If diagrams don't appear, check browser console for Mermaid errors
- Try switching to another view mode and back to Diagram
- Verify the flow has valid clientdata in JSON format
- The tool automatically syncs with PPTB theme settings
- Check console for theme update events
- Verify PPTB version supports theme API
Contributions are welcome! Please:
1. Fork the repository
2. Create a feature branch
3. Make your changes with appropriate TypeScript types
4. Test the build process
5. Submit a pull request
The project includes automated CI/CD workflows:
#### CI Workflow (.github/workflows/ci.yml)
Runs on every push and pull request to main and develop branches:
- Build and Test:
- Tests on Node.js 18.x and 20.x
- TypeScript type checking
- Build verification
- Uploads build artifacts
- Lint Check:
- Runs ESLint if configured
- Validates code quality
- Security Audit:
- Checks for npm package vulnerabilities
- Fails on critical vulnerabilities
- Warns on high-severity issues
- Package Validation:
- Validates package.json structure
- Creates npm-shrinkwrap.json
- Verifies all required fields
#### Release Workflow (.github/workflows/release.yml)
Triggered when pushing a version tag (e.g., v1.0.0):
- Builds the project
- Creates distribution packages (tar.gz and zip)
- Creates GitHub release with auto-generated notes
- Attaches build artifacts to release
To create a release:
`bashUpdate version in package.json
npm version patch # or minor, major
MIT - See LICENSE file for details
Lars Hildebrandt