@memberjunction/db-auto-doc 2.116.0 → 2.118.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 +652 -165
- package/bin/run.js +7 -0
- package/dist/api/DBAutoDocAPI.d.ts +252 -0
- package/dist/api/DBAutoDocAPI.d.ts.map +1 -0
- package/dist/api/DBAutoDocAPI.js +530 -0
- package/dist/api/DBAutoDocAPI.js.map +1 -0
- package/dist/api/index.d.ts +7 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +10 -0
- package/dist/api/index.js.map +1 -0
- package/dist/commands/analyze.d.ts +6 -4
- package/dist/commands/analyze.d.ts.map +1 -1
- package/dist/commands/analyze.js +58 -71
- package/dist/commands/analyze.js.map +1 -1
- package/dist/commands/export.d.ts +14 -4
- package/dist/commands/export.d.ts.map +1 -1
- package/dist/commands/export.js +156 -61
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/init.d.ts +3 -4
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +155 -146
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/reset.d.ts +4 -1
- package/dist/commands/reset.d.ts.map +1 -1
- package/dist/commands/reset.js +33 -19
- package/dist/commands/reset.js.map +1 -1
- package/dist/commands/status.d.ts +10 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +66 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/core/AnalysisEngine.d.ts +108 -0
- package/dist/core/AnalysisEngine.d.ts.map +1 -0
- package/dist/core/AnalysisEngine.js +716 -0
- package/dist/core/AnalysisEngine.js.map +1 -0
- package/dist/core/AnalysisOrchestrator.d.ts +37 -0
- package/dist/core/AnalysisOrchestrator.d.ts.map +1 -0
- package/dist/core/AnalysisOrchestrator.js +294 -0
- package/dist/core/AnalysisOrchestrator.js.map +1 -0
- package/dist/core/BackpropagationEngine.d.ts +32 -0
- package/dist/core/BackpropagationEngine.d.ts.map +1 -0
- package/dist/core/BackpropagationEngine.js +121 -0
- package/dist/core/BackpropagationEngine.js.map +1 -0
- package/dist/core/ConvergenceDetector.d.ts +27 -0
- package/dist/core/ConvergenceDetector.d.ts.map +1 -0
- package/dist/core/ConvergenceDetector.js +92 -0
- package/dist/core/ConvergenceDetector.js.map +1 -0
- package/dist/core/GuardrailsManager.d.ts +78 -0
- package/dist/core/GuardrailsManager.d.ts.map +1 -0
- package/dist/core/GuardrailsManager.js +367 -0
- package/dist/core/GuardrailsManager.js.map +1 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +13 -0
- package/dist/core/index.js.map +1 -0
- package/dist/database/Database.d.ts +56 -0
- package/dist/database/Database.d.ts.map +1 -0
- package/dist/database/Database.js +172 -0
- package/dist/database/Database.js.map +1 -0
- package/dist/database/TopologicalSorter.d.ts +25 -0
- package/dist/database/TopologicalSorter.d.ts.map +1 -0
- package/dist/database/TopologicalSorter.js +150 -0
- package/dist/database/TopologicalSorter.js.map +1 -0
- package/dist/database/index.d.ts +6 -0
- package/dist/database/index.d.ts.map +1 -0
- package/dist/database/index.js +14 -0
- package/dist/database/index.js.map +1 -0
- package/dist/discovery/ColumnStatsCache.d.ts +91 -0
- package/dist/discovery/ColumnStatsCache.d.ts.map +1 -0
- package/dist/discovery/ColumnStatsCache.js +231 -0
- package/dist/discovery/ColumnStatsCache.js.map +1 -0
- package/dist/discovery/DiscoveryEngine.d.ts +100 -0
- package/dist/discovery/DiscoveryEngine.d.ts.map +1 -0
- package/dist/discovery/DiscoveryEngine.js +726 -0
- package/dist/discovery/DiscoveryEngine.js.map +1 -0
- package/dist/discovery/DiscoveryTriggerAnalyzer.d.ts +57 -0
- package/dist/discovery/DiscoveryTriggerAnalyzer.d.ts.map +1 -0
- package/dist/discovery/DiscoveryTriggerAnalyzer.js +186 -0
- package/dist/discovery/DiscoveryTriggerAnalyzer.js.map +1 -0
- package/dist/discovery/FKDetector.d.ts +47 -0
- package/dist/discovery/FKDetector.d.ts.map +1 -0
- package/dist/discovery/FKDetector.js +317 -0
- package/dist/discovery/FKDetector.js.map +1 -0
- package/dist/discovery/LLMDiscoveryValidator.d.ts +64 -0
- package/dist/discovery/LLMDiscoveryValidator.d.ts.map +1 -0
- package/dist/discovery/LLMDiscoveryValidator.js +431 -0
- package/dist/discovery/LLMDiscoveryValidator.js.map +1 -0
- package/dist/discovery/LLMSanityChecker.d.ts +38 -0
- package/dist/discovery/LLMSanityChecker.d.ts.map +1 -0
- package/dist/discovery/LLMSanityChecker.js +156 -0
- package/dist/discovery/LLMSanityChecker.js.map +1 -0
- package/dist/discovery/PKDetector.d.ts +62 -0
- package/dist/discovery/PKDetector.d.ts.map +1 -0
- package/dist/discovery/PKDetector.js +436 -0
- package/dist/discovery/PKDetector.js.map +1 -0
- package/dist/discovery/index.d.ts +9 -0
- package/dist/discovery/index.d.ts.map +1 -0
- package/dist/discovery/index.js +25 -0
- package/dist/discovery/index.js.map +1 -0
- package/dist/drivers/BaseAutoDocDriver.d.ts +132 -0
- package/dist/drivers/BaseAutoDocDriver.d.ts.map +1 -0
- package/dist/drivers/BaseAutoDocDriver.js +121 -0
- package/dist/drivers/BaseAutoDocDriver.js.map +1 -0
- package/dist/drivers/MySQLDriver.d.ts +61 -0
- package/dist/drivers/MySQLDriver.d.ts.map +1 -0
- package/dist/drivers/MySQLDriver.js +668 -0
- package/dist/drivers/MySQLDriver.js.map +1 -0
- package/dist/drivers/PostgreSQLDriver.d.ts +65 -0
- package/dist/drivers/PostgreSQLDriver.d.ts.map +1 -0
- package/dist/drivers/PostgreSQLDriver.js +704 -0
- package/dist/drivers/PostgreSQLDriver.js.map +1 -0
- package/dist/drivers/SQLServerDriver.d.ts +61 -0
- package/dist/drivers/SQLServerDriver.d.ts.map +1 -0
- package/dist/drivers/SQLServerDriver.js +667 -0
- package/dist/drivers/SQLServerDriver.js.map +1 -0
- package/dist/generators/CSVGenerator.d.ts +35 -0
- package/dist/generators/CSVGenerator.d.ts.map +1 -0
- package/dist/generators/CSVGenerator.js +154 -0
- package/dist/generators/CSVGenerator.js.map +1 -0
- package/dist/generators/HTMLGenerator.d.ts +29 -0
- package/dist/generators/HTMLGenerator.d.ts.map +1 -0
- package/dist/generators/HTMLGenerator.js +710 -0
- package/dist/generators/HTMLGenerator.js.map +1 -0
- package/dist/generators/MarkdownGenerator.d.ts +27 -0
- package/dist/generators/MarkdownGenerator.d.ts.map +1 -0
- package/dist/generators/MarkdownGenerator.js +361 -0
- package/dist/generators/MarkdownGenerator.js.map +1 -0
- package/dist/generators/MermaidGenerator.d.ts +35 -0
- package/dist/generators/MermaidGenerator.d.ts.map +1 -0
- package/dist/generators/MermaidGenerator.js +321 -0
- package/dist/generators/MermaidGenerator.js.map +1 -0
- package/dist/generators/ReportGenerator.d.ts +22 -0
- package/dist/generators/ReportGenerator.d.ts.map +1 -0
- package/dist/generators/ReportGenerator.js +176 -0
- package/dist/generators/ReportGenerator.js.map +1 -0
- package/dist/generators/SQLGenerator.d.ts +31 -0
- package/dist/generators/SQLGenerator.d.ts.map +1 -0
- package/dist/generators/SQLGenerator.js +168 -0
- package/dist/generators/SQLGenerator.js.map +1 -0
- package/dist/generators/index.d.ts +10 -0
- package/dist/generators/index.d.ts.map +1 -0
- package/dist/generators/index.js +19 -0
- package/dist/generators/index.js.map +1 -0
- package/dist/index.d.ts +11 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -20
- package/dist/index.js.map +1 -1
- package/dist/prompts/PromptEngine.d.ts +65 -0
- package/dist/prompts/PromptEngine.d.ts.map +1 -0
- package/dist/prompts/PromptEngine.js +282 -0
- package/dist/prompts/PromptEngine.js.map +1 -0
- package/dist/prompts/PromptFileLoader.d.ts +21 -0
- package/dist/prompts/PromptFileLoader.d.ts.map +1 -0
- package/dist/prompts/PromptFileLoader.js +74 -0
- package/dist/prompts/PromptFileLoader.js.map +1 -0
- package/dist/prompts/index.d.ts +6 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +11 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/state/IterationTracker.d.ts +64 -0
- package/dist/state/IterationTracker.d.ts.map +1 -0
- package/dist/state/IterationTracker.js +136 -0
- package/dist/state/IterationTracker.js.map +1 -0
- package/dist/state/StateManager.d.ts +79 -0
- package/dist/state/StateManager.d.ts.map +1 -0
- package/dist/state/StateManager.js +348 -0
- package/dist/state/StateManager.js.map +1 -0
- package/dist/state/StateValidator.d.ts +24 -0
- package/dist/state/StateValidator.d.ts.map +1 -0
- package/dist/state/StateValidator.js +147 -0
- package/dist/state/StateValidator.js.map +1 -0
- package/dist/state/index.d.ts +7 -0
- package/dist/state/index.d.ts.map +1 -0
- package/dist/state/index.js +13 -0
- package/dist/state/index.js.map +1 -0
- package/dist/types/analysis.d.ts +76 -0
- package/dist/types/analysis.d.ts.map +1 -0
- package/dist/types/analysis.js +6 -0
- package/dist/types/analysis.js.map +1 -0
- package/dist/types/config.d.ts +132 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +7 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/discovery.d.ts +277 -0
- package/dist/types/discovery.d.ts.map +1 -0
- package/dist/types/discovery.js +7 -0
- package/dist/types/discovery.js.map +1 -0
- package/dist/types/driver.d.ts +148 -0
- package/dist/types/driver.d.ts.map +1 -0
- package/dist/types/driver.js +7 -0
- package/dist/types/driver.js.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +24 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/prompts.d.ts +158 -0
- package/dist/types/prompts.d.ts.map +1 -0
- package/dist/types/prompts.js +6 -0
- package/dist/types/prompts.js.map +1 -0
- package/dist/types/state.d.ts +278 -0
- package/dist/types/state.d.ts.map +1 -0
- package/dist/types/state.js +7 -0
- package/dist/types/state.js.map +1 -0
- package/dist/utils/config-loader.d.ts +29 -0
- package/dist/utils/config-loader.d.ts.map +1 -0
- package/dist/utils/config-loader.js +163 -0
- package/dist/utils/config-loader.js.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +9 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +24 -3
- package/dist/ai/simple-ai-client.d.ts +0 -70
- package/dist/ai/simple-ai-client.d.ts.map +0 -1
- package/dist/ai/simple-ai-client.js +0 -181
- package/dist/ai/simple-ai-client.js.map +0 -1
- package/dist/analyzers/analyzer.d.ts +0 -23
- package/dist/analyzers/analyzer.d.ts.map +0 -1
- package/dist/analyzers/analyzer.js +0 -127
- package/dist/analyzers/analyzer.js.map +0 -1
- package/dist/cli-old/cli.d.ts +0 -3
- package/dist/cli-old/cli.d.ts.map +0 -1
- package/dist/cli-old/cli.js +0 -388
- package/dist/cli-old/cli.js.map +0 -1
- package/dist/commands/review.d.ts +0 -11
- package/dist/commands/review.d.ts.map +0 -1
- package/dist/commands/review.js +0 -82
- package/dist/commands/review.js.map +0 -1
- package/dist/database/connection.d.ts +0 -40
- package/dist/database/connection.d.ts.map +0 -1
- package/dist/database/connection.js +0 -136
- package/dist/database/connection.js.map +0 -1
- package/dist/database/introspection.d.ts +0 -59
- package/dist/database/introspection.d.ts.map +0 -1
- package/dist/database/introspection.js +0 -124
- package/dist/database/introspection.js.map +0 -1
- package/dist/generators/markdown-generator.d.ts +0 -8
- package/dist/generators/markdown-generator.d.ts.map +0 -1
- package/dist/generators/markdown-generator.js +0 -106
- package/dist/generators/markdown-generator.js.map +0 -1
- package/dist/generators/sql-generator.d.ts +0 -20
- package/dist/generators/sql-generator.d.ts.map +0 -1
- package/dist/generators/sql-generator.js +0 -83
- package/dist/generators/sql-generator.js.map +0 -1
- package/dist/state/state-manager.d.ts +0 -95
- package/dist/state/state-manager.d.ts.map +0 -1
- package/dist/state/state-manager.js +0 -236
- package/dist/state/state-manager.js.map +0 -1
- package/dist/types/state-file.d.ts +0 -124
- package/dist/types/state-file.d.ts.map +0 -1
- package/dist/types/state-file.js +0 -79
- package/dist/types/state-file.js.map +0 -1
|
@@ -0,0 +1,710 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Generates interactive HTML documentation with Mermaid ERD
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.HTMLGenerator = void 0;
|
|
7
|
+
class HTMLGenerator {
|
|
8
|
+
/**
|
|
9
|
+
* Generate interactive HTML documentation
|
|
10
|
+
*/
|
|
11
|
+
generate(state, options = {}) {
|
|
12
|
+
const htmlLines = [];
|
|
13
|
+
// HTML header
|
|
14
|
+
this.appendHtmlHeader(htmlLines, state);
|
|
15
|
+
// Body content
|
|
16
|
+
htmlLines.push('<body>');
|
|
17
|
+
htmlLines.push('<div class="container">');
|
|
18
|
+
// Header section
|
|
19
|
+
this.appendHeaderSection(htmlLines, state);
|
|
20
|
+
// Sidebar with navigation
|
|
21
|
+
htmlLines.push('<div class="main-wrapper">');
|
|
22
|
+
this.appendSidebar(htmlLines, state);
|
|
23
|
+
// Main content
|
|
24
|
+
htmlLines.push('<div class="main-content">');
|
|
25
|
+
// Analysis summary
|
|
26
|
+
this.appendAnalysisSummary(htmlLines, state);
|
|
27
|
+
// Database context
|
|
28
|
+
this.appendDatabaseContext(htmlLines, state);
|
|
29
|
+
// Searchable table/column list
|
|
30
|
+
this.appendSearchableList(htmlLines, state, options);
|
|
31
|
+
// Schemas with ERD and tables
|
|
32
|
+
this.appendSchemas(htmlLines, state, options);
|
|
33
|
+
htmlLines.push('</div>'); // main-content
|
|
34
|
+
htmlLines.push('</div>'); // main-wrapper
|
|
35
|
+
htmlLines.push('</div>'); // container
|
|
36
|
+
htmlLines.push('</body>');
|
|
37
|
+
htmlLines.push('</html>');
|
|
38
|
+
return htmlLines.join('\n');
|
|
39
|
+
}
|
|
40
|
+
appendHtmlHeader(lines, state) {
|
|
41
|
+
lines.push('<!DOCTYPE html>');
|
|
42
|
+
lines.push('<html lang="en">');
|
|
43
|
+
lines.push('<head>');
|
|
44
|
+
lines.push('<meta charset="UTF-8">');
|
|
45
|
+
lines.push('<meta name="viewport" content="width=device-width, initial-scale=1.0">');
|
|
46
|
+
lines.push(`<title>Database Documentation - ${state.database.name}</title>`);
|
|
47
|
+
this.appendStyles(lines);
|
|
48
|
+
lines.push('</head>');
|
|
49
|
+
}
|
|
50
|
+
appendStyles(lines) {
|
|
51
|
+
lines.push('<style>');
|
|
52
|
+
lines.push(`
|
|
53
|
+
* {
|
|
54
|
+
margin: 0;
|
|
55
|
+
padding: 0;
|
|
56
|
+
box-sizing: border-box;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
body {
|
|
60
|
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
61
|
+
background-color: #f5f7fa;
|
|
62
|
+
color: #333;
|
|
63
|
+
line-height: 1.6;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.container {
|
|
67
|
+
width: 100%;
|
|
68
|
+
min-height: 100vh;
|
|
69
|
+
display: flex;
|
|
70
|
+
flex-direction: column;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
header {
|
|
74
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
75
|
+
color: white;
|
|
76
|
+
padding: 2rem;
|
|
77
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
header h1 {
|
|
81
|
+
font-size: 2.5rem;
|
|
82
|
+
margin-bottom: 0.5rem;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
header .subtitle {
|
|
86
|
+
font-size: 1.1rem;
|
|
87
|
+
opacity: 0.95;
|
|
88
|
+
margin-bottom: 1rem;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
header .meta {
|
|
92
|
+
display: flex;
|
|
93
|
+
gap: 2rem;
|
|
94
|
+
font-size: 0.95rem;
|
|
95
|
+
opacity: 0.9;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.main-wrapper {
|
|
99
|
+
display: flex;
|
|
100
|
+
flex: 1;
|
|
101
|
+
gap: 0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.sidebar {
|
|
105
|
+
width: 280px;
|
|
106
|
+
background-color: #fff;
|
|
107
|
+
border-right: 1px solid #e0e0e0;
|
|
108
|
+
overflow-y: auto;
|
|
109
|
+
padding: 1.5rem 0;
|
|
110
|
+
position: sticky;
|
|
111
|
+
top: 0;
|
|
112
|
+
max-height: calc(100vh - 200px);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.sidebar h3 {
|
|
116
|
+
padding: 0.5rem 1.5rem;
|
|
117
|
+
color: #667eea;
|
|
118
|
+
font-size: 0.95rem;
|
|
119
|
+
text-transform: uppercase;
|
|
120
|
+
margin-top: 1.5rem;
|
|
121
|
+
margin-bottom: 0.5rem;
|
|
122
|
+
letter-spacing: 0.5px;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.sidebar a {
|
|
126
|
+
display: block;
|
|
127
|
+
padding: 0.6rem 1.5rem;
|
|
128
|
+
color: #555;
|
|
129
|
+
text-decoration: none;
|
|
130
|
+
border-left: 3px solid transparent;
|
|
131
|
+
transition: all 0.2s;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.sidebar a:hover {
|
|
135
|
+
background-color: #f5f5f5;
|
|
136
|
+
color: #667eea;
|
|
137
|
+
border-left-color: #667eea;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.main-content {
|
|
141
|
+
flex: 1;
|
|
142
|
+
padding: 2rem;
|
|
143
|
+
overflow-y: auto;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
section {
|
|
147
|
+
background: white;
|
|
148
|
+
border-radius: 8px;
|
|
149
|
+
padding: 2rem;
|
|
150
|
+
margin-bottom: 2rem;
|
|
151
|
+
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
h2 {
|
|
155
|
+
color: #667eea;
|
|
156
|
+
font-size: 1.8rem;
|
|
157
|
+
margin-bottom: 1rem;
|
|
158
|
+
border-bottom: 2px solid #e0e0e0;
|
|
159
|
+
padding-bottom: 0.5rem;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
h3 {
|
|
163
|
+
color: #764ba2;
|
|
164
|
+
font-size: 1.3rem;
|
|
165
|
+
margin-top: 1.5rem;
|
|
166
|
+
margin-bottom: 0.8rem;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
h4 {
|
|
170
|
+
color: #555;
|
|
171
|
+
font-size: 1.1rem;
|
|
172
|
+
margin-top: 1rem;
|
|
173
|
+
margin-bottom: 0.5rem;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.summary-grid {
|
|
177
|
+
display: grid;
|
|
178
|
+
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
179
|
+
gap: 1rem;
|
|
180
|
+
margin-bottom: 1rem;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.summary-card {
|
|
184
|
+
background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
|
|
185
|
+
padding: 1rem;
|
|
186
|
+
border-radius: 6px;
|
|
187
|
+
border-left: 4px solid #667eea;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.summary-card strong {
|
|
191
|
+
display: block;
|
|
192
|
+
color: #667eea;
|
|
193
|
+
font-size: 0.9rem;
|
|
194
|
+
text-transform: uppercase;
|
|
195
|
+
margin-bottom: 0.3rem;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.summary-card .value {
|
|
199
|
+
font-size: 1.6rem;
|
|
200
|
+
font-weight: bold;
|
|
201
|
+
color: #333;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.search-box {
|
|
205
|
+
margin-bottom: 2rem;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.search-box input {
|
|
209
|
+
width: 100%;
|
|
210
|
+
padding: 0.8rem;
|
|
211
|
+
border: 2px solid #e0e0e0;
|
|
212
|
+
border-radius: 6px;
|
|
213
|
+
font-size: 1rem;
|
|
214
|
+
transition: border-color 0.2s;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.search-box input:focus {
|
|
218
|
+
outline: none;
|
|
219
|
+
border-color: #667eea;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.search-results {
|
|
223
|
+
display: grid;
|
|
224
|
+
gap: 0.5rem;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.search-result {
|
|
228
|
+
padding: 0.8rem;
|
|
229
|
+
background-color: #f9f9f9;
|
|
230
|
+
border-radius: 4px;
|
|
231
|
+
border-left: 3px solid #667eea;
|
|
232
|
+
cursor: pointer;
|
|
233
|
+
transition: all 0.2s;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.search-result:hover {
|
|
237
|
+
background-color: #f0f0f0;
|
|
238
|
+
transform: translateX(4px);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.search-result .table-name {
|
|
242
|
+
font-weight: bold;
|
|
243
|
+
color: #667eea;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.search-result .column-name {
|
|
247
|
+
color: #666;
|
|
248
|
+
font-size: 0.9rem;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
table {
|
|
252
|
+
width: 100%;
|
|
253
|
+
border-collapse: collapse;
|
|
254
|
+
margin-top: 1rem;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
table th {
|
|
258
|
+
background-color: #f5f5f5;
|
|
259
|
+
padding: 0.8rem;
|
|
260
|
+
text-align: left;
|
|
261
|
+
font-weight: 600;
|
|
262
|
+
color: #667eea;
|
|
263
|
+
border-bottom: 2px solid #e0e0e0;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
table td {
|
|
267
|
+
padding: 0.8rem;
|
|
268
|
+
border-bottom: 1px solid #e0e0e0;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
table tr:hover {
|
|
272
|
+
background-color: #f9f9f9;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.confidence-indicator {
|
|
276
|
+
display: inline-block;
|
|
277
|
+
padding: 0.3rem 0.8rem;
|
|
278
|
+
border-radius: 20px;
|
|
279
|
+
font-size: 0.85rem;
|
|
280
|
+
font-weight: 600;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.confidence-high {
|
|
284
|
+
background-color: #d4edda;
|
|
285
|
+
color: #155724;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.confidence-medium {
|
|
289
|
+
background-color: #fff3cd;
|
|
290
|
+
color: #856404;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.confidence-low {
|
|
294
|
+
background-color: #f8d7da;
|
|
295
|
+
color: #721c24;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.schema-section {
|
|
299
|
+
background: white;
|
|
300
|
+
border-radius: 8px;
|
|
301
|
+
padding: 2rem;
|
|
302
|
+
margin-bottom: 2rem;
|
|
303
|
+
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.schema-title {
|
|
307
|
+
color: #667eea;
|
|
308
|
+
font-size: 1.6rem;
|
|
309
|
+
margin-bottom: 1rem;
|
|
310
|
+
padding-bottom: 0.5rem;
|
|
311
|
+
border-bottom: 2px solid #e0e0e0;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
.mermaid {
|
|
315
|
+
background-color: #f9f9f9;
|
|
316
|
+
border: 1px solid #e0e0e0;
|
|
317
|
+
border-radius: 6px;
|
|
318
|
+
padding: 1rem;
|
|
319
|
+
margin: 1rem 0;
|
|
320
|
+
display: flex;
|
|
321
|
+
justify-content: center;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
.mermaid svg {
|
|
325
|
+
max-width: 100%;
|
|
326
|
+
height: auto;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.relationship-info {
|
|
330
|
+
margin-top: 1rem;
|
|
331
|
+
padding: 1rem;
|
|
332
|
+
background-color: #f5f5f5;
|
|
333
|
+
border-radius: 4px;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
.relationship-info strong {
|
|
337
|
+
color: #667eea;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.tag {
|
|
341
|
+
display: inline-block;
|
|
342
|
+
padding: 0.25rem 0.6rem;
|
|
343
|
+
margin-right: 0.5rem;
|
|
344
|
+
background-color: #e0e0e0;
|
|
345
|
+
color: #333;
|
|
346
|
+
border-radius: 3px;
|
|
347
|
+
font-size: 0.85rem;
|
|
348
|
+
font-weight: 600;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
.tag.pk {
|
|
352
|
+
background-color: #667eea;
|
|
353
|
+
color: white;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
.tag.fk {
|
|
357
|
+
background-color: #764ba2;
|
|
358
|
+
color: white;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
.tag.notnull {
|
|
362
|
+
background-color: #ff6b6b;
|
|
363
|
+
color: white;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
.no-results {
|
|
367
|
+
text-align: center;
|
|
368
|
+
color: #999;
|
|
369
|
+
padding: 2rem;
|
|
370
|
+
font-style: italic;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
@media (max-width: 1024px) {
|
|
374
|
+
.main-wrapper {
|
|
375
|
+
flex-direction: column;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
.sidebar {
|
|
379
|
+
width: 100%;
|
|
380
|
+
max-height: auto;
|
|
381
|
+
border-right: none;
|
|
382
|
+
border-bottom: 1px solid #e0e0e0;
|
|
383
|
+
padding: 1rem 0;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
.sidebar h3 {
|
|
387
|
+
display: inline-block;
|
|
388
|
+
margin-right: 1rem;
|
|
389
|
+
margin-top: 0;
|
|
390
|
+
margin-bottom: 0;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
.sidebar a {
|
|
394
|
+
display: inline-block;
|
|
395
|
+
margin-right: 1rem;
|
|
396
|
+
border-left: none;
|
|
397
|
+
border-bottom: 2px solid transparent;
|
|
398
|
+
padding: 0.5rem 0;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
.sidebar a:hover {
|
|
402
|
+
border-left: none;
|
|
403
|
+
border-bottom-color: #667eea;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
`);
|
|
407
|
+
lines.push('</style>');
|
|
408
|
+
}
|
|
409
|
+
appendHeaderSection(lines, state) {
|
|
410
|
+
lines.push('<header>');
|
|
411
|
+
lines.push(`<h1>📊 ${this.escapeHtml(state.database.name)}</h1>`);
|
|
412
|
+
lines.push(`<div class="subtitle">Database Documentation</div>`);
|
|
413
|
+
lines.push('<div class="meta">');
|
|
414
|
+
lines.push(`<span><strong>Server:</strong> ${this.escapeHtml(state.database.server)}</span>`);
|
|
415
|
+
lines.push(`<span><strong>Generated:</strong> ${new Date().toLocaleDateString()}</span>`);
|
|
416
|
+
lines.push('</div>');
|
|
417
|
+
lines.push('</header>');
|
|
418
|
+
}
|
|
419
|
+
appendSidebar(lines, state) {
|
|
420
|
+
lines.push('<aside class="sidebar">');
|
|
421
|
+
lines.push('<h3>📑 Schemas</h3>');
|
|
422
|
+
for (const schema of state.schemas) {
|
|
423
|
+
lines.push(`<a href="#schema-${this.toAnchor(schema.name)}">${this.escapeHtml(schema.name)}</a>`);
|
|
424
|
+
}
|
|
425
|
+
lines.push('</aside>');
|
|
426
|
+
}
|
|
427
|
+
appendAnalysisSummary(lines, state) {
|
|
428
|
+
lines.push('<section id="summary">');
|
|
429
|
+
lines.push('<h2>📈 Analysis Summary</h2>');
|
|
430
|
+
const summary = state.summary;
|
|
431
|
+
lines.push('<div class="summary-grid">');
|
|
432
|
+
lines.push(`<div class="summary-card">
|
|
433
|
+
<strong>Total Schemas</strong>
|
|
434
|
+
<div class="value">${summary.totalSchemas}</div>
|
|
435
|
+
</div>`);
|
|
436
|
+
lines.push(`<div class="summary-card">
|
|
437
|
+
<strong>Total Tables</strong>
|
|
438
|
+
<div class="value">${summary.totalTables}</div>
|
|
439
|
+
</div>`);
|
|
440
|
+
lines.push(`<div class="summary-card">
|
|
441
|
+
<strong>Total Columns</strong>
|
|
442
|
+
<div class="value">${summary.totalColumns}</div>
|
|
443
|
+
</div>`);
|
|
444
|
+
lines.push(`<div class="summary-card">
|
|
445
|
+
<strong>Total Iterations</strong>
|
|
446
|
+
<div class="value">${summary.totalIterations}</div>
|
|
447
|
+
</div>`);
|
|
448
|
+
lines.push(`<div class="summary-card">
|
|
449
|
+
<strong>Tokens Used</strong>
|
|
450
|
+
<div class="value">${summary.totalTokens.toLocaleString()}</div>
|
|
451
|
+
</div>`);
|
|
452
|
+
lines.push(`<div class="summary-card">
|
|
453
|
+
<strong>Estimated Cost</strong>
|
|
454
|
+
<div class="value">$${summary.estimatedCost.toFixed(2)}</div>
|
|
455
|
+
</div>`);
|
|
456
|
+
lines.push('</div>');
|
|
457
|
+
if (state.phases.descriptionGeneration.length > 0) {
|
|
458
|
+
const lastRun = state.phases.descriptionGeneration[state.phases.descriptionGeneration.length - 1];
|
|
459
|
+
lines.push('<h3>Latest Analysis Run</h3>');
|
|
460
|
+
lines.push(`<p><strong>Status:</strong> ${this.escapeHtml(lastRun.status)}</p>`);
|
|
461
|
+
lines.push(`<p><strong>Model:</strong> ${this.escapeHtml(lastRun.modelUsed)} (${this.escapeHtml(lastRun.vendor)})</p>`);
|
|
462
|
+
lines.push(`<p><strong>Temperature:</strong> ${lastRun.temperature}</p>`);
|
|
463
|
+
}
|
|
464
|
+
lines.push('</section>');
|
|
465
|
+
}
|
|
466
|
+
appendDatabaseContext(lines, state) {
|
|
467
|
+
if (!state.seedContext) {
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
lines.push('<section id="context">');
|
|
471
|
+
lines.push('<h2>💡 Database Context</h2>');
|
|
472
|
+
if (state.seedContext.overallPurpose) {
|
|
473
|
+
lines.push(`<p><strong>Purpose:</strong> ${this.escapeHtml(state.seedContext.overallPurpose)}</p>`);
|
|
474
|
+
}
|
|
475
|
+
if (state.seedContext.industryContext) {
|
|
476
|
+
lines.push(`<p><strong>Industry:</strong> ${this.escapeHtml(state.seedContext.industryContext)}</p>`);
|
|
477
|
+
}
|
|
478
|
+
if (state.seedContext.businessDomains && state.seedContext.businessDomains.length > 0) {
|
|
479
|
+
lines.push('<p><strong>Business Domains:</strong> ');
|
|
480
|
+
const domains = state.seedContext.businessDomains.map(d => this.escapeHtml(d)).join(', ');
|
|
481
|
+
lines.push(domains + '</p>');
|
|
482
|
+
}
|
|
483
|
+
lines.push('</section>');
|
|
484
|
+
}
|
|
485
|
+
appendSearchableList(lines, state, options) {
|
|
486
|
+
lines.push('<section id="search">');
|
|
487
|
+
lines.push('<h2>🔍 Search Tables & Columns</h2>');
|
|
488
|
+
lines.push('<div class="search-box">');
|
|
489
|
+
lines.push('<input type="text" id="search-input" placeholder="Search for tables or columns...">');
|
|
490
|
+
lines.push('</div>');
|
|
491
|
+
lines.push('<div id="search-results" class="search-results"></div>');
|
|
492
|
+
lines.push('</section>');
|
|
493
|
+
// Generate search data
|
|
494
|
+
lines.push('<script>');
|
|
495
|
+
lines.push('const searchData = [');
|
|
496
|
+
for (const schema of state.schemas) {
|
|
497
|
+
for (const table of schema.tables) {
|
|
498
|
+
// Check filters
|
|
499
|
+
if (options.approvedOnly && !table.userApproved) {
|
|
500
|
+
continue;
|
|
501
|
+
}
|
|
502
|
+
lines.push(` {`);
|
|
503
|
+
lines.push(` type: 'table',`);
|
|
504
|
+
lines.push(` schema: '${this.escapeJson(schema.name)}',`);
|
|
505
|
+
lines.push(` name: '${this.escapeJson(table.name)}',`);
|
|
506
|
+
lines.push(` description: '${this.escapeJson(table.description || '')}',`);
|
|
507
|
+
lines.push(` anchor: 'table-${this.toAnchor(table.name)}'`);
|
|
508
|
+
lines.push(` },`);
|
|
509
|
+
// Add columns
|
|
510
|
+
for (const column of table.columns) {
|
|
511
|
+
lines.push(` {`);
|
|
512
|
+
lines.push(` type: 'column',`);
|
|
513
|
+
lines.push(` schema: '${this.escapeJson(schema.name)}',`);
|
|
514
|
+
lines.push(` table: '${this.escapeJson(table.name)}',`);
|
|
515
|
+
lines.push(` name: '${this.escapeJson(column.name)}',`);
|
|
516
|
+
lines.push(` dataType: '${this.escapeJson(column.dataType)}',`);
|
|
517
|
+
lines.push(` description: '${this.escapeJson(column.description || '')}',`);
|
|
518
|
+
lines.push(` anchor: 'table-${this.toAnchor(table.name)}'`);
|
|
519
|
+
lines.push(` },`);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
lines.push('];');
|
|
524
|
+
this.appendSearchScript(lines);
|
|
525
|
+
lines.push('</script>');
|
|
526
|
+
}
|
|
527
|
+
appendSearchScript(lines) {
|
|
528
|
+
lines.push(`
|
|
529
|
+
const searchInput = document.getElementById('search-input');
|
|
530
|
+
const searchResults = document.getElementById('search-results');
|
|
531
|
+
|
|
532
|
+
searchInput.addEventListener('input', (e) => {
|
|
533
|
+
const query = e.target.value.toLowerCase().trim();
|
|
534
|
+
|
|
535
|
+
if (!query) {
|
|
536
|
+
searchResults.innerHTML = '';
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
const results = searchData.filter(item =>
|
|
541
|
+
item.name.toLowerCase().includes(query) ||
|
|
542
|
+
item.description.toLowerCase().includes(query)
|
|
543
|
+
).slice(0, 50);
|
|
544
|
+
|
|
545
|
+
if (results.length === 0) {
|
|
546
|
+
searchResults.innerHTML = '<div class="no-results">No results found</div>';
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
searchResults.innerHTML = results.map(item => {
|
|
551
|
+
if (item.type === 'table') {
|
|
552
|
+
return \`<div class="search-result" onclick="document.getElementById('\${item.anchor}').scrollIntoView({behavior: 'smooth'})">
|
|
553
|
+
<div class="table-name">\${item.schema}.\${item.name}</div>
|
|
554
|
+
<div class="column-name">\${item.description || 'No description'}</div>
|
|
555
|
+
</div>\`;
|
|
556
|
+
} else {
|
|
557
|
+
return \`<div class="search-result" onclick="document.getElementById('\${item.anchor}').scrollIntoView({behavior: 'smooth'})">
|
|
558
|
+
<div class="table-name">\${item.table}.\${item.name}</div>
|
|
559
|
+
<div class="column-name">\${item.dataType} - \${item.description || 'No description'}</div>
|
|
560
|
+
</div>\`;
|
|
561
|
+
}
|
|
562
|
+
}).join('');
|
|
563
|
+
});
|
|
564
|
+
`);
|
|
565
|
+
}
|
|
566
|
+
appendSchemas(lines, state, options) {
|
|
567
|
+
for (const schema of state.schemas) {
|
|
568
|
+
lines.push(`<div class="schema-section" id="schema-${this.toAnchor(schema.name)}">`);
|
|
569
|
+
lines.push(`<div class="schema-title">${this.escapeHtml(schema.name)}</div>`);
|
|
570
|
+
if (schema.description) {
|
|
571
|
+
lines.push(`<p>${this.escapeHtml(schema.description)}</p>`);
|
|
572
|
+
}
|
|
573
|
+
if (schema.inferredPurpose) {
|
|
574
|
+
lines.push(`<p><strong>Purpose:</strong> ${this.escapeHtml(schema.inferredPurpose)}</p>`);
|
|
575
|
+
}
|
|
576
|
+
if (schema.businessDomains && schema.businessDomains.length > 0) {
|
|
577
|
+
lines.push(`<p><strong>Business Domains:</strong> ${schema.businessDomains.map(d => this.escapeHtml(d)).join(', ')}</p>`);
|
|
578
|
+
}
|
|
579
|
+
// Entity Relationship Diagram
|
|
580
|
+
lines.push('<h3>Entity Relationship Diagram</h3>');
|
|
581
|
+
lines.push('<div class="mermaid">');
|
|
582
|
+
lines.push(this.generateMermaidERD(schema));
|
|
583
|
+
lines.push('</div>');
|
|
584
|
+
// Tables
|
|
585
|
+
lines.push('<h3>Tables</h3>');
|
|
586
|
+
for (const table of schema.tables) {
|
|
587
|
+
// Check filters
|
|
588
|
+
if (options.approvedOnly && !table.userApproved) {
|
|
589
|
+
continue;
|
|
590
|
+
}
|
|
591
|
+
lines.push(`<div id="table-${this.toAnchor(table.name)}">`);
|
|
592
|
+
lines.push(`<h4>${this.escapeHtml(table.name)}</h4>`);
|
|
593
|
+
if (table.description) {
|
|
594
|
+
lines.push(`<p>${this.escapeHtml(table.description)}</p>`);
|
|
595
|
+
}
|
|
596
|
+
// Metadata
|
|
597
|
+
lines.push(`<p><strong>Row Count:</strong> ${table.rowCount.toLocaleString()}</p>`);
|
|
598
|
+
if (table.dependencyLevel !== undefined) {
|
|
599
|
+
lines.push(`<p><strong>Dependency Level:</strong> ${table.dependencyLevel}</p>`);
|
|
600
|
+
}
|
|
601
|
+
// Confidence
|
|
602
|
+
if (table.descriptionIterations.length > 0) {
|
|
603
|
+
const latest = table.descriptionIterations[table.descriptionIterations.length - 1];
|
|
604
|
+
if (latest.confidence) {
|
|
605
|
+
const confidence = latest.confidence * 100;
|
|
606
|
+
const confClass = confidence >= 80 ? 'confidence-high' : confidence >= 60 ? 'confidence-medium' : 'confidence-low';
|
|
607
|
+
lines.push(`<p><span class="confidence-indicator ${confClass}">Confidence: ${confidence.toFixed(0)}%</span></p>`);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
// Relationships
|
|
611
|
+
if ((table.dependsOn && table.dependsOn.length > 0) || (table.dependents && table.dependents.length > 0)) {
|
|
612
|
+
lines.push('<div class="relationship-info">');
|
|
613
|
+
if (table.dependsOn && table.dependsOn.length > 0) {
|
|
614
|
+
lines.push('<strong>Depends On:</strong>');
|
|
615
|
+
lines.push('<ul>');
|
|
616
|
+
for (const dep of table.dependsOn) {
|
|
617
|
+
lines.push(`<li><a href="#table-${this.toAnchor(dep.table)}">${dep.schema}.${dep.table}</a> (via ${dep.column})</li>`);
|
|
618
|
+
}
|
|
619
|
+
lines.push('</ul>');
|
|
620
|
+
}
|
|
621
|
+
if (table.dependents && table.dependents.length > 0) {
|
|
622
|
+
lines.push('<strong>Referenced By:</strong>');
|
|
623
|
+
lines.push('<ul>');
|
|
624
|
+
for (const dep of table.dependents) {
|
|
625
|
+
lines.push(`<li><a href="#table-${this.toAnchor(dep.table)}">${dep.schema}.${dep.table}</a></li>`);
|
|
626
|
+
}
|
|
627
|
+
lines.push('</ul>');
|
|
628
|
+
}
|
|
629
|
+
lines.push('</div>');
|
|
630
|
+
}
|
|
631
|
+
// Columns table
|
|
632
|
+
lines.push('<table>');
|
|
633
|
+
lines.push('<thead><tr><th>Column</th><th>Type</th><th>Description</th></tr></thead>');
|
|
634
|
+
lines.push('<tbody>');
|
|
635
|
+
for (const column of table.columns) {
|
|
636
|
+
const flags = [];
|
|
637
|
+
if (column.isPrimaryKey)
|
|
638
|
+
flags.push('<span class="tag pk">PK</span>');
|
|
639
|
+
if (column.isForeignKey)
|
|
640
|
+
flags.push('<span class="tag fk">FK</span>');
|
|
641
|
+
if (!column.isNullable)
|
|
642
|
+
flags.push('<span class="tag notnull">NOT NULL</span>');
|
|
643
|
+
const typeInfo = flags.length > 0 ? `${column.dataType} ${flags.join(' ')}` : column.dataType;
|
|
644
|
+
const description = column.description || '';
|
|
645
|
+
lines.push(`<tr>`);
|
|
646
|
+
lines.push(`<td>${this.escapeHtml(column.name)}</td>`);
|
|
647
|
+
lines.push(`<td>${typeInfo}</td>`);
|
|
648
|
+
lines.push(`<td>${this.escapeHtml(description)}</td>`);
|
|
649
|
+
lines.push(`</tr>`);
|
|
650
|
+
}
|
|
651
|
+
lines.push('</tbody>');
|
|
652
|
+
lines.push('</table>');
|
|
653
|
+
lines.push('</div>');
|
|
654
|
+
}
|
|
655
|
+
lines.push('</div>');
|
|
656
|
+
}
|
|
657
|
+
// Add Mermaid script
|
|
658
|
+
lines.push('<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"><\/script>');
|
|
659
|
+
lines.push('<script>mermaid.initialize({ startOnLoad: true, theme: "default" }); mermaid.contentLoaded();<\/script>');
|
|
660
|
+
}
|
|
661
|
+
generateMermaidERD(schema) {
|
|
662
|
+
const lines = [];
|
|
663
|
+
lines.push('erDiagram');
|
|
664
|
+
// Add entities with their columns
|
|
665
|
+
for (const table of schema.tables) {
|
|
666
|
+
lines.push(` ${table.name} {`);
|
|
667
|
+
for (const column of table.columns) {
|
|
668
|
+
const type = column.dataType.replace(/\s+/g, '_');
|
|
669
|
+
const constraints = [];
|
|
670
|
+
if (column.isPrimaryKey)
|
|
671
|
+
constraints.push('PK');
|
|
672
|
+
if (column.isForeignKey)
|
|
673
|
+
constraints.push('FK');
|
|
674
|
+
if (!column.isNullable)
|
|
675
|
+
constraints.push('NOT_NULL');
|
|
676
|
+
const constraintStr = constraints.length > 0 ? ` "${constraints.join(',')}"` : '';
|
|
677
|
+
lines.push(` ${type} ${column.name}${constraintStr}`);
|
|
678
|
+
}
|
|
679
|
+
lines.push(' }');
|
|
680
|
+
}
|
|
681
|
+
lines.push('');
|
|
682
|
+
// Add relationships
|
|
683
|
+
for (const table of schema.tables) {
|
|
684
|
+
if (table.dependsOn && table.dependsOn.length > 0) {
|
|
685
|
+
for (const dep of table.dependsOn) {
|
|
686
|
+
lines.push(` ${dep.table} ||--o{ ${table.name} : "has"`);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
return lines.join('\n');
|
|
691
|
+
}
|
|
692
|
+
toAnchor(text) {
|
|
693
|
+
return text.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
|
|
694
|
+
}
|
|
695
|
+
escapeHtml(text) {
|
|
696
|
+
const map = {
|
|
697
|
+
'&': '&',
|
|
698
|
+
'<': '<',
|
|
699
|
+
'>': '>',
|
|
700
|
+
'"': '"',
|
|
701
|
+
"'": '''
|
|
702
|
+
};
|
|
703
|
+
return text.replace(/[&<>"']/g, (char) => map[char]);
|
|
704
|
+
}
|
|
705
|
+
escapeJson(text) {
|
|
706
|
+
return text.replace(/\\/g, '\\\\').replace(/'/g, "\\'").replace(/\n/g, '\\n').replace(/\r/g, '\\r');
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
exports.HTMLGenerator = HTMLGenerator;
|
|
710
|
+
//# sourceMappingURL=HTMLGenerator.js.map
|