@power-maverick/tool-erd-generator 0.0.7

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.
Files changed (47) hide show
  1. package/CONVERSION_SUMMARY.md +288 -0
  2. package/README.md +463 -0
  3. package/REFACTORING_COMPLETE.md +352 -0
  4. package/TYPESCRIPT_NOTES.md +57 -0
  5. package/dist/src/components/ERDGenerator.d.ts +44 -0
  6. package/dist/src/components/ERDGenerator.d.ts.map +1 -0
  7. package/dist/src/components/ERDGenerator.js +232 -0
  8. package/dist/src/components/ERDGenerator.js.map +1 -0
  9. package/dist/src/dvdtIntegration/integration.d.ts +47 -0
  10. package/dist/src/dvdtIntegration/integration.d.ts.map +1 -0
  11. package/dist/src/dvdtIntegration/integration.js +223 -0
  12. package/dist/src/dvdtIntegration/integration.js.map +1 -0
  13. package/dist/src/index.d.ts +6 -0
  14. package/dist/src/index.d.ts.map +1 -0
  15. package/dist/src/index.js +26 -0
  16. package/dist/src/index.js.map +1 -0
  17. package/dist/src/models/interfaces.d.ts +84 -0
  18. package/dist/src/models/interfaces.d.ts.map +1 -0
  19. package/dist/src/models/interfaces.js +3 -0
  20. package/dist/src/models/interfaces.js.map +1 -0
  21. package/dist/src/models/platformApi.d.ts +92 -0
  22. package/dist/src/models/platformApi.d.ts.map +1 -0
  23. package/dist/src/models/platformApi.js +213 -0
  24. package/dist/src/models/platformApi.js.map +1 -0
  25. package/dist/src/utils/Constants.d.ts +3 -0
  26. package/dist/src/utils/Constants.d.ts.map +1 -0
  27. package/dist/src/utils/Constants.js +6 -0
  28. package/dist/src/utils/Constants.js.map +1 -0
  29. package/dist/src/utils/DataverseClient.d.ts +53 -0
  30. package/dist/src/utils/DataverseClient.d.ts.map +1 -0
  31. package/dist/src/utils/DataverseClient.js +236 -0
  32. package/dist/src/utils/DataverseClient.js.map +1 -0
  33. package/dist/webview/index.css +1 -0
  34. package/dist/webview/index.html +13 -0
  35. package/dist/webview/index.js +49 -0
  36. package/index.html +12 -0
  37. package/package.json +50 -0
  38. package/tsconfig.json +20 -0
  39. package/tsconfig.webview.json +24 -0
  40. package/ui/test.html +326 -0
  41. package/webview/App.tsx +412 -0
  42. package/webview/index.html +12 -0
  43. package/webview/main.tsx +10 -0
  44. package/webview/styles.css +288 -0
  45. package/webview/tsconfig.json +35 -0
  46. package/webview/tsconfig.node.json +10 -0
  47. package/webview/vite.config.ts +17 -0
