@rawsql-ts/ddl-docs-cli 0.2.2
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/AGENTS.md +27 -0
- package/README.md +86 -0
- package/dist/src/analyzer/columnConcepts.d.ts +12 -0
- package/dist/src/analyzer/columnConcepts.js +185 -0
- package/dist/src/analyzer/columnConcepts.js.map +1 -0
- package/dist/src/analyzer/dictionary.d.ts +3 -0
- package/dist/src/analyzer/dictionary.js +39 -0
- package/dist/src/analyzer/dictionary.js.map +1 -0
- package/dist/src/analyzer/typeNormalization.d.ts +7 -0
- package/dist/src/analyzer/typeNormalization.js +76 -0
- package/dist/src/analyzer/typeNormalization.js.map +1 -0
- package/dist/src/cli.d.ts +8 -0
- package/dist/src/cli.js +264 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/commands/generate.d.ts +5 -0
- package/dist/src/commands/generate.js +266 -0
- package/dist/src/commands/generate.js.map +1 -0
- package/dist/src/commands/prune.d.ts +2 -0
- package/dist/src/commands/prune.js +17 -0
- package/dist/src/commands/prune.js.map +1 -0
- package/dist/src/config.d.ts +5 -0
- package/dist/src/config.js +57 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +9 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/parser/snapshotTableDocs.d.ts +6 -0
- package/dist/src/parser/snapshotTableDocs.js +1001 -0
- package/dist/src/parser/snapshotTableDocs.js.map +1 -0
- package/dist/src/render/columnPages.d.ts +6 -0
- package/dist/src/render/columnPages.js +226 -0
- package/dist/src/render/columnPages.js.map +1 -0
- package/dist/src/render/indexPages.d.ts +6 -0
- package/dist/src/render/indexPages.js +156 -0
- package/dist/src/render/indexPages.js.map +1 -0
- package/dist/src/render/referencesPage.d.ts +6 -0
- package/dist/src/render/referencesPage.js +51 -0
- package/dist/src/render/referencesPage.js.map +1 -0
- package/dist/src/render/tableMarkdown.d.ts +36 -0
- package/dist/src/render/tableMarkdown.js +243 -0
- package/dist/src/render/tableMarkdown.js.map +1 -0
- package/dist/src/render/types.d.ts +7 -0
- package/dist/src/render/types.js +3 -0
- package/dist/src/render/types.js.map +1 -0
- package/dist/src/state/manifest.d.ts +14 -0
- package/dist/src/state/manifest.js +153 -0
- package/dist/src/state/manifest.js.map +1 -0
- package/dist/src/types.d.ts +193 -0
- package/dist/src/types.js +3 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils/ddlInputDedupe.d.ts +9 -0
- package/dist/src/utils/ddlInputDedupe.js +25 -0
- package/dist/src/utils/ddlInputDedupe.js.map +1 -0
- package/dist/src/utils/fs.d.ts +13 -0
- package/dist/src/utils/fs.js +187 -0
- package/dist/src/utils/fs.js.map +1 -0
- package/dist/src/utils/io.d.ts +2 -0
- package/dist/src/utils/io.js +13 -0
- package/dist/src/utils/io.js.map +1 -0
- package/dist/src/utils/markdown.d.ts +12 -0
- package/dist/src/utils/markdown.js +34 -0
- package/dist/src/utils/markdown.js.map +1 -0
- package/dist/src/utils/pgDumpFilter.d.ts +8 -0
- package/dist/src/utils/pgDumpFilter.js +104 -0
- package/dist/src/utils/pgDumpFilter.js.map +1 -0
- package/dist/src/utils/slug.d.ts +1 -0
- package/dist/src/utils/slug.js +13 -0
- package/dist/src/utils/slug.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.renderTableMarkdown = renderTableMarkdown;
|
|
7
|
+
exports.tableDocPath = tableDocPath;
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const markdown_1 = require("../utils/markdown");
|
|
10
|
+
/**
|
|
11
|
+
* Renders one table documentation page as markdown.
|
|
12
|
+
*
|
|
13
|
+
* @param table Table metadata to render.
|
|
14
|
+
* @param suggestedSql Suggested SQL statements grouped by table.
|
|
15
|
+
* @param renderOptions Optional rendering options such as label/comment splitting.
|
|
16
|
+
* @returns A markdown document string for the table page.
|
|
17
|
+
*/
|
|
18
|
+
function renderTableMarkdown(table, suggestedSql, renderOptions) {
|
|
19
|
+
const labelSeparator = renderOptions === null || renderOptions === void 0 ? void 0 : renderOptions.labelSeparator;
|
|
20
|
+
const lines = [];
|
|
21
|
+
lines.push('<!-- generated-by: @rawsql-ts/ddl-docs-cli -->');
|
|
22
|
+
lines.push('');
|
|
23
|
+
lines.push(`# ${table.schema}.${table.table}`);
|
|
24
|
+
lines.push('');
|
|
25
|
+
lines.push('[<- All Schemas](../index.md) | [Table Index](./index.md)');
|
|
26
|
+
lines.push('');
|
|
27
|
+
lines.push('## Overview');
|
|
28
|
+
lines.push('');
|
|
29
|
+
lines.push(`- Instance: ${(0, markdown_1.formatTableCell)(table.instance || '-')}`);
|
|
30
|
+
lines.push(`- Comment: ${(0, markdown_1.formatTableCell)(table.tableComment)}`);
|
|
31
|
+
lines.push(`- Source Files: ${(0, markdown_1.formatTableCell)(table.sourceFiles.map((entry) => `\`${entry}\``).join('<br>'))}`);
|
|
32
|
+
lines.push('');
|
|
33
|
+
lines.push('## Columns');
|
|
34
|
+
lines.push('');
|
|
35
|
+
if (labelSeparator) {
|
|
36
|
+
lines.push('| Key | Label | Column | Type | Nullable | Default | Seq | Comment | Usages |');
|
|
37
|
+
lines.push('| --- | --- | --- | --- | --- | --- | --- | --- | --- |');
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
lines.push('| Key | Column | Type | Nullable | Default | Seq | Comment | Usages |');
|
|
41
|
+
lines.push('| --- | --- | --- | --- | --- | --- | --- | --- |');
|
|
42
|
+
}
|
|
43
|
+
for (const column of table.columns) {
|
|
44
|
+
lines.push(renderColumnRow(column, labelSeparator));
|
|
45
|
+
}
|
|
46
|
+
lines.push('');
|
|
47
|
+
lines.push('## Indexes & Constraints');
|
|
48
|
+
lines.push('');
|
|
49
|
+
const nonKeyConstraints = table.constraints.filter((constraint) => constraint.kind !== 'PK' && constraint.kind !== 'FK');
|
|
50
|
+
if (nonKeyConstraints.length === 0) {
|
|
51
|
+
lines.push('- None');
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
lines.push('| Kind | Name | Expression |');
|
|
55
|
+
lines.push('| --- | --- | --- |');
|
|
56
|
+
for (const constraint of nonKeyConstraints) {
|
|
57
|
+
lines.push(`| ${constraint.kind} | ${(0, markdown_1.formatCodeCell)(constraint.name)} | ${(0, markdown_1.formatTableCell)(constraint.expression)} |`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
lines.push('');
|
|
61
|
+
lines.push('## References');
|
|
62
|
+
lines.push('');
|
|
63
|
+
const outgoingAll = sortDirectionalReferences([...table.outgoingReferences]);
|
|
64
|
+
const incomingAll = sortDirectionalReferences([...table.incomingReferences]);
|
|
65
|
+
if (outgoingAll.length === 0 && incomingAll.length === 0) {
|
|
66
|
+
lines.push('- None');
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
if (outgoingAll.length > 0) {
|
|
70
|
+
lines.push(`::: details To (outgoing): ${outgoingAll.length}`);
|
|
71
|
+
lines.push('');
|
|
72
|
+
lines.push(...renderUnifiedReferenceTable(outgoingAll, table));
|
|
73
|
+
lines.push('');
|
|
74
|
+
lines.push(':::');
|
|
75
|
+
lines.push('');
|
|
76
|
+
}
|
|
77
|
+
if (incomingAll.length > 0) {
|
|
78
|
+
lines.push(`::: details From (incoming): ${incomingAll.length}`);
|
|
79
|
+
lines.push('');
|
|
80
|
+
lines.push(...renderUnifiedReferenceTable(incomingAll, table));
|
|
81
|
+
lines.push('');
|
|
82
|
+
lines.push(':::');
|
|
83
|
+
lines.push('');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
lines.push('');
|
|
87
|
+
lines.push('## Triggers');
|
|
88
|
+
lines.push('');
|
|
89
|
+
if (table.triggers.length === 0) {
|
|
90
|
+
lines.push('- None');
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
lines.push('| Name | Timing | Events | For Each | Function |');
|
|
94
|
+
lines.push('| --- | --- | --- | --- | --- |');
|
|
95
|
+
for (const trigger of table.triggers) {
|
|
96
|
+
const nameCell = (0, markdown_1.formatCodeCell)(trigger.name);
|
|
97
|
+
const eventsCell = trigger.events.join(', ');
|
|
98
|
+
const funcCell = (0, markdown_1.formatCodeCell)(trigger.functionName);
|
|
99
|
+
lines.push(`| ${nameCell} | ${trigger.timing} | ${eventsCell} | ${trigger.forEach} | ${funcCell} |`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
lines.push('');
|
|
103
|
+
lines.push('## Appendix');
|
|
104
|
+
lines.push('');
|
|
105
|
+
lines.push('::: details Definition');
|
|
106
|
+
lines.push('');
|
|
107
|
+
lines.push('```sql');
|
|
108
|
+
lines.push(table.normalizedSql.definition);
|
|
109
|
+
lines.push('```');
|
|
110
|
+
lines.push('');
|
|
111
|
+
lines.push(':::');
|
|
112
|
+
if (table.normalizedSql.comments) {
|
|
113
|
+
lines.push('');
|
|
114
|
+
lines.push('::: details Comments');
|
|
115
|
+
lines.push('');
|
|
116
|
+
lines.push('```sql');
|
|
117
|
+
lines.push(table.normalizedSql.comments);
|
|
118
|
+
lines.push('```');
|
|
119
|
+
lines.push('');
|
|
120
|
+
lines.push(':::');
|
|
121
|
+
}
|
|
122
|
+
if (table.normalizedSql.triggers) {
|
|
123
|
+
lines.push('');
|
|
124
|
+
lines.push('::: details Triggers (raw)');
|
|
125
|
+
lines.push('');
|
|
126
|
+
lines.push('```sql');
|
|
127
|
+
lines.push(table.normalizedSql.triggers);
|
|
128
|
+
lines.push('```');
|
|
129
|
+
lines.push('');
|
|
130
|
+
lines.push(':::');
|
|
131
|
+
}
|
|
132
|
+
if (suggestedSql.columnCommentSql.length > 0) {
|
|
133
|
+
lines.push('');
|
|
134
|
+
lines.push('### Suggested Column Comment SQL (Optional)');
|
|
135
|
+
lines.push('');
|
|
136
|
+
lines.push('```sql');
|
|
137
|
+
lines.push('-- suggested: v1 (not applied)');
|
|
138
|
+
lines.push(...suggestedSql.columnCommentSql);
|
|
139
|
+
lines.push('```');
|
|
140
|
+
}
|
|
141
|
+
if (suggestedSql.foreignKeySql.length > 0) {
|
|
142
|
+
lines.push('');
|
|
143
|
+
lines.push('### Suggested Foreign Key Constraint SQL (Optional)');
|
|
144
|
+
lines.push('');
|
|
145
|
+
lines.push('```sql');
|
|
146
|
+
lines.push('-- suggested: v1 (not applied)');
|
|
147
|
+
lines.push(...suggestedSql.foreignKeySql);
|
|
148
|
+
lines.push('```');
|
|
149
|
+
}
|
|
150
|
+
lines.push('');
|
|
151
|
+
return lines.join('\n');
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Returns output path for a rendered table markdown page.
|
|
155
|
+
*/
|
|
156
|
+
function tableDocPath(outDir, schemaSlug, tableSlug) {
|
|
157
|
+
return node_path_1.default.join(outDir, schemaSlug, `${tableSlug}.md`);
|
|
158
|
+
}
|
|
159
|
+
function linkFromTablePage(current, targetSchemaSlug, targetTableSlug) {
|
|
160
|
+
if (current.schemaSlug === targetSchemaSlug) {
|
|
161
|
+
return `./${targetTableSlug}.md`;
|
|
162
|
+
}
|
|
163
|
+
return `../${targetSchemaSlug}/${targetTableSlug}.md`;
|
|
164
|
+
}
|
|
165
|
+
const SERIAL_TYPES = new Set(['serial', 'serial2', 'serial4', 'serial8', 'bigserial', 'smallserial']);
|
|
166
|
+
function isSequenceColumn(column) {
|
|
167
|
+
return SERIAL_TYPES.has(column.typeName.toLowerCase()) || column.defaultValue.toLowerCase().includes('nextval(');
|
|
168
|
+
}
|
|
169
|
+
function splitComment(comment, separator) {
|
|
170
|
+
const regex = safeSeparatorRegExp(separator);
|
|
171
|
+
const match = regex.exec(comment);
|
|
172
|
+
if (match !== null) {
|
|
173
|
+
return {
|
|
174
|
+
label: comment.slice(0, match.index).trim(),
|
|
175
|
+
description: comment.slice(match.index + match[0].length).trim(),
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
return { label: comment, description: '' };
|
|
179
|
+
}
|
|
180
|
+
function safeSeparatorRegExp(separator) {
|
|
181
|
+
try {
|
|
182
|
+
return new RegExp(separator);
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
return new RegExp(escapeRegExp(separator));
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function escapeRegExp(value) {
|
|
189
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
190
|
+
}
|
|
191
|
+
function renderColumnRow(column, labelSeparator) {
|
|
192
|
+
const keyCell = column.isPrimaryKey ? 'PK' : '';
|
|
193
|
+
const nameCell = (0, markdown_1.formatCodeCell)(column.name);
|
|
194
|
+
const typeCell = (0, markdown_1.formatCodeCell)(column.typeName);
|
|
195
|
+
const nullableCell = column.nullable ? 'YES' : 'NO';
|
|
196
|
+
const defaultCell = (0, markdown_1.formatCodeCell)(column.defaultValue);
|
|
197
|
+
const seqCell = isSequenceColumn(column) ? 'YES' : '';
|
|
198
|
+
const usagesCell = `[usages](./columns/${column.conceptSlug}.md)`;
|
|
199
|
+
if (labelSeparator) {
|
|
200
|
+
const { label, description } = splitComment(column.comment, labelSeparator);
|
|
201
|
+
const labelCell = (0, markdown_1.formatTableCell)(label);
|
|
202
|
+
const commentCell = (0, markdown_1.formatTableCell)(description);
|
|
203
|
+
return `| ${keyCell} | ${labelCell} | ${nameCell} | ${typeCell} | ${nullableCell} | ${defaultCell} | ${seqCell} | ${commentCell} | ${usagesCell} |`;
|
|
204
|
+
}
|
|
205
|
+
const commentCell = (0, markdown_1.formatTableCell)(column.comment);
|
|
206
|
+
return `| ${keyCell} | ${nameCell} | ${typeCell} | ${nullableCell} | ${defaultCell} | ${seqCell} | ${commentCell} | ${usagesCell} |`;
|
|
207
|
+
}
|
|
208
|
+
function renderUnifiedReferenceTable(references, table) {
|
|
209
|
+
var _a, _b;
|
|
210
|
+
const lines = [];
|
|
211
|
+
lines.push('| Source | Table | Comment | Columns | On Delete | On Update | Match |');
|
|
212
|
+
lines.push('| --- | --- | --- | --- | --- | --- | --- |');
|
|
213
|
+
for (const reference of references) {
|
|
214
|
+
const sourceCell = (0, markdown_1.formatCodeCell)(reference.source);
|
|
215
|
+
const otherTableCell = renderOtherTableCell(reference, table);
|
|
216
|
+
const otherComment = reference.direction === 'outgoing' ? reference.targetTableComment : reference.fromTableComment;
|
|
217
|
+
const commentCell = (0, markdown_1.formatTableCell)(otherComment);
|
|
218
|
+
const columnsCell = (0, markdown_1.formatCodeCell)(`${reference.fromColumns.join(', ') || '?'} -> ${reference.targetColumns.join(', ') || '?'}`);
|
|
219
|
+
const onDeleteCell = reference.source === 'ddl' ? (0, markdown_1.formatCodeCell)((_a = reference.onDeleteAction) !== null && _a !== void 0 ? _a : 'none') : '-';
|
|
220
|
+
const onUpdateCell = reference.source === 'ddl' ? (0, markdown_1.formatCodeCell)((_b = reference.onUpdateAction) !== null && _b !== void 0 ? _b : 'none') : '-';
|
|
221
|
+
const matchCell = reference.source === 'suggested' && reference.matchRule ? (0, markdown_1.formatCodeCell)(reference.matchRule) : '-';
|
|
222
|
+
lines.push(`| ${sourceCell} | ${otherTableCell} | ${commentCell} | ${columnsCell} | ${onDeleteCell} | ${onUpdateCell} | ${matchCell} |`);
|
|
223
|
+
}
|
|
224
|
+
return lines;
|
|
225
|
+
}
|
|
226
|
+
function renderOtherTableCell(reference, table) {
|
|
227
|
+
if (reference.direction === 'outgoing') {
|
|
228
|
+
const linkPath = linkFromTablePage(table, reference.targetSchemaSlug, reference.targetTableSlug);
|
|
229
|
+
return `[${reference.targetTableKey}](${linkPath})`;
|
|
230
|
+
}
|
|
231
|
+
const linkPath = linkFromTablePage(table, reference.fromSchemaSlug, reference.fromTableSlug);
|
|
232
|
+
return `[${reference.fromTableKey}](${linkPath})`;
|
|
233
|
+
}
|
|
234
|
+
function sortDirectionalReferences(references) {
|
|
235
|
+
return references.sort((left, right) => {
|
|
236
|
+
const leftOther = left.direction === 'outgoing' ? left.targetTableKey : left.fromTableKey;
|
|
237
|
+
const rightOther = right.direction === 'outgoing' ? right.targetTableKey : right.fromTableKey;
|
|
238
|
+
const leftComment = left.direction === 'outgoing' ? left.targetTableComment : left.fromTableComment;
|
|
239
|
+
const rightComment = right.direction === 'outgoing' ? right.targetTableComment : right.fromTableComment;
|
|
240
|
+
return `${left.source}|${leftOther}|${leftComment}|${left.expression}`.localeCompare(`${right.source}|${rightOther}|${rightComment}|${right.expression}`);
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=tableMarkdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableMarkdown.js","sourceRoot":"","sources":["../../../src/render/tableMarkdown.ts"],"names":[],"mappings":";;;;;AAoCA,kDA4IC;AAKD,oCAEC;AAvLD,0DAA6B;AAE7B,gDAAoE;AA0BpE;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CAAC,KAAoB,EAAE,YAAgC,EAAE,aAAkC;IAC5H,MAAM,cAAc,GAAG,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,cAAc,CAAC;IACrD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC;IAC7D,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;IAC/C,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,2DAA2D,CAAC,CAAC;IACxE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC1B,KAAK,CAAC,IAAI,CAAC,EAAE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,CAAC;IAC7F,OAAO,IAAI,SAAS,CAAC,YAAY,KAAK,QAAQ,GAAG,CAAC;AACpD,CAAC;AAED,SAAS,yBAAyB,CAAC,UAA+B;IAChE,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACrC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC;QAC1F,MAAM,UAAU,GAAG,KAAK,CAAC,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC;QAC9F,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC;QACpG,MAAM,YAAY,GAAG,KAAK,CAAC,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC;QACxG,OAAO,GAAG,IAAI,CAAC,MAAM,IAAI,SAAS,IAAI,WAAW,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC,aAAa,CAClF,GAAG,KAAK,CAAC,MAAM,IAAI,UAAU,IAAI,YAAY,IAAI,KAAK,CAAC,UAAU,EAAE,CACpE,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/render/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DocsManifest, PruneResult } from '../types';
|
|
2
|
+
export interface ManifestWriteOptions {
|
|
3
|
+
outDir: string;
|
|
4
|
+
generatorVersion: string;
|
|
5
|
+
dialect: 'postgres';
|
|
6
|
+
optionsForHash: Record<string, unknown>;
|
|
7
|
+
nameMap: Record<string, string>;
|
|
8
|
+
tableOutputs: string[];
|
|
9
|
+
columnOutputs: string[];
|
|
10
|
+
}
|
|
11
|
+
export declare function manifestPath(outDir: string): string;
|
|
12
|
+
export declare function writeManifest(options: ManifestWriteOptions): string;
|
|
13
|
+
export declare function readManifest(outDir: string): DocsManifest | null;
|
|
14
|
+
export declare function pruneManagedFiles(outDir: string, dryRun: boolean, pruneOrphans: boolean): PruneResult;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.manifestPath = manifestPath;
|
|
7
|
+
exports.writeManifest = writeManifest;
|
|
8
|
+
exports.readManifest = readManifest;
|
|
9
|
+
exports.pruneManagedFiles = pruneManagedFiles;
|
|
10
|
+
const node_crypto_1 = require("node:crypto");
|
|
11
|
+
const node_fs_1 = require("node:fs");
|
|
12
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
13
|
+
const fs_1 = require("../utils/fs");
|
|
14
|
+
const io_1 = require("../utils/io");
|
|
15
|
+
const MANIFEST_FILE = 'manifest.json';
|
|
16
|
+
const GENERATED_HEADER = '<!-- generated-by: @rawsql-ts/ddl-docs-cli -->';
|
|
17
|
+
function manifestPath(outDir) {
|
|
18
|
+
return node_path_1.default.join(outDir, '_meta', MANIFEST_FILE);
|
|
19
|
+
}
|
|
20
|
+
function writeManifest(options) {
|
|
21
|
+
(0, fs_1.ensureDirectory)(node_path_1.default.join(options.outDir, '_meta'));
|
|
22
|
+
const manifest = {
|
|
23
|
+
generator: {
|
|
24
|
+
version: options.generatorVersion,
|
|
25
|
+
dialect: options.dialect,
|
|
26
|
+
optionsHash: hashOptions(options.optionsForHash),
|
|
27
|
+
},
|
|
28
|
+
naming: {
|
|
29
|
+
slugRules: 'lowercase; replace non [a-z0-9] with -; trim dashes; fallback unnamed',
|
|
30
|
+
nameMap: options.nameMap,
|
|
31
|
+
},
|
|
32
|
+
outputs: {
|
|
33
|
+
tables: toSortedPosix(options.outDir, options.tableOutputs),
|
|
34
|
+
columns: toSortedPosix(options.outDir, options.columnOutputs),
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
const outputPath = manifestPath(options.outDir);
|
|
38
|
+
(0, node_fs_1.writeFileSync)(outputPath, (0, io_1.normalizeLf)(JSON.stringify(manifest, null, 2)), 'utf8');
|
|
39
|
+
return outputPath;
|
|
40
|
+
}
|
|
41
|
+
function readManifest(outDir) {
|
|
42
|
+
var _a, _b;
|
|
43
|
+
const filePath = manifestPath(outDir);
|
|
44
|
+
if (!(0, node_fs_1.existsSync)(filePath)) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const raw = (0, node_fs_1.readFileSync)(filePath, 'utf8');
|
|
48
|
+
const parsed = JSON.parse(raw);
|
|
49
|
+
if (!(parsed === null || parsed === void 0 ? void 0 : parsed.generator) || !(parsed === null || parsed === void 0 ? void 0 : parsed.naming) || !(parsed === null || parsed === void 0 ? void 0 : parsed.outputs)) {
|
|
50
|
+
throw new Error(`Invalid manifest format: ${filePath}`);
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
generator: parsed.generator,
|
|
54
|
+
naming: parsed.naming,
|
|
55
|
+
outputs: {
|
|
56
|
+
tables: (_a = parsed.outputs.tables) !== null && _a !== void 0 ? _a : [],
|
|
57
|
+
columns: (_b = parsed.outputs.columns) !== null && _b !== void 0 ? _b : [],
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function pruneManagedFiles(outDir, dryRun, pruneOrphans) {
|
|
62
|
+
const manifest = readManifest(outDir);
|
|
63
|
+
if (!manifest) {
|
|
64
|
+
return { removed: [], dryRun };
|
|
65
|
+
}
|
|
66
|
+
const managed = [...manifest.outputs.tables, ...manifest.outputs.columns];
|
|
67
|
+
const removed = [];
|
|
68
|
+
for (const relativeFile of managed) {
|
|
69
|
+
const resolvedFile = node_path_1.default.resolve(outDir, relativeFile);
|
|
70
|
+
if (!(0, node_fs_1.existsSync)(resolvedFile) || !isManagedGeneratedFile(resolvedFile)) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (!dryRun) {
|
|
74
|
+
(0, node_fs_1.rmSync)(resolvedFile, { force: true });
|
|
75
|
+
}
|
|
76
|
+
removed.push(resolvedFile);
|
|
77
|
+
}
|
|
78
|
+
if (pruneOrphans) {
|
|
79
|
+
const orphanCandidates = findGeneratedMarkdownFiles(outDir);
|
|
80
|
+
const managedSet = new Set(managed.map((entry) => node_path_1.default.resolve(outDir, entry)));
|
|
81
|
+
for (const candidate of orphanCandidates) {
|
|
82
|
+
if (managedSet.has(candidate)) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (!dryRun) {
|
|
86
|
+
(0, node_fs_1.rmSync)(candidate, { force: true });
|
|
87
|
+
}
|
|
88
|
+
removed.push(candidate);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const metaFiles = [
|
|
92
|
+
manifestPath(outDir),
|
|
93
|
+
node_path_1.default.join(outDir, '_meta', 'warnings.json'),
|
|
94
|
+
node_path_1.default.join(outDir, '_meta', 'warnings.md'),
|
|
95
|
+
node_path_1.default.join(outDir, '_meta', 'findings.json'),
|
|
96
|
+
node_path_1.default.join(outDir, '_meta', 'findings.md'),
|
|
97
|
+
node_path_1.default.join(outDir, '_meta', 'snapshot.json'),
|
|
98
|
+
node_path_1.default.join(outDir, '_meta', 'observed-column-dictionary.json'),
|
|
99
|
+
node_path_1.default.join(outDir, '_meta', 'suggested.sql'),
|
|
100
|
+
];
|
|
101
|
+
if (!dryRun) {
|
|
102
|
+
for (const metaFile of metaFiles) {
|
|
103
|
+
if ((0, node_fs_1.existsSync)(metaFile)) {
|
|
104
|
+
(0, node_fs_1.rmSync)(metaFile, { force: true });
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return { removed: Array.from(new Set(removed)).sort(), dryRun };
|
|
109
|
+
}
|
|
110
|
+
function hashOptions(options) {
|
|
111
|
+
const hash = (0, node_crypto_1.createHash)('sha256');
|
|
112
|
+
hash.update(JSON.stringify(options, Object.keys(options).sort()));
|
|
113
|
+
return hash.digest('hex');
|
|
114
|
+
}
|
|
115
|
+
function toSortedPosix(outDir, files) {
|
|
116
|
+
return Array.from(new Set(files.map((entry) => node_path_1.default.relative(outDir, entry).replace(/\\/g, '/')))).sort();
|
|
117
|
+
}
|
|
118
|
+
function isManagedGeneratedFile(filePath) {
|
|
119
|
+
if (!filePath.toLowerCase().endsWith('.md')) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
const content = (0, node_fs_1.readFileSync)(filePath, 'utf8');
|
|
123
|
+
return content.includes(GENERATED_HEADER);
|
|
124
|
+
}
|
|
125
|
+
function findGeneratedMarkdownFiles(rootDir) {
|
|
126
|
+
const files = [];
|
|
127
|
+
walk(rootDir, files);
|
|
128
|
+
return files.sort();
|
|
129
|
+
}
|
|
130
|
+
function walk(currentDir, files) {
|
|
131
|
+
const entries = (0, node_fs_1.readdirSync)(currentDir, { withFileTypes: true });
|
|
132
|
+
for (const entry of entries) {
|
|
133
|
+
const resolved = node_path_1.default.join(currentDir, entry.name);
|
|
134
|
+
if (entry.isDirectory()) {
|
|
135
|
+
if (entry.name === '_meta' || entry.name === 'node_modules') {
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
walk(resolved, files);
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (!entry.isFile()) {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if (!resolved.toLowerCase().endsWith('.md')) {
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (!isManagedGeneratedFile(resolved)) {
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
files.push(resolved);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../../src/state/manifest.ts"],"names":[],"mappings":";;;;;AAoBA,oCAEC;AAED,sCAoBC;AAED,oCAkBC;AAED,8CAoDC;AAtHD,6CAAyC;AACzC,qCAAuF;AACvF,0DAA6B;AAE7B,oCAA8C;AAC9C,oCAA0C;AAE1C,MAAM,aAAa,GAAG,eAAe,CAAC;AACtC,MAAM,gBAAgB,GAAG,gDAAgD,CAAC;AAY1E,SAAgB,YAAY,CAAC,MAAc;IACzC,OAAO,mBAAI,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;AACnD,CAAC;AAED,SAAgB,aAAa,CAAC,OAA6B;IACzD,IAAA,oBAAe,EAAC,mBAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACpD,MAAM,QAAQ,GAAiB;QAC7B,SAAS,EAAE;YACT,OAAO,EAAE,OAAO,CAAC,gBAAgB;YACjC,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,WAAW,EAAE,WAAW,CAAC,OAAO,CAAC,cAAc,CAAC;SACjD;QACD,MAAM,EAAE;YACN,SAAS,EAAE,uEAAuE;YAClF,OAAO,EAAE,OAAO,CAAC,OAAO;SACzB;QACD,OAAO,EAAE;YACP,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC;YAC3D,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC;SAC9D;KACF,CAAC;IACF,MAAM,UAAU,GAAG,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAChD,IAAA,uBAAa,EAAC,UAA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AQ,EAAE,KAAK,CAAC,CAAC;YACtB,SAAS;QACX,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;YACpB,SAAS;QACX,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5C,SAAS;QACX,CAAC;QACD,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACtC,SAAS;QACX,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
export interface SqlSource {
|
|
2
|
+
path: string;
|
|
3
|
+
sql: string;
|
|
4
|
+
instance: string;
|
|
5
|
+
}
|
|
6
|
+
export interface DdlInput {
|
|
7
|
+
path: string;
|
|
8
|
+
instance: string;
|
|
9
|
+
}
|
|
10
|
+
export interface GenerateDocsOptions {
|
|
11
|
+
ddlDirectories: DdlInput[];
|
|
12
|
+
ddlFiles: DdlInput[];
|
|
13
|
+
ddlGlobs: DdlInput[];
|
|
14
|
+
extensions: string[];
|
|
15
|
+
outDir: string;
|
|
16
|
+
includeIndexes: boolean;
|
|
17
|
+
strict: boolean;
|
|
18
|
+
dialect: 'postgres';
|
|
19
|
+
columnOrder: 'definition' | 'name';
|
|
20
|
+
labelSeparator?: string;
|
|
21
|
+
locale?: string;
|
|
22
|
+
dictionaryPath?: string;
|
|
23
|
+
configPath?: string;
|
|
24
|
+
defaultSchema?: string;
|
|
25
|
+
searchPath?: string[];
|
|
26
|
+
filterPgDump?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface PruneDocsOptions {
|
|
29
|
+
outDir: string;
|
|
30
|
+
dryRun: boolean;
|
|
31
|
+
pruneOrphans: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface ResolvedSchemaSettings {
|
|
34
|
+
defaultSchema: string;
|
|
35
|
+
searchPath: string[];
|
|
36
|
+
}
|
|
37
|
+
export interface ColumnDocModel {
|
|
38
|
+
name: string;
|
|
39
|
+
concept: string;
|
|
40
|
+
conceptSlug: string;
|
|
41
|
+
typeName: string;
|
|
42
|
+
canonicalType: string;
|
|
43
|
+
typeKey: string;
|
|
44
|
+
nullable: boolean;
|
|
45
|
+
defaultValue: string;
|
|
46
|
+
isPrimaryKey: boolean;
|
|
47
|
+
comment: string;
|
|
48
|
+
checks: string[];
|
|
49
|
+
unknownType: boolean;
|
|
50
|
+
}
|
|
51
|
+
export interface TriggerDocModel {
|
|
52
|
+
name: string;
|
|
53
|
+
timing: string;
|
|
54
|
+
events: string[];
|
|
55
|
+
forEach: string;
|
|
56
|
+
functionName: string;
|
|
57
|
+
rawSql: string;
|
|
58
|
+
}
|
|
59
|
+
export interface TableDocModel {
|
|
60
|
+
schema: string;
|
|
61
|
+
table: string;
|
|
62
|
+
schemaSlug: string;
|
|
63
|
+
tableSlug: string;
|
|
64
|
+
instance: string;
|
|
65
|
+
tableComment: string;
|
|
66
|
+
sourceFiles: string[];
|
|
67
|
+
columns: ColumnDocModel[];
|
|
68
|
+
primaryKey: string[];
|
|
69
|
+
constraints: TableConstraintDocModel[];
|
|
70
|
+
triggers: TriggerDocModel[];
|
|
71
|
+
outgoingReferences: ReferenceDocModel[];
|
|
72
|
+
incomingReferences: ReferenceDocModel[];
|
|
73
|
+
normalizedSql: NormalizedSql;
|
|
74
|
+
}
|
|
75
|
+
export interface DocsManifest {
|
|
76
|
+
generator: {
|
|
77
|
+
version: string;
|
|
78
|
+
dialect: 'postgres';
|
|
79
|
+
optionsHash: string;
|
|
80
|
+
};
|
|
81
|
+
naming: {
|
|
82
|
+
slugRules: string;
|
|
83
|
+
nameMap: Record<string, string>;
|
|
84
|
+
};
|
|
85
|
+
outputs: {
|
|
86
|
+
tables: string[];
|
|
87
|
+
columns: string[];
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
export interface WarningSource {
|
|
91
|
+
filePath: string;
|
|
92
|
+
statementIndex?: number;
|
|
93
|
+
}
|
|
94
|
+
export interface WarningItem {
|
|
95
|
+
kind: 'UNSUPPORTED_DDL' | 'PARSE_FAILED' | 'AMBIGUOUS';
|
|
96
|
+
message: string;
|
|
97
|
+
statementPreview: string;
|
|
98
|
+
source: WarningSource;
|
|
99
|
+
}
|
|
100
|
+
export interface SnapshotResult {
|
|
101
|
+
tables: TableDocModel[];
|
|
102
|
+
warnings: WarningItem[];
|
|
103
|
+
}
|
|
104
|
+
export interface TableConstraintDocModel {
|
|
105
|
+
kind: 'PK' | 'UK' | 'CHECK' | 'FK' | 'INDEX';
|
|
106
|
+
name: string;
|
|
107
|
+
expression: string;
|
|
108
|
+
/** true when this constraint originated from CREATE [UNIQUE] INDEX */
|
|
109
|
+
isIndex?: boolean;
|
|
110
|
+
}
|
|
111
|
+
export interface NormalizedSql {
|
|
112
|
+
/** CREATE TABLE + ALTER TABLE constraints + CREATE [UNIQUE] INDEX */
|
|
113
|
+
definition: string;
|
|
114
|
+
/** COMMENT ON TABLE + COMMENT ON COLUMN */
|
|
115
|
+
comments: string;
|
|
116
|
+
/** CREATE TRIGGER statements (raw, not normalized) */
|
|
117
|
+
triggers: string;
|
|
118
|
+
}
|
|
119
|
+
export interface ReferenceDocModel {
|
|
120
|
+
direction: 'outgoing' | 'incoming';
|
|
121
|
+
source: 'ddl' | 'suggested';
|
|
122
|
+
fromTableKey: string;
|
|
123
|
+
fromTableComment: string;
|
|
124
|
+
targetTableKey: string;
|
|
125
|
+
targetTableComment: string;
|
|
126
|
+
fromColumns: string[];
|
|
127
|
+
targetColumns: string[];
|
|
128
|
+
onDeleteAction: 'cascade' | 'restrict' | 'no action' | 'set null' | 'set default' | null;
|
|
129
|
+
onUpdateAction: 'cascade' | 'restrict' | 'no action' | 'set null' | 'set default' | null;
|
|
130
|
+
fromSchemaSlug: string;
|
|
131
|
+
fromTableSlug: string;
|
|
132
|
+
targetSchemaSlug: string;
|
|
133
|
+
targetTableSlug: string;
|
|
134
|
+
matchRule?: 'exact';
|
|
135
|
+
expression: string;
|
|
136
|
+
}
|
|
137
|
+
export interface PruneResult {
|
|
138
|
+
removed: string[];
|
|
139
|
+
dryRun: boolean;
|
|
140
|
+
}
|
|
141
|
+
export interface DictionaryEntry {
|
|
142
|
+
preferredTypes?: string[];
|
|
143
|
+
labels?: Record<string, string>;
|
|
144
|
+
notes?: Record<string, string>;
|
|
145
|
+
}
|
|
146
|
+
export interface ColumnDictionary {
|
|
147
|
+
version: number;
|
|
148
|
+
locales?: string[];
|
|
149
|
+
columns: Record<string, DictionaryEntry>;
|
|
150
|
+
}
|
|
151
|
+
export interface ObservedColumnUsage {
|
|
152
|
+
schema: string;
|
|
153
|
+
table: string;
|
|
154
|
+
column: string;
|
|
155
|
+
tableSlug: string;
|
|
156
|
+
schemaSlug: string;
|
|
157
|
+
typeKey: string;
|
|
158
|
+
canonicalType: string;
|
|
159
|
+
nullable: boolean;
|
|
160
|
+
defaultValue: string;
|
|
161
|
+
comment: string;
|
|
162
|
+
hasComment: boolean;
|
|
163
|
+
}
|
|
164
|
+
export interface ObservedColumnConcept {
|
|
165
|
+
concept: string;
|
|
166
|
+
conceptSlug: string;
|
|
167
|
+
typeDistribution: Record<string, number>;
|
|
168
|
+
usages: ObservedColumnUsage[];
|
|
169
|
+
}
|
|
170
|
+
export interface ObservedColumnDictionary {
|
|
171
|
+
version: 1;
|
|
172
|
+
generatedAt: string;
|
|
173
|
+
concepts: ObservedColumnConcept[];
|
|
174
|
+
}
|
|
175
|
+
export type FindingKind = 'COLUMN_NAME_TYPE_DIVERGENCE' | 'MISSING_COMMENT_SUGGESTED' | 'COMMENT_VS_DICTIONARY_MISMATCH' | 'UNSUPPORTED_OR_UNKNOWN_TYPE';
|
|
176
|
+
export interface FindingItem {
|
|
177
|
+
kind: FindingKind;
|
|
178
|
+
severity: 'info' | 'warning';
|
|
179
|
+
message: string;
|
|
180
|
+
scope: {
|
|
181
|
+
schema?: string;
|
|
182
|
+
table?: string;
|
|
183
|
+
column?: string;
|
|
184
|
+
concept?: string;
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
export interface SuggestionItem {
|
|
188
|
+
kind: 'column_comment' | 'foreign_key';
|
|
189
|
+
schema: string;
|
|
190
|
+
table: string;
|
|
191
|
+
column: string;
|
|
192
|
+
sql: string;
|
|
193
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DdlInput } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Dedupe DDL inputs by the tuple key of (instance, path).
|
|
4
|
+
*
|
|
5
|
+
* Inputs sharing only the path are preserved when their instance differs.
|
|
6
|
+
* The key format intentionally uses a NUL separator to avoid collisions with
|
|
7
|
+
* common path characters on Windows and POSIX.
|
|
8
|
+
*/
|
|
9
|
+
export declare function dedupeDdlInputsByInstanceAndPath(inputs: DdlInput[]): DdlInput[];
|