@cyco77/pptb-plugin-documentation-generator 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,444 @@
1
+ # Plugin Documentation Generator
2
+
3
+ <p align="center">
4
+ <img src="icon/plugin-documentation_small.png" alt="Plugin Documentation Generator Logo" width="314" height="150">
5
+ </p>
6
+
7
+ <p align="center">
8
+ A Power Platform Tool Box (PPTB) plugin for viewing and documenting Dynamics 365 plugin assemblies and steps. This tool provides an intuitive interface to explore plugin configurations and export documentation in multiple formats.
9
+ </p>
10
+
11
+ ## Screenshots
12
+
13
+ ### Dark Theme
14
+
15
+ ![Plugin Documentation Generator - Dark Theme](screenshots/main_dark.png)
16
+
17
+ ### Light Theme
18
+
19
+ ![Plugin Documentation Generator - Light Theme](screenshots/main_light.png)
20
+
21
+ ## Features
22
+
23
+ ### Core Capabilities
24
+
25
+ - 🔌 **Plugin Assembly Browser** - View all plugin assemblies in your Dynamics 365 environment
26
+ - 📋 **Plugin Step Details** - Display detailed information about SDK message processing steps
27
+ - 🔍 **Advanced Filtering** - Filter assemblies by name and search steps by any property
28
+ - 📊 **Sortable Data Grid** - Sort plugin steps by any column with resizable columns
29
+ - 📤 **Multiple Export Formats**:
30
+ - CSV file export
31
+ - Copy to clipboard as CSV
32
+ - Copy to clipboard as Markdown table
33
+ - 📢 **Visual Notifications** - Toast notifications for all operations
34
+ - 📝 **Event Logging** - Track all operations and API calls in real-time
35
+ - 🎨 **Theme Support** - Automatic light/dark theme switching based on PPTB settings
36
+
37
+ ### Technical Stack
38
+
39
+ - ✅ React 18 with TypeScript
40
+ - ✅ Fluent UI React Components for consistent Microsoft design
41
+ - ✅ Vite for fast development and optimized builds
42
+ - ✅ Power Platform Toolbox API integration
43
+ - ✅ Dataverse API for querying plugin data
44
+ - ✅ Custom hooks for state management
45
+ - ✅ Centralized logging service
46
+ - ✅ Hot Module Replacement (HMR) for development
47
+
48
+ ## Structure
49
+
50
+ ```
51
+ pptb-plugin-documentation-generator/
52
+ ├── src/
53
+ │ ├── components/
54
+ │ │ ├── AssemblySteps.tsx # Data grid for plugin steps
55
+ │ │ ├── EventLog.tsx # Real-time event log display
56
+ │ │ ├── Filter.tsx # Assembly and text filtering
57
+ │ │ ├── Overview.tsx # Main container component
58
+ │ │ └── ToolBar.tsx # Action buttons toolbar
59
+ │ ├── hooks/
60
+ │ │ ├── useConnection.ts # Dataverse connection management
61
+ │ │ ├── useEventLog.ts # Event logging hook
62
+ │ │ └── useToolboxEvents.ts # PPTB event subscription
63
+ │ ├── mappers/
64
+ │ │ ├── pluginAssemblyMapper.ts # Map API responses to models
65
+ │ │ └── pluginAssemblyStepMapper.ts # Map step data to models
66
+ │ ├── services/
67
+ │ │ ├── dataverseService.ts # Dataverse API queries
68
+ │ │ └── loggerService.ts # Centralized logging singleton
69
+ │ ├── types/
70
+ │ │ ├── pluginAssembly.ts # Plugin assembly type definitions
71
+ │ │ └── pluginAssemblyStep.ts # Plugin step type definitions
72
+ │ ├── utils/
73
+ │ │ └── exportUtils.ts # Export and clipboard utilities
74
+ │ ├── App.tsx # Main application component
75
+ │ ├── main.tsx # Entry point
76
+ │ └── index.css # Global styling
77
+ ├── dist/ # Build output
78
+ ├── index.html
79
+ ├── package.json
80
+ ├── tsconfig.json
81
+ └── vite.config.ts
82
+ ```
83
+
84
+ ## Installation
85
+
86
+ ### Prerequisites
87
+
88
+ - Node.js >= 18.0.0
89
+ - npm or yarn
90
+ - Power Platform Toolbox installed
91
+
92
+ ### Setup
93
+
94
+ 1. Clone the repository:
95
+
96
+ ```bash
97
+ git clone <repository-url>
98
+ cd pptb-plugin-documentation-generator
99
+ ```
100
+
101
+ 2. Install dependencies:
102
+
103
+ ```bash
104
+ npm install
105
+ ```
106
+
107
+ ## Development
108
+
109
+ ### Development Server
110
+
111
+ Start development server with HMR:
112
+
113
+ ```bash
114
+ npm run dev
115
+ ```
116
+
117
+ The tool will be available at `http://localhost:5173`
118
+
119
+ ### Watch Mode
120
+
121
+ Build the tool in watch mode for continuous updates:
122
+
123
+ ```bash
124
+ npm run watch
125
+ ```
126
+
127
+ ### Production Build
128
+
129
+ Build the optimized production version:
130
+
131
+ ```bash
132
+ npm run build
133
+ ```
134
+
135
+ The output will be in the `dist/` directory.
136
+
137
+ ### Preview Build
138
+
139
+ Preview the production build locally:
140
+
141
+ ```bash
142
+ npm run preview
143
+ ```
144
+
145
+ ## Usage
146
+
147
+ ### In Power Platform Toolbox
148
+
149
+ 1. Build the tool:
150
+
151
+ ```bash
152
+ npm run build
153
+ ```
154
+
155
+ 2. Package the tool (creates npm-shrinkwrap.json):
156
+
157
+ ```bash
158
+ npm run finalize-package
159
+ ```
160
+
161
+ 3. Install in Power Platform Toolbox using the PPTB interface
162
+
163
+ 4. Connect to a Dataverse environment
164
+
165
+ 5. Launch the plugin to view assemblies and steps
166
+
167
+ ### User Interface
168
+
169
+ #### Filter Section
170
+
171
+ - **Plugin Assembly Dropdown**: Select an assembly to view its steps
172
+ - **Filter Steps SearchBox**: Real-time search across all step properties (name, SDK message, mode, stage, rank, event handler, filtering attributes)
173
+
174
+ #### Action Buttons
175
+
176
+ - **Export CSV**: Download plugin steps as a CSV file
177
+ - **Copy CSV**: Copy steps to clipboard in CSV format
178
+ - **Copy Markdown**: Copy steps to clipboard as a formatted Markdown table
179
+
180
+ #### Data Grid
181
+
182
+ - Click column headers to sort
183
+ - Drag column borders to resize
184
+ - View tooltips on hover for full text content
185
+
186
+ #### Event Log
187
+
188
+ - Monitor all operations and API calls
189
+ - Color-coded log levels (info, success, warning, error)
190
+ - Auto-scrolls to show latest entries
191
+
192
+ ## API Usage
193
+
194
+ The tool demonstrates various Power Platform Toolbox and Dataverse API features:
195
+
196
+ ### Connection Management
197
+
198
+ ```typescript
199
+ // Get current connection
200
+ const connection = await window.toolboxAPI.getConnection();
201
+ console.log(connection.connectionUrl);
202
+
203
+ // Listen for connection changes
204
+ window.toolboxAPI.onToolboxEvent((event, payload) => {
205
+ if (event === "connection:updated") {
206
+ // Refresh data with new connection
207
+ }
208
+ });
209
+ ```
210
+
211
+ ### Dataverse Queries
212
+
213
+ ```typescript
214
+ // Query plugin assemblies
215
+ const assemblies = await window.dataverseAPI.executeQuery(
216
+ `pluginassemblies?$select=name,version,pluginassemblyid&$filter=...`
217
+ );
218
+
219
+ // Query SDK message processing steps
220
+ const steps = await window.dataverseAPI.executeQuery(
221
+ `sdkmessageprocessingsteps?$select=...&$filter=...&$expand=...`
222
+ );
223
+ ```
224
+
225
+ ### Notifications
226
+
227
+ ```typescript
228
+ await window.toolboxAPI.utils.showNotification({
229
+ title: "Export Successful",
230
+ body: "Exported 15 plugin assembly steps",
231
+ type: "success",
232
+ duration: 3000,
233
+ });
234
+ ```
235
+
236
+ ### File Operations
237
+
238
+ ```typescript
239
+ // Save file
240
+ await window.toolboxAPI.utils.saveFile("plugin_steps.csv", csvContent);
241
+
242
+ // Copy to clipboard
243
+ await window.toolboxAPI.utils.copyToClipboard(content);
244
+ ```
245
+
246
+ ### Theme Management
247
+
248
+ ```typescript
249
+ // Get current theme
250
+ const theme = await window.toolboxAPI.utils.getCurrentTheme();
251
+ // Returns 'light' or 'dark'
252
+
253
+ // Listen for theme changes
254
+ window.toolboxAPI.onToolboxEvent((event) => {
255
+ if (event === "settings:updated") {
256
+ updateThemeBasedOnSettings();
257
+ }
258
+ });
259
+ ```
260
+
261
+ ### Event Subscription
262
+
263
+ ```typescript
264
+ // Subscribe to all PPTB events
265
+ window.toolboxAPI.onToolboxEvent((event, payload) => {
266
+ console.log("Event:", event);
267
+ console.log("Data:", payload.data);
268
+
269
+ // Handle specific events
270
+ switch (event) {
271
+ case "connection:created":
272
+ case "connection:updated":
273
+ refreshConnection();
274
+ break;
275
+ case "connection:deleted":
276
+ clearData();
277
+ break;
278
+ }
279
+ });
280
+ ```
281
+
282
+ ## Architecture
283
+
284
+ ### Custom Hooks
285
+
286
+ - **useConnection**: Manages Dataverse connection state and refresh logic
287
+ - **useToolboxEvents**: Subscribes to PPTB events and handles callbacks
288
+ - **useEventLog**: Manages event log state and logger service integration
289
+
290
+ ### Services
291
+
292
+ - **loggerService**: Singleton service for centralized logging with callback pattern
293
+
294
+ - Methods: `info()`, `success()`, `warning()`, `error()`
295
+ - Eliminates prop drilling for logging across components
296
+
297
+ - **dataverseService**: Handles all Dataverse API queries
298
+ - Queries plugin assemblies and SDK message processing steps
299
+ - Maps raw API responses to typed models
300
+
301
+ ### Export Utilities
302
+
303
+ - **exportPluginAssemblyStepsToCSV**: Export to file
304
+ - **copyPluginAssemblyStepsAsCSV**: Copy CSV to clipboard
305
+ - **copyPluginAssemblyStepsAsMarkdown**: Copy Markdown table to clipboard
306
+
307
+ All export functions support optional notifications for user feedback.
308
+
309
+ ### Type Safety
310
+
311
+ Full TypeScript coverage with:
312
+
313
+ - Interface definitions for all data models
314
+ - Type-safe API responses
315
+ - Strongly typed component props
316
+ - PPTB API types from `@pptb/types` package
317
+
318
+ ## Configuration
319
+
320
+ ### Vite Build Configuration
321
+
322
+ The tool uses a custom Vite configuration for PPTB compatibility:
323
+
324
+ - **IIFE format**: Bundles as Immediately Invoked Function Expression for iframe compatibility
325
+ - **Single bundle**: Uses `inlineDynamicImports` to avoid module loading issues with file:// URLs
326
+ - **HTML transformation**: Custom plugin removes `type="module"` and moves scripts to end of body
327
+ - **Chunk size limit**: Set to 1000 kB to accommodate Fluent UI bundle size
328
+
329
+ ## Data Models
330
+
331
+ ### PluginAssembly
332
+
333
+ ```typescript
334
+ {
335
+ pluginassemblyid: string;
336
+ name: string;
337
+ version: string;
338
+ }
339
+ ```
340
+
341
+ ### PluginAssemblyStep
342
+
343
+ ```typescript
344
+ {
345
+ id: string;
346
+ name: string;
347
+ sdkMessage: string;
348
+ mode: string; // Sync/Async
349
+ stage: string; // PreValidation/PreOperation/PostOperation
350
+ rank: number; // Execution order
351
+ eventHandler: string; // Full type name
352
+ filteringattributes: string;
353
+ }
354
+ ```
355
+
356
+ ## Troubleshooting
357
+
358
+ ### Build Issues
359
+
360
+ If you encounter chunk size warnings:
361
+
362
+ - The tool uses IIFE format which requires a single bundle
363
+ - Chunk size limit is configured in `vite.config.ts`
364
+ - This is expected for Fluent UI components
365
+
366
+ ### Connection Issues
367
+
368
+ - Ensure you're connected to a Dataverse environment in PPTB
369
+ - Check the Event Log for connection-related errors
370
+ - Verify permissions to read plugin assembly data
371
+
372
+ ### Theme Not Updating
373
+
374
+ - The tool automatically syncs with PPTB theme settings
375
+ - Check console for theme update events
376
+ - Verify PPTB version supports theme API
377
+
378
+ ## Contributing
379
+
380
+ Contributions are welcome! Please:
381
+
382
+ 1. Fork the repository
383
+ 2. Create a feature branch
384
+ 3. Make your changes with appropriate TypeScript types
385
+ 4. Test the build process
386
+ 5. Submit a pull request
387
+
388
+ ### GitHub Actions
389
+
390
+ The project includes automated CI/CD workflows:
391
+
392
+ #### CI Workflow (`.github/workflows/ci.yml`)
393
+
394
+ Runs on every push and pull request to `main` and `develop` branches:
395
+
396
+ - **Build and Test**:
397
+
398
+ - Tests on Node.js 18.x and 20.x
399
+ - TypeScript type checking
400
+ - Build verification
401
+ - Uploads build artifacts
402
+
403
+ - **Lint Check**:
404
+
405
+ - Runs ESLint if configured
406
+ - Validates code quality
407
+
408
+ - **Security Audit**:
409
+
410
+ - Checks for npm package vulnerabilities
411
+ - Fails on critical vulnerabilities
412
+ - Warns on high-severity issues
413
+
414
+ - **Package Validation**:
415
+ - Validates package.json structure
416
+ - Creates npm-shrinkwrap.json
417
+ - Verifies all required fields
418
+
419
+ #### Release Workflow (`.github/workflows/release.yml`)
420
+
421
+ Triggered when pushing a version tag (e.g., `v1.0.0`):
422
+
423
+ - Builds the project
424
+ - Creates distribution packages (tar.gz and zip)
425
+ - Creates GitHub release with auto-generated notes
426
+ - Attaches build artifacts to release
427
+
428
+ **To create a release:**
429
+
430
+ ```bash
431
+ # Update version in package.json
432
+ npm version patch # or minor, major
433
+
434
+ # Push with tags
435
+ git push origin main --tags
436
+ ```
437
+
438
+ ## License
439
+
440
+ MIT - See LICENSE file for details
441
+
442
+ ## Author
443
+
444
+ Lars Hildebrandt