@sqldoc/ns-docs 0.0.1
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/package.json +32 -0
- package/src/__tests__/atlas.test.ts +134 -0
- package/src/__tests__/merge.test.ts +401 -0
- package/src/__tests__/mermaid.test.ts +107 -0
- package/src/__tests__/renderers/fixture.ts +109 -0
- package/src/__tests__/renderers/html.test.ts +122 -0
- package/src/__tests__/renderers/markdown.test.ts +121 -0
- package/src/atlas.ts +56 -0
- package/src/index.ts +68 -0
- package/src/merge.ts +226 -0
- package/src/mermaid.ts +67 -0
- package/src/renderers/html.ts +250 -0
- package/src/renderers/markdown.ts +160 -0
- package/src/types.ts +145 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// ── Atlas CLI JSON output types ─────────────────────────────────────
|
|
2
|
+
|
|
3
|
+
export interface AtlasSchema {
|
|
4
|
+
schemas: AtlasSchemaEntry[]
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface AtlasSchemaEntry {
|
|
8
|
+
name: string
|
|
9
|
+
tables?: AtlasTable[]
|
|
10
|
+
views?: AtlasView[]
|
|
11
|
+
comment?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface AtlasTable {
|
|
15
|
+
name: string
|
|
16
|
+
columns: AtlasColumn[]
|
|
17
|
+
indexes?: AtlasIndex[]
|
|
18
|
+
primary_key?: AtlasPrimaryKey
|
|
19
|
+
foreign_keys?: AtlasForeignKey[]
|
|
20
|
+
checks?: AtlasCheck[]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface AtlasColumn {
|
|
24
|
+
name: string
|
|
25
|
+
type: string
|
|
26
|
+
null?: boolean
|
|
27
|
+
default?: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface AtlasIndex {
|
|
31
|
+
name: string
|
|
32
|
+
unique?: boolean
|
|
33
|
+
parts: Array<{ column: string }>
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface AtlasPrimaryKey {
|
|
37
|
+
parts: Array<{ column: string }>
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface AtlasForeignKey {
|
|
41
|
+
name: string
|
|
42
|
+
columns: string[]
|
|
43
|
+
references: {
|
|
44
|
+
table: string
|
|
45
|
+
columns: string[]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface AtlasCheck {
|
|
50
|
+
name: string
|
|
51
|
+
expr: string
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface AtlasView {
|
|
55
|
+
name: string
|
|
56
|
+
columns: AtlasColumn[]
|
|
57
|
+
definition?: string
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// ── Merged schema types (Atlas + sqldoc tags combined) ──────────────
|
|
61
|
+
|
|
62
|
+
export interface DocsRelationship {
|
|
63
|
+
from: string
|
|
64
|
+
to: string
|
|
65
|
+
label: string
|
|
66
|
+
style?: 'dashed'
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface DocsAnnotation {
|
|
70
|
+
object: string
|
|
71
|
+
text: string
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface DocsColumnEntry {
|
|
75
|
+
header: string
|
|
76
|
+
object: string
|
|
77
|
+
column?: string
|
|
78
|
+
value: string
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface MergedSchema {
|
|
82
|
+
title: string
|
|
83
|
+
generatedAt: string
|
|
84
|
+
tables: MergedTable[]
|
|
85
|
+
views: MergedView[]
|
|
86
|
+
mermaidERD: string
|
|
87
|
+
/** Extra relationships from plugins (e.g. audit trail arrows) */
|
|
88
|
+
extraRelationships: DocsRelationship[]
|
|
89
|
+
/** Table-level annotations from plugins (e.g. "RLS enabled") */
|
|
90
|
+
annotations: DocsAnnotation[]
|
|
91
|
+
/** Extra column headers contributed by plugins (appear on all tables) */
|
|
92
|
+
extraColumnHeaders: string[]
|
|
93
|
+
/** Extra column cell data from plugins, keyed by "table:column:header" */
|
|
94
|
+
extraColumnData: Map<string, string>
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface MergedTable {
|
|
98
|
+
name: string
|
|
99
|
+
description?: string
|
|
100
|
+
/** Previous name if this table was renamed via @docs.previously */
|
|
101
|
+
previously?: string
|
|
102
|
+
isGenerated: boolean
|
|
103
|
+
generatedBy?: string
|
|
104
|
+
columns: MergedColumn[]
|
|
105
|
+
indexes: AtlasIndex[]
|
|
106
|
+
primaryKey?: AtlasPrimaryKey
|
|
107
|
+
foreignKeys: AtlasForeignKey[]
|
|
108
|
+
tags: MergedTag[]
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface MergedColumn {
|
|
112
|
+
name: string
|
|
113
|
+
type: string
|
|
114
|
+
nullable: boolean
|
|
115
|
+
description?: string
|
|
116
|
+
/** Previous name if this column was renamed via @docs.previously */
|
|
117
|
+
previously?: string
|
|
118
|
+
isPrimaryKey: boolean
|
|
119
|
+
isForeignKey: boolean
|
|
120
|
+
tags: MergedTag[]
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface MergedTag {
|
|
124
|
+
namespace: string
|
|
125
|
+
tag: string | null
|
|
126
|
+
args: Record<string, unknown> | unknown[]
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface MergedView {
|
|
130
|
+
name: string
|
|
131
|
+
description?: string
|
|
132
|
+
columns: MergedColumn[]
|
|
133
|
+
tags: MergedTag[]
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// ── Plugin config ───────────────────────────────────────────────────
|
|
137
|
+
|
|
138
|
+
export interface DocsConfig {
|
|
139
|
+
/** Output file path (e.g. 'docs/schema.html') */
|
|
140
|
+
output: string
|
|
141
|
+
/** Output format */
|
|
142
|
+
format: 'markdown' | 'html'
|
|
143
|
+
/** Documentation title */
|
|
144
|
+
title?: string
|
|
145
|
+
}
|