tecton 0.4.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/src/types.d.ts ADDED
@@ -0,0 +1,207 @@
1
+ // Shapes shared by the CLI (which builds the report model) and the report's client code (which reads it).
2
+ // Checked with `npm run typecheck`; the code stays plain JavaScript with JSDoc annotations.
3
+
4
+ export type Status = 'same' | 'added' | 'removed';
5
+ export type Severity = 'error' | 'warn';
6
+
7
+ // ---------------------------------------------------------------- config (tecton.config.json)
8
+ export interface Rule {
9
+ name?: string;
10
+ from: string | string[];
11
+ to?: string | string[];
12
+ allow?: string | string[];
13
+ severity?: Severity;
14
+ message?: string;
15
+ }
16
+ export interface Config {
17
+ root?: string;
18
+ depth?: number;
19
+ cycles?: Severity | 'off';
20
+ rules?: Rule[];
21
+ modules?: Record<string, string | string[]>;
22
+ onlyListedModules?: boolean;
23
+ exclude?: string[];
24
+ aliases?: Record<string, string | string[]>;
25
+ externals?: boolean;
26
+ base?: string;
27
+ }
28
+
29
+ // ---------------------------------------------------------------- sources and graphs
30
+ export interface Source {
31
+ label?: string;
32
+ files: string[];
33
+ manifests: string[];
34
+ extras?: string[];
35
+ read(path: string): string | null;
36
+ readConfig?(name: string): string | null;
37
+ }
38
+ export interface Evidence { file: string; line: number; spec: string; target: string }
39
+ export interface GraphEdge { from: string; to: string; external: boolean; imports: Evidence[]; count: number }
40
+ export interface Graph {
41
+ modules: Map<string, { files: string[] }>;
42
+ edges: Map<string, GraphEdge>;
43
+ stats: { files: number; imports: number; unresolved: number };
44
+ root: string;
45
+ moduleOf: Map<string, string>;
46
+ fileDeps: Map<string, Map<string, number>>;
47
+ }
48
+
49
+ // ---------------------------------------------------------------- rule breaks
50
+ export interface Violation {
51
+ id: string;
52
+ kind: 'rule' | 'cycle';
53
+ rule: string;
54
+ message: string | null;
55
+ severity: Severity;
56
+ from: string;
57
+ to: string;
58
+ members?: string[];
59
+ edges: string[];
60
+ count: number;
61
+ imports: Evidence[];
62
+ /** set once base and current are compared */
63
+ status?: 'new' | 'existing' | 'fixed';
64
+ }
65
+
66
+ // ---------------------------------------------------------------- the dependency map
67
+ export interface MapNode {
68
+ id: string;
69
+ external: boolean;
70
+ status: Status;
71
+ filesBase: number;
72
+ filesCur: number;
73
+ files: { path: string; status: Status }[];
74
+ /** layout box, top-left corner */
75
+ pos?: { x: number; y: number; w: number; h: number };
76
+ /** files in this module the change edits */
77
+ touched?: number;
78
+ }
79
+ export interface MapEdge {
80
+ id: string;
81
+ from: string;
82
+ to: string;
83
+ external: boolean;
84
+ status: Status;
85
+ countBase: number;
86
+ countCur: number;
87
+ imports: Evidence[];
88
+ addedImports: Evidence[];
89
+ points?: [number, number][];
90
+ }
91
+ export interface Summary {
92
+ modules: { added: number; removed: number; total: number };
93
+ deps: { added: number; removed: number; changed: number; total: number };
94
+ violations: { newErrors: number; newWarnings: number; existing: number; fixed: number };
95
+ files: { base: number; cur: number };
96
+ touched?: { files: number; modules: number };
97
+ }
98
+
99
+ // ---------------------------------------------------------------- the system (architecture) view
100
+ export interface SysEvidence { file: string; line: number; text?: string | null; module?: string | null }
101
+ export interface EntryPoint {
102
+ key: string;
103
+ label: string;
104
+ file: string;
105
+ line: number;
106
+ methods?: string[];
107
+ cmd?: string | null;
108
+ /** cron schedules: the expression in plain words */
109
+ human?: string | null;
110
+ status?: Status;
111
+ }
112
+ export type EntryGroup = 'pages' | 'api' | 'endpoints' | 'jobs' | 'schedules';
113
+ export interface App {
114
+ id: string;
115
+ root: string;
116
+ name: string;
117
+ pkgName: string | null;
118
+ framework: string;
119
+ role: 'web' | 'mobile' | 'desktop' | 'server' | 'service';
120
+ tech: string[];
121
+ fileCount: number;
122
+ fileCountBase?: number;
123
+ modules: { name: string; files: number }[];
124
+ groups: Record<EntryGroup, EntryPoint[]>;
125
+ status?: Status;
126
+ }
127
+ export interface Store {
128
+ id: string;
129
+ name: string;
130
+ kind: string;
131
+ via: string[];
132
+ evidence: SysEvidence[];
133
+ apps: string[];
134
+ status?: Status;
135
+ }
136
+ export interface Outside {
137
+ id: string;
138
+ name: string;
139
+ kind: string;
140
+ hosts: string[];
141
+ via: string[];
142
+ evidence: SysEvidence[];
143
+ apps: string[];
144
+ status?: Status;
145
+ }
146
+ /** An outside service after base and current are compared: each host carries its own status. */
147
+ export interface OutsideDiff extends Omit<Outside, 'hosts'> {
148
+ hosts: { host: string; status: Status }[];
149
+ }
150
+ export interface Link {
151
+ id: string;
152
+ from: string;
153
+ to: string;
154
+ kind: 'users' | 'app' | 'data' | 'outside';
155
+ labels: string[];
156
+ evidence: SysEvidence[];
157
+ count: number;
158
+ status?: Status;
159
+ }
160
+ export interface SystemSnapshot {
161
+ apps: App[];
162
+ stores: Store[];
163
+ outside: Outside[];
164
+ links: Link[];
165
+ hasUsers: boolean;
166
+ }
167
+ type Delta = { total: number; added: number; removed: number };
168
+ /** The system view in the report: base and current merged, every item with a status. */
169
+ export interface System extends Omit<SystemSnapshot, 'outside'> {
170
+ outside: OutsideDiff[];
171
+ summary: { apps: Delta; entry: Delta; stores: Delta; outside: Delta } | null;
172
+ }
173
+
174
+ // ---------------------------------------------------------------- the report model (embedded as JSON)
175
+ export interface RuleInfo {
176
+ key: string;
177
+ kind: 'rule' | 'cycle';
178
+ from?: string | string[];
179
+ to?: string[] | null;
180
+ allow?: string[] | null;
181
+ severity: Severity;
182
+ message: string | null;
183
+ }
184
+ /** Files inside modules: [path, module, status (s|a|r), edited (0|1)] and imports: [fromIdx, toIdx, status, line] */
185
+ export interface FileGraph {
186
+ files: [string, string, 's' | 'a' | 'r', 0 | 1][];
187
+ deps: [number, number, 's' | 'a' | 'r', number][];
188
+ }
189
+ export interface ReportModel {
190
+ project: string;
191
+ curLabel: string;
192
+ baseLabel: string | null;
193
+ hasBase: boolean;
194
+ ruleCount: number;
195
+ generatedAt: string;
196
+ width: number;
197
+ height: number;
198
+ summary: Summary;
199
+ nodes: MapNode[];
200
+ edges: MapEdge[];
201
+ violations: Violation[];
202
+ rules: RuleInfo[];
203
+ files: FileGraph;
204
+ version: string;
205
+ system: System;
206
+ markdown?: string;
207
+ }