@cuongph.dev/dbdocgen 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/LICENSE +21 -0
- package/README.md +437 -0
- package/dist/cli/index.cjs +1844 -0
- package/dist/cli/index.cjs.map +1 -0
- package/dist/cli/index.d.cts +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +1830 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.cjs +1751 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +292 -0
- package/dist/index.d.ts +292 -0
- package/dist/index.js +1713 -0
- package/dist/index.js.map +1 -0
- package/package.json +80 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
type DatabaseDialect = "postgres" | "mysql" | "mariadb" | "sqlite" | "mssql" | "unknown";
|
|
4
|
+
type Confidence = "high" | "medium" | "low";
|
|
5
|
+
type EnrichedText = {
|
|
6
|
+
value: string;
|
|
7
|
+
source: "db_comment" | "backend_source" | "ai";
|
|
8
|
+
confidence: Confidence;
|
|
9
|
+
needsReview: boolean;
|
|
10
|
+
};
|
|
11
|
+
type WarningDoc = {
|
|
12
|
+
code: string;
|
|
13
|
+
message: string;
|
|
14
|
+
target?: string;
|
|
15
|
+
severity: "info" | "warning" | "error";
|
|
16
|
+
};
|
|
17
|
+
type ReviewTodo = {
|
|
18
|
+
type: "table" | "column" | "relationship" | "ai" | "parser";
|
|
19
|
+
target: string;
|
|
20
|
+
issue: string;
|
|
21
|
+
suggestion?: string;
|
|
22
|
+
source: "schema" | "backend_source" | "ai" | "parser";
|
|
23
|
+
};
|
|
24
|
+
type ColumnDoc = {
|
|
25
|
+
name: string;
|
|
26
|
+
type: string;
|
|
27
|
+
nullable: boolean;
|
|
28
|
+
defaultValue?: string;
|
|
29
|
+
isPrimaryKey: boolean;
|
|
30
|
+
isForeignKey: boolean;
|
|
31
|
+
comment?: string;
|
|
32
|
+
description?: EnrichedText;
|
|
33
|
+
};
|
|
34
|
+
type ForeignKeyDoc = {
|
|
35
|
+
name?: string;
|
|
36
|
+
columns: string[];
|
|
37
|
+
referencedTable: string;
|
|
38
|
+
referencedColumns: string[];
|
|
39
|
+
};
|
|
40
|
+
type IndexDoc = {
|
|
41
|
+
name: string;
|
|
42
|
+
table: string;
|
|
43
|
+
columns: string[];
|
|
44
|
+
unique: boolean;
|
|
45
|
+
};
|
|
46
|
+
type RelationshipDoc = {
|
|
47
|
+
fromTable: string;
|
|
48
|
+
fromColumn: string;
|
|
49
|
+
toTable: string;
|
|
50
|
+
toColumn: string;
|
|
51
|
+
constraintName?: string;
|
|
52
|
+
source: "schema" | "ai_suggestion";
|
|
53
|
+
needsReview: boolean;
|
|
54
|
+
};
|
|
55
|
+
type TableDoc = {
|
|
56
|
+
name: string;
|
|
57
|
+
schema?: string;
|
|
58
|
+
comment?: string;
|
|
59
|
+
description?: EnrichedText;
|
|
60
|
+
columns: ColumnDoc[];
|
|
61
|
+
primaryKeys: string[];
|
|
62
|
+
foreignKeys: ForeignKeyDoc[];
|
|
63
|
+
indexes: IndexDoc[];
|
|
64
|
+
reviewTodos: ReviewTodo[];
|
|
65
|
+
};
|
|
66
|
+
type DatabaseDoc = {
|
|
67
|
+
dialect: DatabaseDialect;
|
|
68
|
+
tables: TableDoc[];
|
|
69
|
+
relationships: RelationshipDoc[];
|
|
70
|
+
indexes: IndexDoc[];
|
|
71
|
+
warnings: WarningDoc[];
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
declare const databaseDocSchema: z.ZodObject<{
|
|
75
|
+
dialect: z.ZodEnum<{
|
|
76
|
+
postgres: "postgres";
|
|
77
|
+
mysql: "mysql";
|
|
78
|
+
mariadb: "mariadb";
|
|
79
|
+
sqlite: "sqlite";
|
|
80
|
+
mssql: "mssql";
|
|
81
|
+
unknown: "unknown";
|
|
82
|
+
}>;
|
|
83
|
+
tables: z.ZodArray<z.ZodObject<{
|
|
84
|
+
name: z.ZodString;
|
|
85
|
+
schema: z.ZodOptional<z.ZodString>;
|
|
86
|
+
comment: z.ZodOptional<z.ZodString>;
|
|
87
|
+
description: z.ZodOptional<z.ZodObject<{
|
|
88
|
+
value: z.ZodString;
|
|
89
|
+
source: z.ZodEnum<{
|
|
90
|
+
db_comment: "db_comment";
|
|
91
|
+
backend_source: "backend_source";
|
|
92
|
+
ai: "ai";
|
|
93
|
+
}>;
|
|
94
|
+
confidence: z.ZodEnum<{
|
|
95
|
+
high: "high";
|
|
96
|
+
medium: "medium";
|
|
97
|
+
low: "low";
|
|
98
|
+
}>;
|
|
99
|
+
needsReview: z.ZodBoolean;
|
|
100
|
+
}, z.core.$strip>>;
|
|
101
|
+
columns: z.ZodArray<z.ZodObject<{
|
|
102
|
+
name: z.ZodString;
|
|
103
|
+
type: z.ZodString;
|
|
104
|
+
nullable: z.ZodBoolean;
|
|
105
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
106
|
+
isPrimaryKey: z.ZodBoolean;
|
|
107
|
+
isForeignKey: z.ZodBoolean;
|
|
108
|
+
comment: z.ZodOptional<z.ZodString>;
|
|
109
|
+
description: z.ZodOptional<z.ZodObject<{
|
|
110
|
+
value: z.ZodString;
|
|
111
|
+
source: z.ZodEnum<{
|
|
112
|
+
db_comment: "db_comment";
|
|
113
|
+
backend_source: "backend_source";
|
|
114
|
+
ai: "ai";
|
|
115
|
+
}>;
|
|
116
|
+
confidence: z.ZodEnum<{
|
|
117
|
+
high: "high";
|
|
118
|
+
medium: "medium";
|
|
119
|
+
low: "low";
|
|
120
|
+
}>;
|
|
121
|
+
needsReview: z.ZodBoolean;
|
|
122
|
+
}, z.core.$strip>>;
|
|
123
|
+
}, z.core.$strip>>;
|
|
124
|
+
primaryKeys: z.ZodArray<z.ZodString>;
|
|
125
|
+
foreignKeys: z.ZodArray<z.ZodObject<{
|
|
126
|
+
name: z.ZodOptional<z.ZodString>;
|
|
127
|
+
columns: z.ZodArray<z.ZodString>;
|
|
128
|
+
referencedTable: z.ZodString;
|
|
129
|
+
referencedColumns: z.ZodArray<z.ZodString>;
|
|
130
|
+
}, z.core.$strip>>;
|
|
131
|
+
indexes: z.ZodArray<z.ZodObject<{
|
|
132
|
+
name: z.ZodString;
|
|
133
|
+
table: z.ZodString;
|
|
134
|
+
columns: z.ZodArray<z.ZodString>;
|
|
135
|
+
unique: z.ZodBoolean;
|
|
136
|
+
}, z.core.$strip>>;
|
|
137
|
+
reviewTodos: z.ZodArray<z.ZodObject<{
|
|
138
|
+
type: z.ZodEnum<{
|
|
139
|
+
ai: "ai";
|
|
140
|
+
table: "table";
|
|
141
|
+
column: "column";
|
|
142
|
+
relationship: "relationship";
|
|
143
|
+
parser: "parser";
|
|
144
|
+
}>;
|
|
145
|
+
target: z.ZodString;
|
|
146
|
+
issue: z.ZodString;
|
|
147
|
+
suggestion: z.ZodOptional<z.ZodString>;
|
|
148
|
+
source: z.ZodEnum<{
|
|
149
|
+
backend_source: "backend_source";
|
|
150
|
+
ai: "ai";
|
|
151
|
+
parser: "parser";
|
|
152
|
+
schema: "schema";
|
|
153
|
+
}>;
|
|
154
|
+
}, z.core.$strip>>;
|
|
155
|
+
}, z.core.$strip>>;
|
|
156
|
+
relationships: z.ZodArray<z.ZodObject<{
|
|
157
|
+
fromTable: z.ZodString;
|
|
158
|
+
fromColumn: z.ZodString;
|
|
159
|
+
toTable: z.ZodString;
|
|
160
|
+
toColumn: z.ZodString;
|
|
161
|
+
constraintName: z.ZodOptional<z.ZodString>;
|
|
162
|
+
source: z.ZodEnum<{
|
|
163
|
+
schema: "schema";
|
|
164
|
+
ai_suggestion: "ai_suggestion";
|
|
165
|
+
}>;
|
|
166
|
+
needsReview: z.ZodBoolean;
|
|
167
|
+
}, z.core.$strip>>;
|
|
168
|
+
indexes: z.ZodArray<z.ZodObject<{
|
|
169
|
+
name: z.ZodString;
|
|
170
|
+
table: z.ZodString;
|
|
171
|
+
columns: z.ZodArray<z.ZodString>;
|
|
172
|
+
unique: z.ZodBoolean;
|
|
173
|
+
}, z.core.$strip>>;
|
|
174
|
+
warnings: z.ZodArray<z.ZodObject<{
|
|
175
|
+
code: z.ZodString;
|
|
176
|
+
message: z.ZodString;
|
|
177
|
+
target: z.ZodOptional<z.ZodString>;
|
|
178
|
+
severity: z.ZodEnum<{
|
|
179
|
+
info: "info";
|
|
180
|
+
warning: "warning";
|
|
181
|
+
error: "error";
|
|
182
|
+
}>;
|
|
183
|
+
}, z.core.$strip>>;
|
|
184
|
+
}, z.core.$strip>;
|
|
185
|
+
|
|
186
|
+
declare const outputFormatSchema: z.ZodEnum<{
|
|
187
|
+
excel: "excel";
|
|
188
|
+
markdown: "markdown";
|
|
189
|
+
html: "html";
|
|
190
|
+
diagram: "diagram";
|
|
191
|
+
word: "word";
|
|
192
|
+
}>;
|
|
193
|
+
declare const outputLanguageSchema: z.ZodEnum<{
|
|
194
|
+
en: "en";
|
|
195
|
+
jp: "jp";
|
|
196
|
+
}>;
|
|
197
|
+
declare const dbdocgenConfigSchema: z.ZodObject<{
|
|
198
|
+
schema: z.ZodDefault<z.ZodString>;
|
|
199
|
+
dialect: z.ZodOptional<z.ZodEnum<{
|
|
200
|
+
postgres: "postgres";
|
|
201
|
+
mysql: "mysql";
|
|
202
|
+
mariadb: "mariadb";
|
|
203
|
+
sqlite: "sqlite";
|
|
204
|
+
mssql: "mssql";
|
|
205
|
+
unknown: "unknown";
|
|
206
|
+
}>>;
|
|
207
|
+
outDir: z.ZodDefault<z.ZodString>;
|
|
208
|
+
output: z.ZodDefault<z.ZodObject<{
|
|
209
|
+
formats: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
210
|
+
excel: "excel";
|
|
211
|
+
markdown: "markdown";
|
|
212
|
+
html: "html";
|
|
213
|
+
diagram: "diagram";
|
|
214
|
+
word: "word";
|
|
215
|
+
}>>>;
|
|
216
|
+
language: z.ZodDefault<z.ZodEnum<{
|
|
217
|
+
en: "en";
|
|
218
|
+
jp: "jp";
|
|
219
|
+
}>>;
|
|
220
|
+
}, z.core.$strip>>;
|
|
221
|
+
}, z.core.$strip>;
|
|
222
|
+
type OutputFormat = z.infer<typeof outputFormatSchema>;
|
|
223
|
+
type OutputLanguage = z.infer<typeof outputLanguageSchema>;
|
|
224
|
+
type DbdocgenConfig = z.infer<typeof dbdocgenConfigSchema>;
|
|
225
|
+
|
|
226
|
+
type CliConfigOptions = {
|
|
227
|
+
schema?: string;
|
|
228
|
+
dialect?: "postgres" | "mysql" | "mariadb" | "sqlite" | "mssql" | "unknown";
|
|
229
|
+
outDir?: string;
|
|
230
|
+
formats?: OutputFormat[];
|
|
231
|
+
configPath?: string;
|
|
232
|
+
};
|
|
233
|
+
type LoadConfigInput = {
|
|
234
|
+
cwd: string;
|
|
235
|
+
cliOptions: CliConfigOptions;
|
|
236
|
+
};
|
|
237
|
+
declare function loadConfig(input: LoadConfigInput): Promise<DbdocgenConfig>;
|
|
238
|
+
|
|
239
|
+
type ParseSqlSchemaOptions = {
|
|
240
|
+
dialect?: DatabaseDialect;
|
|
241
|
+
};
|
|
242
|
+
declare function parseSqlSchema(sql: string, options?: ParseSqlSchemaOptions): Promise<DatabaseDoc>;
|
|
243
|
+
|
|
244
|
+
type ExportOptions = {
|
|
245
|
+
outDir: string;
|
|
246
|
+
language?: OutputLanguage;
|
|
247
|
+
};
|
|
248
|
+
declare function exportExcelDictionary(doc: DatabaseDoc, options: ExportOptions): Promise<void>;
|
|
249
|
+
|
|
250
|
+
type DiagramExportOptions = {
|
|
251
|
+
outDir: string;
|
|
252
|
+
};
|
|
253
|
+
declare function exportMermaidDiagram(doc: DatabaseDoc, options: DiagramExportOptions): Promise<void>;
|
|
254
|
+
declare function renderMermaid(doc: DatabaseDoc): string;
|
|
255
|
+
|
|
256
|
+
type MarkdownExportOptions = {
|
|
257
|
+
outDir: string;
|
|
258
|
+
language?: OutputLanguage;
|
|
259
|
+
};
|
|
260
|
+
declare function exportMarkdownDocs(doc: DatabaseDoc, options: MarkdownExportOptions): Promise<void>;
|
|
261
|
+
|
|
262
|
+
type HtmlExportOptions = {
|
|
263
|
+
outDir: string;
|
|
264
|
+
language?: OutputLanguage;
|
|
265
|
+
};
|
|
266
|
+
declare function exportHtmlDocs(doc: DatabaseDoc, options: HtmlExportOptions): Promise<void>;
|
|
267
|
+
|
|
268
|
+
type WordExportOptions = {
|
|
269
|
+
outDir: string;
|
|
270
|
+
language?: OutputLanguage;
|
|
271
|
+
};
|
|
272
|
+
declare function exportWordDocument(doc: DatabaseDoc, options: WordExportOptions): Promise<void>;
|
|
273
|
+
|
|
274
|
+
type GenerateDbDocsOptions = {
|
|
275
|
+
schema: string;
|
|
276
|
+
outDir: string;
|
|
277
|
+
dialect?: DatabaseDialect;
|
|
278
|
+
output: {
|
|
279
|
+
formats: OutputFormat[];
|
|
280
|
+
language?: OutputLanguage;
|
|
281
|
+
};
|
|
282
|
+
onProgress?: (event: {
|
|
283
|
+
step: string;
|
|
284
|
+
message: string;
|
|
285
|
+
detail?: Record<string, unknown>;
|
|
286
|
+
}) => void;
|
|
287
|
+
};
|
|
288
|
+
declare function generateDbDocs(options: GenerateDbDocsOptions): Promise<DatabaseDoc>;
|
|
289
|
+
|
|
290
|
+
declare const version = "0.1.0";
|
|
291
|
+
|
|
292
|
+
export { type ColumnDoc, type Confidence, type DatabaseDialect, type DatabaseDoc, type DbdocgenConfig, type EnrichedText, type ForeignKeyDoc, type GenerateDbDocsOptions, type IndexDoc, type OutputFormat, type RelationshipDoc, type ReviewTodo, type TableDoc, type WarningDoc, databaseDocSchema, exportExcelDictionary, exportHtmlDocs, exportMarkdownDocs, exportMermaidDiagram, exportWordDocument, generateDbDocs, loadConfig, parseSqlSchema, renderMermaid, version };
|