package/README.md ADDED
@@ -0,0 +1,463 @@
1
+ # ERD Generator for Dataverse
2
+
3
+ Generate Entity Relationship Diagrams (ERD) from Dataverse solutions. **React-based tool** with dual integration support for **DVDT (Dataverse DevTools for VS Code)** and **PPTB (PowerPlatform ToolBox)**.
4
+
5
+ > **🚀 Works in Both Platforms**: This tool automatically detects whether it's running in DVDT (VS Code extension) or PPTB (desktop application) and adapts accordingly. Zero configuration needed!
6
+
7
+ ## Quick Links
8
+
9
+ - **[PPTB Integration Guide](docs/PPTB_Integration.md)** - For PowerPlatform ToolBox users
10
+ - **[DVDT Integration Guide](docs/DVDT_Integration.md)** - For VS Code extension developers
11
+ - **[Integration Examples](docs/Integration_Examples.md)** - Complete code samples for both platforms
12
+ - **[Getting Started](docs/Getting_Started.md)** - New to this tool? Start here!
13
+
14
+ ## Features
15
+
16
+ - **🎨 Modern React UI**: Component-based architecture with React 18 and TypeScript
17
+ - **🔄 Dual Platform Support**: Works seamlessly in both VS Code (DVDT) and PowerPlatform ToolBox (PPTB)
18
+ - **⚡ Fast Development**: Vite for instant HMR and optimized production builds
19
+ - **🔌 Minimal Integration**: Just pass credentials - tool handles all the rest
20
+ - **📊 Multiple Formats**: Generate ERDs in Mermaid, PlantUML, or Graphviz DOT
21
+ - **🎯 Smart Detection**: Automatically detects DVDT vs PPTB environment
22
+ - **🛠️ Configurable Output**: Control attributes, relationships, and detail level
23
+ - **📥 Export Options**: Download source files or copy to clipboard
24
+ - **🔍 Visual Preview**: Interactive Mermaid diagram rendering (when available)
25
+ - **🔒 Secure**: Platform-abstracted APIs ensure security in both environments
26
+
27
+ ## Platform Support
28
+
29
+ | Platform | Description | Status |
30
+ |----------|-------------|--------|
31
+ | **DVDT** | Dataverse DevTools for VS Code | ✅ Fully Supported |
32
+ | **PPTB** | PowerPlatform ToolBox (Desktop) | ✅ Fully Supported |
33
+
34
+ Both platforms use the same codebase with automatic platform detection and adaptation.
35
+
36
+ ## Technical Architecture
37
+
38
+ ### Platform Abstraction Layer
39
+ The tool uses a unified `IPlatformAPI` interface that abstracts platform differences:
40
+
41
+ ```typescript
42
+ // Automatically detects PPTB or DVDT
43
+ const api = PlatformAPIFactory.create();
44
+
45
+ // Works the same in both platforms
46
+ const context = await api.getToolContext();
47
+ await api.showNotification({ title: 'Success', body: 'Done!', type: 'success' });
48
+ await api.saveFile('erd.mmd', diagram);
49
+ await api.copyToClipboard(text);
50
+ ```
51
+
52
+ ### Build System
53
+ - **Vite**: Modern build tool for fast development and optimized production builds
54
+ - **React 18**: Latest React with hooks and concurrent features
55
+ - **TypeScript**: Full type safety across the codebase
56
+ - **Dual Build Target**:
57
+ - Extension code (Node.js/VS Code) compiled with `tsc`
58
+ - Webview (browser) bundled with Vite
59
+ - Single `dist/` output works for both platforms
60
+
61
+ ### Platform Integration
62
+ The tool automatically detects its environment:
63
+
64
+ 1. **DVDT (VS Code)**: Detects `window.acquireVsCodeApi()`
65
+ - Receives credentials via `postMessage` with `setCredentials` command
66
+ - Uses VS Code APIs for file operations and clipboard
67
+
68
+ 2. **PPTB (ToolBox)**: Detects `window.toolboxAPI`
69
+ - Gets context via `toolboxAPI.getToolContext()`
70
+ - Listens for `TOOLBOX_CONTEXT` via `postMessage`
71
+ - Uses PPTB APIs for file operations, clipboard, and notifications
72
+
73
+ ## Installation
74
+
75
+ ```bash
76
+ npm install @dvdt-tools/erd-generator
77
+ ```
78
+
79
+ ## Development & Testing
80
+
81
+ ### Building the Project
82
+
83
+ The project uses dual build targets:
84
+
85
+ ```bash
86
+ npm run build
87
+ ```
88
+
89
+ This runs:
90
+ 1. **Extension build** (`npm run build:extension`): Compiles TypeScript for Node.js/VS Code
91
+ - Input: `src/` TypeScript files
92
+ - Output: `dist/src/` JavaScript files
93
+ - Target: Node.js runtime (VS Code extension host)
94
+
95
+ 2. **Webview build** (`npm run build:webview`): Bundles React app for browser
96
+ - Input: `webview/` React components
97
+ - Output: `dist/webview/` bundled files (index.js, index.css)
98
+ - Target: Browser runtime (Chrome-based webview)
99
+
100
+ ### Development Mode
101
+
102
+ Run with hot module replacement:
103
+
104
+ ```bash
105
+ npm run dev
106
+ ```
107
+
108
+ This starts:
109
+ - TypeScript compiler in watch mode
110
+ - Vite dev server with instant HMR
111
+
112
+ ### Preview Production Build
113
+
114
+ Preview the production build locally:
115
+
116
+ ```bash
117
+ npm run preview
118
+ ```
119
+
120
+ ## Integration Guide
121
+
122
+ ### DVDT (Dataverse DevTools) Integration
123
+
124
+ The ERD Generator provides a simple function to show the panel in VS Code:
125
+
126
+ ```typescript
127
+ import { showERDPanel } from '@dvdt-tools/erd-generator';
128
+
129
+ // In your DVDT extension code
130
+ export function activate(context: vscode.ExtensionContext) {
131
+ // When you want to show ERD Generator (e.g., from a command)
132
+ showERDPanel(
133
+ context.extensionUri,
134
+ environmentUrl, // Your Dataverse environment URL
135
+ accessToken // Your Dataverse access token
136
+ );
137
+ }
138
+ ```
139
+
140
+ **What it does:**
141
+ 1. Creates or reveals a VS Code WebView panel
142
+ 2. Loads the React app into the webview
143
+ 3. Sends credentials via `postMessage`
144
+ 4. Handles file save and clipboard operations through VS Code APIs
145
+
146
+ ### PPTB (Power Platform Toolbox) Integration
147
+
148
+ The tool automatically integrates with PPTB when deployed as a tool:
149
+
150
+ **No code required!** The React app detects PPTB environment and:
151
+ 1. Listens for `TOOLBOX_CONTEXT` via `postMessage`
152
+ 2. Calls `window.toolboxAPI.getToolContext()` to get connection details
153
+ 3. Uses `window.toolboxAPI.showNotification()` for user feedback
154
+ 4. Subscribes to toolbox events via `window.toolboxAPI.onToolboxEvent()`
155
+
156
+ **Package structure for PPTB:**
157
+ ```json
158
+ {
159
+ "name": "dvdt-erd-generator",
160
+ "version": "0.0.6",
161
+ "displayName": "Dataverse ERD Generator",
162
+ "description": "Generate Entity Relationship Diagrams for Dataverse solutions"
163
+ }
164
+ ```
165
+
166
+ The `dist/webview/` folder contains the complete tool:
167
+ - `index.html` - Entry point
168
+ - `index.js` - Bundled React app
169
+ - `index.css` - Styles
170
+
171
+ ## Usage
172
+
173
+ ### In DVDT (VS Code)
174
+
175
+ 1. Install the tool in your Dataverse DevTools extension
176
+ 2. Call `showERDPanel()` with connection details
177
+ 3. The panel opens showing available solutions
178
+ 4. Select a solution and configure options
179
+ 5. Click "Generate ERD" to create the diagram
180
+ 6. Download or copy the generated diagram
181
+
182
+ ### In PPTB (Web)
183
+
184
+ 1. Install the tool in Power Platform Toolbox
185
+ 2. Open the tool from the toolbox interface
186
+ 3. Tool automatically receives connection context
187
+ 4. Select a solution and configure options
188
+ 5. Click "Generate ERD" to create the diagram
189
+ 6. Download to your computer or copy to clipboard
190
+
191
+ ## Configuration Options
192
+
193
+ The tool provides several configuration options:
194
+
195
+ - **Output Format**: Choose between Mermaid, PlantUML, or Graphviz
196
+ - **Include Attributes**: Show/hide table columns in the diagram
197
+ - **Include Relationships**: Show/hide relationships between tables
198
+ - **Max Attributes**: Limit the number of attributes shown per table (0 = show all)
199
+
200
+ ## Output Formats
201
+
202
+ ### Mermaid
203
+ - Modern, declarative diagram syntax
204
+ - Visual preview available in the tool
205
+ - Great for documentation and GitHub
206
+
207
+ ### PlantUML
208
+ - Widely supported UML format
209
+ - Can be rendered by many tools
210
+ - Standard UML notation
211
+
212
+ ### Graphviz DOT
213
+ - Graph description language
214
+ - Powerful layout engines
215
+ - Flexible customization options
216
+
217
+ ## Architecture Details
218
+
219
+ ### No Node.js Dependencies in Webview
220
+
221
+ The webview bundle (`dist/webview/index.js`) is **pure browser JavaScript**:
222
+ - ✅ No `require()` or `module.exports`
223
+ - ✅ No `process.env` or Node.js globals
224
+ - ✅ No Node.js-specific APIs
225
+ - ✅ Uses only browser-standard APIs
226
+
227
+ This ensures:
228
+ - Works in any browser environment (PPTB)
229
+ - Works in VS Code webviews (DVDT)
230
+ - No runtime dependencies
231
+ - Smaller bundle size
232
+
233
+ ### Build Output Structure
234
+
235
+ ```
236
+ dist/
237
+ ├── src/ # Extension code (Node.js)
238
+ │ ├── index.js # Main export
239
+ │ ├── components/
240
+ │ │ └── ERDGenerator.js
241
+ │ ├── utils/
242
+ │ │ └── DataverseClient.js
243
+ │ └── dvdtIntegration/
244
+ │ └── integration.js # VS Code panel management
245
+ └── webview/ # Browser bundle (React app)
246
+ ├── index.html # Entry point
247
+ ├── index.js # Bundled React app (~195 KB)
248
+ └── index.css # Styles (~5 KB)
249
+ ```
250
+
251
+ ## Core Components
252
+
253
+ ### ERDGenerator (`src/components/ERDGenerator.ts`)
254
+ - Core logic for generating diagrams
255
+ - Supports multiple output formats
256
+ - Handles table and relationship mapping
257
+ - Shared between extension and webview builds
258
+
259
+ ### DataverseClient (`src/utils/DataverseClient.ts`)
260
+ - Dataverse API client
261
+ - Fetches solutions, tables, attributes, relationships
262
+ - Uses Axios for HTTP requests
263
+ - Shared between extension and webview builds
264
+
265
+ ### App Component (`webview/App.tsx`)
266
+ - Main React component
267
+ - Environment detection (DVDT vs PPTB)
268
+ - State management with hooks
269
+ - User interface and interactions
270
+
271
+ ## Troubleshooting
272
+
273
+ ### Build Issues
274
+
275
+ If builds fail, try:
276
+ ```bash
277
+ # Clean build artifacts
278
+ rm -rf dist node_modules
279
+ npm install
280
+ npm run build
281
+ ```
282
+
283
+ ### Webview Not Loading in VS Code
284
+
285
+ Check:
286
+ 1. Extension is built: `npm run build:extension`
287
+ 2. Webview is built: `npm run build:webview`
288
+ 3. Files exist in `dist/webview/`
289
+ 4. CSP settings in integration.ts allow loading scripts
290
+
291
+ ### PPTB Integration Issues
292
+
293
+ Check:
294
+ 1. `window.toolboxAPI` is available
295
+ 2. Console logs for TOOLBOX_CONTEXT messages
296
+ 3. Connection context is being received
297
+ 4. Network requests are successful
298
+
299
+ ## Migration from Webpack to Vite
300
+
301
+ This tool was migrated from Webpack to Vite for better performance and simpler configuration:
302
+
303
+ **Benefits:**
304
+ - ⚡ Faster development with instant HMR
305
+ - 📦 Smaller production bundles
306
+ - 🎯 Simpler configuration
307
+ - 🔧 Better TypeScript integration
308
+ - 🚀 Native ESM support
309
+
310
+ **Breaking Changes:**
311
+ - Webview bundle location changed from `dist/webview/webview.js` to `dist/webview/index.js`
312
+ - HTML is now generated (not loaded from template)
313
+ - Build output structure simplified
314
+
315
+ ## Contributing
316
+
317
+ Contributions are welcome! When contributing:
318
+
319
+ 1. Maintain dual platform support (DVDT + PPTB)
320
+ 2. Keep webview bundle browser-only (no Node.js dependencies)
321
+ 3. Test in both environments
322
+ 4. Update documentation as needed
323
+ 5. Follow existing code style
324
+
325
+ ## License
326
+
327
+ This project is licensed under the GPL-2.0 License - see the [LICENSE](../../LICENSE) file for details.
328
+
329
+ ## Support
330
+
331
+ - **Issues**: [GitHub Issues](https://github.com/Power-Maverick/DVDT-Tools/issues)
332
+ - **Discussions**: [GitHub Discussions](https://github.com/Power-Maverick/DVDT-Tools/discussions)
333
+
334
+ ## Changelog
335
+
336
+ ### v0.0.6
337
+ - 🎉 **Major Rewrite**: Converted to React-based architecture
338
+ - 🔄 Added PPTB (Power Platform Toolbox) integration support
339
+ - ⚡ Migrated from Webpack to Vite
340
+ - 🎨 Modern React components with hooks
341
+ - 🌐 Dual platform support (DVDT + PPTB)
342
+ - 📦 Cleaner build output with no Node.js artifacts in webview
343
+ - 🔧 Improved TypeScript configuration
344
+ - 📚 Updated documentation
345
+
346
+ ### Previous Versions
347
+ See [CHANGELOG.md](../../CHANGELOG.md) for full history.
348
+ - Copy to clipboard
349
+
350
+ ## Integration with Dataverse DevTools
351
+
352
+ ### VS Code WebView Panel Integration
353
+
354
+ **Simple function call - no command registration needed:**
355
+
356
+ ```typescript
357
+ import { showERDPanel } from '@dvdt-tools/erd-generator';
358
+
359
+ // Call this when you want to show the ERD panel
360
+ showERDPanel(context.extensionUri, environmentUrl, accessToken);
361
+ ```
362
+
363
+ **Complete example:**
364
+
365
+ ```typescript
366
+ import { showERDPanel } from '@dvdt-tools/erd-generator';
367
+ import * as vscode from 'vscode';
368
+
369
+ // In your DVDT menu handler or button click
370
+ async function openERDGenerator() {
371
+ try {
372
+ const environmentUrl = dvdtConfig.getCurrentEnvironment();
373
+ const accessToken = await dvdtAuth.getAccessToken();
374
+
375
+ if (!environmentUrl || !accessToken) {
376
+ vscode.window.showErrorMessage('Please connect to Dataverse first');
377
+ return;
378
+ }
379
+
380
+ // Open ERD tool panel
381
+ showERDPanel(context.extensionUri, environmentUrl, accessToken);
382
+ } catch (error) {
383
+ vscode.window.showErrorMessage(`Failed to open ERD Generator: ${error.message}`);
384
+ }
385
+ }
386
+ ```
387
+
388
+ That's it! The ERD tool will:
389
+ - Open as a panel when called
390
+ - List all solutions in a dropdown control
391
+ - Allow users to select and generate ERDs
392
+ - Handle downloading and copying
393
+ - Provide a complete UI experience with configuration options
394
+
395
+ See [../../VSCODE_INTEGRATION.md](../../VSCODE_INTEGRATION.md) for complete integration guide.
396
+
397
+ ## API
398
+
399
+ ### showERDPanel()
400
+
401
+ Opens the ERD Generator panel in VS Code.
402
+
403
+ **Parameters:**
404
+ - `extensionUri: vscode.Uri` - VS Code extension URI from context
405
+ - `environmentUrl: string` - Dataverse environment URL
406
+ - `accessToken: string` - Dataverse access token
407
+
408
+ **Example:**
409
+ ```typescript
410
+ showERDPanel(context.extensionUri, environmentUrl, accessToken);
411
+ ```
412
+
413
+ ### DataverseClient
414
+
415
+ Handles communication with Dataverse Web API.
416
+
417
+ **Constructor:**
418
+ ```typescript
419
+ new DataverseClient({
420
+ environmentUrl: string,
421
+ accessToken: string,
422
+ apiVersion?: string // Optional, defaults to '9.2'
423
+ })
424
+ ```
425
+
426
+ **Methods:**
427
+ - `listSolutions(): Promise<Solution[]>` - Lists all solutions
428
+ - `fetchSolution(uniqueName: string): Promise<DataverseSolution>` - Fetches complete solution metadata
429
+
430
+ ### ERDGenerator
431
+
432
+ Generates ERD diagrams from solution metadata.
433
+
434
+ **Constructor:**
435
+ ```typescript
436
+ new ERDGenerator({
437
+ format: 'mermaid' | 'plantuml' | 'graphviz',
438
+ includeAttributes?: boolean, // Default: true
439
+ includeRelationships?: boolean, // Default: true
440
+ maxAttributesPerTable?: number // Default: 10, 0 = all
441
+ })
442
+ ```
443
+
444
+ **Methods:**
445
+ - `generate(solution: DataverseSolution): string` - Generates ERD diagram
446
+
447
+ ## Architecture
448
+
449
+ The ERD tool is self-contained:
450
+
451
+ ```
452
+ DVDT Extension
453
+ ↓ (provides credentials)
454
+ ERD Tool WebView Panel
455
+ ↓ (uses)
456
+ DataverseClient → Dataverse Web API
457
+ ↓ (fetches metadata)
458
+ ERDGenerator → Generates diagrams
459
+ ```
460
+
461
+ ## License
462
+
463
+ GPL-2.0