nestjs-doctor 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.
@@ -0,0 +1,145 @@
1
+ import { ClassDeclaration, Project, SourceFile } from "ts-morph";
2
+
3
+ //#region src/engine/module-graph.d.ts
4
+ interface ModuleNode {
5
+ classDeclaration: ClassDeclaration;
6
+ controllers: string[];
7
+ exports: string[];
8
+ filePath: string;
9
+ imports: string[];
10
+ name: string;
11
+ providers: string[];
12
+ }
13
+ interface ModuleGraph {
14
+ edges: Map<string, Set<string>>;
15
+ modules: Map<string, ModuleNode>;
16
+ } //#endregion
17
+ //#region src/engine/type-resolver.d.ts
18
+ interface ProviderInfo {
19
+ classDeclaration: ClassDeclaration;
20
+ dependencies: string[];
21
+ filePath: string;
22
+ name: string;
23
+ publicMethodCount: number;
24
+ }
25
+
26
+ //#endregion
27
+ //#region src/types/diagnostic.d.ts
28
+ type Severity = "error" | "warning" | "info";
29
+ type Category = "security" | "performance" | "correctness" | "architecture";
30
+ interface Diagnostic {
31
+ category: Category;
32
+ column: number;
33
+ filePath: string;
34
+ help: string;
35
+ line: number;
36
+ message: string;
37
+ rule: string;
38
+ severity: Severity;
39
+ }
40
+
41
+ //#endregion
42
+ //#region src/types/config.d.ts
43
+ //# sourceMappingURL=diagnostic.d.ts.map
44
+ interface RuleOverride {
45
+ enabled?: boolean;
46
+ severity?: Severity;
47
+ }
48
+ interface NestjsDoctorIgnoreConfig {
49
+ files?: string[];
50
+ rules?: string[];
51
+ }
52
+ interface NestjsDoctorConfig {
53
+ categories?: Partial<Record<Category, boolean>>;
54
+ exclude?: string[];
55
+ ignore?: NestjsDoctorIgnoreConfig;
56
+ include?: string[];
57
+ rules?: Record<string, RuleOverride | boolean>;
58
+ thresholds?: {
59
+ godModuleProviders?: number;
60
+ godModuleImports?: number;
61
+ godServiceMethods?: number;
62
+ godServiceDeps?: number;
63
+ };
64
+ }
65
+
66
+ //#endregion
67
+ //#region src/rules/types.d.ts
68
+ type RuleScope = "file" | "project";
69
+ interface RuleMeta {
70
+ category: Category;
71
+ description: string;
72
+ help: string;
73
+ id: string;
74
+ scope?: RuleScope;
75
+ severity: Severity;
76
+ }
77
+ interface RuleContext {
78
+ filePath: string;
79
+ report(diagnostic: Omit<Diagnostic, "rule" | "category" | "severity">): void;
80
+ sourceFile: SourceFile;
81
+ }
82
+ interface ProjectRuleContext {
83
+ config: NestjsDoctorConfig;
84
+ files: string[];
85
+ moduleGraph: ModuleGraph;
86
+ project: Project;
87
+ providers: Map<string, ProviderInfo>;
88
+ report(diagnostic: Omit<Diagnostic, "rule" | "category" | "severity">): void;
89
+ }
90
+ interface Rule {
91
+ check(context: RuleContext): void;
92
+ meta: RuleMeta;
93
+ }
94
+ interface ProjectRule {
95
+ check(context: ProjectRuleContext): void;
96
+ meta: RuleMeta;
97
+ }
98
+ type AnyRule = Rule | ProjectRule;
99
+
100
+ //#endregion
101
+ //#region src/rules/index.d.ts
102
+ declare function getRules(): AnyRule[];
103
+
104
+ //#endregion
105
+ //#region src/types/result.d.ts
106
+ //# sourceMappingURL=index.d.ts.map
107
+ interface Score {
108
+ label: string;
109
+ value: number;
110
+ }
111
+ interface ProjectInfo {
112
+ fileCount: number;
113
+ framework: "express" | "fastify" | null;
114
+ moduleCount: number;
115
+ name: string;
116
+ nestVersion: string | null;
117
+ orm: string | null;
118
+ }
119
+ interface DiagnoseSummary {
120
+ byCategory: Record<Category, number>;
121
+ errors: number;
122
+ info: number;
123
+ total: number;
124
+ warnings: number;
125
+ }
126
+ interface DiagnoseResult {
127
+ diagnostics: Diagnostic[];
128
+ elapsedMs: number;
129
+ project: ProjectInfo;
130
+ score: Score;
131
+ summary: DiagnoseSummary;
132
+ }
133
+
134
+ //#endregion
135
+ //#region src/api/index.d.ts
136
+ //# sourceMappingURL=result.d.ts.map
137
+ declare function diagnose(path: string, options?: {
138
+ config?: string;
139
+ }): Promise<DiagnoseResult>;
140
+
141
+ //#endregion
142
+ //# sourceMappingURL=index.d.ts.map
143
+
144
+ export { AnyRule, Category, DiagnoseResult, DiagnoseSummary, Diagnostic, NestjsDoctorConfig, ProjectInfo, ProjectRule, ProjectRuleContext, Rule, RuleContext, RuleMeta, Score, Severity, diagnose, getRules };
145
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/engine/module-graph.ts","../../src/engine/type-resolver.ts","../../src/types/diagnostic.ts","../../src/types/config.ts","../../src/rules/types.ts","../../src/rules/index.ts","../../src/types/result.ts","../../src/api/index.ts"],"sourcesContent":null,"mappings":";;;UASiB,UAAA;oBACE;EADF,WAAA,EAAU,MAAA,EAAA;EAUV,OAAA,EAAA,MAAW,EAAA;EAAA,QAAA,EAAA,MAAA;EAAA,OACR,EAAA,MAAA,EAAA;EAAG,IAAf,EAAA,MAAA;EAAG,SACW,EAAA,MAAA,EAAA;;AAAT,UAFI,WAAA,CAEJ;SADL,YAAY;WACV,YAAY;;;UChBL,YAAA;oBACE;EDGF,YAAA,EAAU,MAAA,EAAA;EAUV,QAAA,EAAA,MAAW;EAAA,IAAA,EAAA,MAAA;EAAA,iBACR,EAAA,MAAA;;;;;KEpBR,QAAA;KACA,QAAA;UAMK,UAAA;EFEA,QAAA,EEDN,QFCgB;EAUV,MAAA,EAAA,MAAW;EAAA,QAAA,EAAA,MAAA;EAAA,IACR,EAAA,MAAA;EAAG,IAAf,EAAA,MAAA;EAAG,OACW,EAAA,MAAA;EAAU,IAAtB,EAAA,MAAA;EAAG,QAAA,EENF,QFME;;;;;;UGnBI,YAAA;;EHOA,QAAA,CAAA,EGLL,QHKe;AAU3B;AAA4B,UGZX,wBAAA,CHYW;EAAA,KACR,CAAA,EAAA,MAAA,EAAA;EAAG,KAAf,CAAA,EAAA,MAAA,EAAA;;AACE,UGTO,kBAAA,CHSP;EAAG,UAAA,CAAA,EGRC,OHQD,CGRS,MHQT,CGRgB,QHQhB,EAAA,OAAA,CAAA,CAAA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AAA,MAAQ;AACpB;AAMiB,UIiBA,cAAA,CJjBU;EAAA,WAAA,EIkBb,UJlBa,EAAA;EAAA,SAChB,EAAA,MAAA;EAAQ,OAOR,EIYD,WJZC;EAAQ,KAAA,EIaX,KJbW;WIcT;;;;;;ANVkB,iBOGN,QAAA,CPHM,IAAA,EAAA,MAAA,EAAA,OACL,CADK,EAAA;EAAA,MACR,CAAA,EAAA,MAAA;CAAG,CAAA,EOIW,OPJ1B,COEsB,cAAA,CPFtB"}
@@ -0,0 +1,145 @@
1
+ import { ClassDeclaration, Project, SourceFile } from "ts-morph";
2
+
3
+ //#region src/engine/module-graph.d.ts
4
+ interface ModuleNode {
5
+ classDeclaration: ClassDeclaration;
6
+ controllers: string[];
7
+ exports: string[];
8
+ filePath: string;
9
+ imports: string[];
10
+ name: string;
11
+ providers: string[];
12
+ }
13
+ interface ModuleGraph {
14
+ edges: Map<string, Set<string>>;
15
+ modules: Map<string, ModuleNode>;
16
+ } //#endregion
17
+ //#region src/engine/type-resolver.d.ts
18
+ interface ProviderInfo {
19
+ classDeclaration: ClassDeclaration;
20
+ dependencies: string[];
21
+ filePath: string;
22
+ name: string;
23
+ publicMethodCount: number;
24
+ }
25
+
26
+ //#endregion
27
+ //#region src/types/diagnostic.d.ts
28
+ type Severity = "error" | "warning" | "info";
29
+ type Category = "security" | "performance" | "correctness" | "architecture";
30
+ interface Diagnostic {
31
+ category: Category;
32
+ column: number;
33
+ filePath: string;
34
+ help: string;
35
+ line: number;
36
+ message: string;
37
+ rule: string;
38
+ severity: Severity;
39
+ }
40
+
41
+ //#endregion
42
+ //#region src/types/config.d.ts
43
+ //# sourceMappingURL=diagnostic.d.ts.map
44
+ interface RuleOverride {
45
+ enabled?: boolean;
46
+ severity?: Severity;
47
+ }
48
+ interface NestjsDoctorIgnoreConfig {
49
+ files?: string[];
50
+ rules?: string[];
51
+ }
52
+ interface NestjsDoctorConfig {
53
+ categories?: Partial<Record<Category, boolean>>;
54
+ exclude?: string[];
55
+ ignore?: NestjsDoctorIgnoreConfig;
56
+ include?: string[];
57
+ rules?: Record<string, RuleOverride | boolean>;
58
+ thresholds?: {
59
+ godModuleProviders?: number;
60
+ godModuleImports?: number;
61
+ godServiceMethods?: number;
62
+ godServiceDeps?: number;
63
+ };
64
+ }
65
+
66
+ //#endregion
67
+ //#region src/rules/types.d.ts
68
+ type RuleScope = "file" | "project";
69
+ interface RuleMeta {
70
+ category: Category;
71
+ description: string;
72
+ help: string;
73
+ id: string;
74
+ scope?: RuleScope;
75
+ severity: Severity;
76
+ }
77
+ interface RuleContext {
78
+ filePath: string;
79
+ report(diagnostic: Omit<Diagnostic, "rule" | "category" | "severity">): void;
80
+ sourceFile: SourceFile;
81
+ }
82
+ interface ProjectRuleContext {
83
+ config: NestjsDoctorConfig;
84
+ files: string[];
85
+ moduleGraph: ModuleGraph;
86
+ project: Project;
87
+ providers: Map<string, ProviderInfo>;
88
+ report(diagnostic: Omit<Diagnostic, "rule" | "category" | "severity">): void;
89
+ }
90
+ interface Rule {
91
+ check(context: RuleContext): void;
92
+ meta: RuleMeta;
93
+ }
94
+ interface ProjectRule {
95
+ check(context: ProjectRuleContext): void;
96
+ meta: RuleMeta;
97
+ }
98
+ type AnyRule = Rule | ProjectRule;
99
+
100
+ //#endregion
101
+ //#region src/rules/index.d.ts
102
+ declare function getRules(): AnyRule[];
103
+
104
+ //#endregion
105
+ //#region src/types/result.d.ts
106
+ //# sourceMappingURL=index.d.ts.map
107
+ interface Score {
108
+ label: string;
109
+ value: number;
110
+ }
111
+ interface ProjectInfo {
112
+ fileCount: number;
113
+ framework: "express" | "fastify" | null;
114
+ moduleCount: number;
115
+ name: string;
116
+ nestVersion: string | null;
117
+ orm: string | null;
118
+ }
119
+ interface DiagnoseSummary {
120
+ byCategory: Record<Category, number>;
121
+ errors: number;
122
+ info: number;
123
+ total: number;
124
+ warnings: number;
125
+ }
126
+ interface DiagnoseResult {
127
+ diagnostics: Diagnostic[];
128
+ elapsedMs: number;
129
+ project: ProjectInfo;
130
+ score: Score;
131
+ summary: DiagnoseSummary;
132
+ }
133
+
134
+ //#endregion
135
+ //#region src/api/index.d.ts
136
+ //# sourceMappingURL=result.d.ts.map
137
+ declare function diagnose(path: string, options?: {
138
+ config?: string;
139
+ }): Promise<DiagnoseResult>;
140
+
141
+ //#endregion
142
+ //# sourceMappingURL=index.d.ts.map
143
+
144
+ export { AnyRule, Category, DiagnoseResult, DiagnoseSummary, Diagnostic, NestjsDoctorConfig, ProjectInfo, ProjectRule, ProjectRuleContext, Rule, RuleContext, RuleMeta, Score, Severity, diagnose, getRules };
145
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/engine/module-graph.ts","../../src/engine/type-resolver.ts","../../src/types/diagnostic.ts","../../src/types/config.ts","../../src/rules/types.ts","../../src/rules/index.ts","../../src/types/result.ts","../../src/api/index.ts"],"sourcesContent":null,"mappings":";;;UASiB,UAAA;oBACE;EADF,WAAA,EAAU,MAAA,EAAA;EAUV,OAAA,EAAA,MAAW,EAAA;EAAA,QAAA,EAAA,MAAA;EAAA,OACR,EAAA,MAAA,EAAA;EAAG,IAAf,EAAA,MAAA;EAAG,SACW,EAAA,MAAA,EAAA;;AAAT,UAFI,WAAA,CAEJ;SADL,YAAY;WACV,YAAY;;;UChBL,YAAA;oBACE;EDGF,YAAA,EAAU,MAAA,EAAA;EAUV,QAAA,EAAA,MAAW;EAAA,IAAA,EAAA,MAAA;EAAA,iBACR,EAAA,MAAA;;;;;KEpBR,QAAA;KACA,QAAA;UAMK,UAAA;EFEA,QAAA,EEDN,QFCgB;EAUV,MAAA,EAAA,MAAW;EAAA,QAAA,EAAA,MAAA;EAAA,IACR,EAAA,MAAA;EAAG,IAAf,EAAA,MAAA;EAAG,OACW,EAAA,MAAA;EAAU,IAAtB,EAAA,MAAA;EAAG,QAAA,EENF,QFME;;;;;;UGnBI,YAAA;;EHOA,QAAA,CAAA,EGLL,QHKe;AA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