nest-graph-inspector 0.2.8 → 0.3.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/README.md +4 -1
- package/package.json +2 -2
- package/src/{drivers/file-output.driver.d.ts → adapters/file-output.adapter.d.ts} +20 -3
- package/src/adapters/file-output.adapter.js +354 -0
- package/src/adapters/file-output.adapter.js.map +1 -0
- package/src/adapters/http-output.adapter.d.ts +25 -0
- package/src/adapters/http-output.adapter.js +94 -0
- package/src/adapters/http-output.adapter.js.map +1 -0
- package/src/adapters/http-serve.adapter.d.ts +58 -0
- package/src/adapters/http-serve.adapter.js +298 -0
- package/src/adapters/http-serve.adapter.js.map +1 -0
- package/src/{drivers/json-output.driver.d.ts → adapters/json-output.adapter.d.ts} +1 -1
- package/src/{drivers/json-output.driver.js → adapters/json-output.adapter.js} +6 -6
- package/src/adapters/json-output.adapter.js.map +1 -0
- package/src/adapters/proxy.adapter.d.ts +21 -0
- package/src/adapters/proxy.adapter.js +153 -0
- package/src/adapters/proxy.adapter.js.map +1 -0
- package/src/adapters/viewer-output.adapter.d.ts +22 -0
- package/src/adapters/viewer-output.adapter.js +82 -0
- package/src/adapters/viewer-output.adapter.js.map +1 -0
- package/src/nest-graph-inspector.module.js +22 -9
- package/src/nest-graph-inspector.module.js.map +1 -1
- package/src/nest-graph-inspector.setup.d.ts +6 -5
- package/src/nest-graph-inspector.setup.js +26 -9
- package/src/nest-graph-inspector.setup.js.map +1 -1
- package/src/nest-graph-inspector.type.d.ts +10 -0
- package/src/ports/proxy.gateway.d.ts +15 -0
- package/src/ports/proxy.gateway.js +3 -0
- package/src/ports/proxy.gateway.js.map +1 -0
- package/src/drivers/file-output.driver.js +0 -187
- package/src/drivers/file-output.driver.js.map +0 -1
- package/src/drivers/http-output.driver.d.ts +0 -16
- package/src/drivers/http-output.driver.js +0 -40
- package/src/drivers/http-output.driver.js.map +0 -1
- package/src/drivers/json-output.driver.js.map +0 -1
- package/src/drivers/viewer-output.driver.d.ts +0 -16
- package/src/drivers/viewer-output.driver.js +0 -42
- package/src/drivers/viewer-output.driver.js.map +0 -1
package/README.md
CHANGED
|
@@ -14,13 +14,16 @@ Nest Graph Inspector reads your NestJS runtime container and generates a depende
|
|
|
14
14
|
|
|
15
15
|
### Result Preview
|
|
16
16
|
|
|
17
|
-
[**Try the interactive viewer →**](https://albasyir.github.io/nest-graph-inspector/view/
|
|
17
|
+
[**Try the interactive viewer with AI Chat →**](https://albasyir.github.io/nest-graph-inspector/view/)
|
|
18
|
+
|
|
19
|
+
> "Load Example" to see result without installing it
|
|
18
20
|
|
|
19
21
|
## Features
|
|
20
22
|
|
|
21
23
|
- **Runtime introspection** — graphs are built from the actual Nest container, not static source parsing
|
|
22
24
|
- **Minimal setup** — import the module and you're done
|
|
23
25
|
- **Interactive web viewer** — zoom, pan, and inspect nodes in the browser
|
|
26
|
+
- **Chat with AI** — there's AI that help you to understand complex graph
|
|
24
27
|
- **JSON output** — structured data for programmatic use or CI integration
|
|
25
28
|
- **Markdown output** — AI-friendly graph representation
|
|
26
29
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nest-graph-inspector",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "NestJS module graph inspector for discovery and dependency analysis",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"bugs": {
|
|
35
35
|
"url": "https://github.com/albasyir/nest-graph-inspector/issues"
|
|
36
36
|
},
|
|
37
|
-
"homepage": "https://github.
|
|
37
|
+
"homepage": "https://albasyir.github.io/nest-graph-inspector",
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@nestjs/common": "^10.0.0 || ^11.0.0",
|
|
40
40
|
"@nestjs/core": "^10.0.0 || ^11.0.0"
|
|
@@ -4,24 +4,41 @@ import type { GraphOutput } from '../types/graph-output.type';
|
|
|
4
4
|
type FileOutputConfig = Extract<NestGraphInspectorOutput, {
|
|
5
5
|
type: 'markdown';
|
|
6
6
|
}>;
|
|
7
|
-
export declare class
|
|
7
|
+
export declare class FileOutputAdapter implements OutputAdapter<FileOutputConfig> {
|
|
8
|
+
private readonly markdownTitle;
|
|
9
|
+
private readonly arrowDirectionDescription;
|
|
8
10
|
private readonly nestCoreModuleName;
|
|
9
11
|
execute(graphOutput: GraphOutput, config: FileOutputConfig): Promise<{
|
|
10
12
|
message: string;
|
|
11
13
|
}>;
|
|
12
|
-
|
|
14
|
+
buildMarkdownText(graphOutput: GraphOutput): string;
|
|
13
15
|
private appendMermaidModuleGroups;
|
|
14
16
|
private appendMermaidModuleRelations;
|
|
15
17
|
private appendMermaidImportRelations;
|
|
16
18
|
private appendMermaidProviderRelations;
|
|
17
19
|
private appendMermaidControllerRelations;
|
|
18
20
|
private appendDependencyRelations;
|
|
19
|
-
private appendLegend;
|
|
20
21
|
private appendModuleSections;
|
|
22
|
+
private findProviderCircularWarnings;
|
|
23
|
+
private findModuleCircularWarnings;
|
|
24
|
+
private findUnusedImportWarnings;
|
|
25
|
+
private isModuleImportUsed;
|
|
21
26
|
private appendStringSection;
|
|
22
27
|
private appendProviderSection;
|
|
23
28
|
private appendControllerSection;
|
|
24
29
|
private appendNamedDependencyItem;
|
|
30
|
+
private appendWarningItems;
|
|
31
|
+
private appendModuleWarningBlock;
|
|
32
|
+
private addImportWarning;
|
|
33
|
+
private providerKey;
|
|
34
|
+
private providerDisplayName;
|
|
35
|
+
private providerDisplayNameFromKey;
|
|
36
|
+
private getOrCreateSet;
|
|
37
|
+
private getOrCreateMap;
|
|
38
|
+
private getOrCreateArray;
|
|
39
|
+
private createNodeMap;
|
|
40
|
+
private findCircularWarnings;
|
|
41
|
+
private findReachableKeys;
|
|
25
42
|
private toMermaidNodeId;
|
|
26
43
|
private escapeMermaidLabel;
|
|
27
44
|
private moduleGroupId;
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.FileOutputAdapter = void 0;
|
|
10
|
+
const promises_1 = require("node:fs/promises");
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const node_path_1 = require("node:path");
|
|
13
|
+
let FileOutputAdapter = class FileOutputAdapter {
|
|
14
|
+
markdownTitle = 'NestJS Dependency Graph';
|
|
15
|
+
arrowDirectionDescription = 'Arrow direction: `A --> B` means `A` depends on `B`.';
|
|
16
|
+
nestCoreModuleName = 'NestJSCoreModule';
|
|
17
|
+
async execute(graphOutput, config) {
|
|
18
|
+
const filePath = (0, node_path_1.join)(process.cwd(), config.path);
|
|
19
|
+
const markdownText = this.buildMarkdownText(graphOutput);
|
|
20
|
+
await (0, promises_1.mkdir)((0, node_path_1.dirname)(filePath), { recursive: true });
|
|
21
|
+
await (0, promises_1.writeFile)(filePath, markdownText, 'utf8');
|
|
22
|
+
return {
|
|
23
|
+
message: `Graph inspector markdown output was written to ${filePath}`,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
buildMarkdownText(graphOutput) {
|
|
27
|
+
const lines = [];
|
|
28
|
+
const moduleEntries = Object.entries(graphOutput.modules);
|
|
29
|
+
lines.push(`# ${this.markdownTitle}`);
|
|
30
|
+
lines.push('');
|
|
31
|
+
lines.push('```mermaid');
|
|
32
|
+
lines.push('graph TD');
|
|
33
|
+
lines.push('');
|
|
34
|
+
this.appendMermaidModuleGroups(lines, moduleEntries);
|
|
35
|
+
this.appendMermaidModuleRelations(lines, moduleEntries, graphOutput);
|
|
36
|
+
lines.push('```');
|
|
37
|
+
lines.push('');
|
|
38
|
+
lines.push(`> ${this.arrowDirectionDescription}`);
|
|
39
|
+
lines.push('');
|
|
40
|
+
this.appendModuleSections(lines, moduleEntries, graphOutput);
|
|
41
|
+
return lines.join('\n');
|
|
42
|
+
}
|
|
43
|
+
appendMermaidModuleGroups(lines, moduleEntries) {
|
|
44
|
+
for (const [moduleName, moduleData] of moduleEntries) {
|
|
45
|
+
lines.push(` subgraph ${this.moduleGroupId(moduleName)}["${this.escapeMermaidLabel(moduleName)}"]`);
|
|
46
|
+
for (const provider of moduleData.providers) {
|
|
47
|
+
lines.push(` ${this.providerNodeId(moduleName, provider.name)}["${this.escapeMermaidLabel(provider.name)}"]`);
|
|
48
|
+
}
|
|
49
|
+
for (const controller of moduleData.controllers) {
|
|
50
|
+
lines.push(` ${this.controllerNodeId(moduleName, controller.name)}["${this.escapeMermaidLabel(controller.name)}"]`);
|
|
51
|
+
}
|
|
52
|
+
lines.push(' end');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
appendMermaidModuleRelations(lines, moduleEntries, graphOutput) {
|
|
56
|
+
for (const [moduleName, moduleData] of moduleEntries) {
|
|
57
|
+
this.appendMermaidImportRelations(lines, moduleName, moduleData, graphOutput);
|
|
58
|
+
this.appendMermaidProviderRelations(lines, moduleName, moduleData, graphOutput);
|
|
59
|
+
this.appendMermaidControllerRelations(lines, moduleName, moduleData, graphOutput);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
appendMermaidImportRelations(lines, moduleName, moduleData, graphOutput) {
|
|
63
|
+
const importingModuleGroupId = this.moduleGroupId(moduleName);
|
|
64
|
+
if (moduleName === this.nestCoreModuleName) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
for (const importedModuleName of moduleData.imports) {
|
|
68
|
+
if (!graphOutput.modules[importedModuleName]) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const importedModuleGroupId = this.moduleGroupId(importedModuleName);
|
|
72
|
+
lines.push(` ${importingModuleGroupId} --> ${importedModuleGroupId}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
appendMermaidProviderRelations(lines, moduleName, moduleData, graphOutput) {
|
|
76
|
+
for (const provider of moduleData.providers) {
|
|
77
|
+
const providerNodeId = this.providerNodeId(moduleName, provider.name);
|
|
78
|
+
this.appendDependencyRelations(lines, providerNodeId, moduleName, provider.name, provider.dependencies, graphOutput);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
appendMermaidControllerRelations(lines, moduleName, moduleData, graphOutput) {
|
|
82
|
+
for (const controller of moduleData.controllers) {
|
|
83
|
+
const controllerNodeId = this.controllerNodeId(moduleName, controller.name);
|
|
84
|
+
this.appendDependencyRelations(lines, controllerNodeId, moduleName, controller.name, controller.dependencies, graphOutput);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
appendDependencyRelations(lines, ownerNodeId, moduleName, ownerName, dependencies, graphOutput) {
|
|
88
|
+
for (const dependency of dependencies) {
|
|
89
|
+
const dependencyModule = graphOutput.modules[dependency.providedBy.name];
|
|
90
|
+
const hasDependencyProvider = dependencyModule?.providers.some((provider) => provider.name === dependency.token);
|
|
91
|
+
if (hasDependencyProvider) {
|
|
92
|
+
const dependencyProviderNodeId = this.providerNodeId(dependency.providedBy.name, dependency.token);
|
|
93
|
+
lines.push(` ${ownerNodeId} --> ${dependencyProviderNodeId}`);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const dependencyLabel = `${dependency.providedBy.name}:${dependency.token}`;
|
|
97
|
+
const dependencyNodeId = this.dependencyNodeId(moduleName, ownerName, dependencyLabel);
|
|
98
|
+
lines.push(` ${dependencyNodeId}["${this.escapeMermaidLabel(dependencyLabel)}"]`);
|
|
99
|
+
lines.push(` ${ownerNodeId} --> ${dependencyNodeId}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
appendModuleSections(lines, moduleEntries, graphOutput) {
|
|
103
|
+
const providerCircularWarnings = this.findProviderCircularWarnings(moduleEntries, graphOutput);
|
|
104
|
+
const moduleCircularWarnings = this.findModuleCircularWarnings(moduleEntries, graphOutput);
|
|
105
|
+
const unusedImportWarnings = this.findUnusedImportWarnings(moduleEntries, graphOutput);
|
|
106
|
+
for (const [moduleName, moduleData] of moduleEntries) {
|
|
107
|
+
lines.push(`## ${moduleName}`);
|
|
108
|
+
lines.push('');
|
|
109
|
+
const moduleWarnings = moduleCircularWarnings.get(moduleName);
|
|
110
|
+
this.appendModuleWarningBlock(lines, moduleWarnings);
|
|
111
|
+
if (moduleWarnings && moduleWarnings.length > 0) {
|
|
112
|
+
lines.push('');
|
|
113
|
+
}
|
|
114
|
+
this.appendStringSection(lines, 'Imports', moduleData.imports, unusedImportWarnings.get(moduleName));
|
|
115
|
+
this.appendStringSection(lines, 'Exports', moduleData.exports);
|
|
116
|
+
this.appendProviderSection(lines, 'Providers', moduleName, moduleData.providers, providerCircularWarnings);
|
|
117
|
+
this.appendControllerSection(lines, 'Controllers', moduleData.controllers);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
findProviderCircularWarnings(moduleEntries, graphOutput) {
|
|
121
|
+
const providerKeys = new Set();
|
|
122
|
+
const providerEdges = this.createNodeMap(moduleEntries, ([moduleName]) => graphOutput.modules[moduleName].providers.map((provider) => this.providerKey(moduleName, provider.name)));
|
|
123
|
+
for (const [moduleName, moduleData] of moduleEntries) {
|
|
124
|
+
for (const provider of moduleData.providers) {
|
|
125
|
+
providerKeys.add(this.providerKey(moduleName, provider.name));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
for (const [moduleName, moduleData] of moduleEntries) {
|
|
129
|
+
for (const provider of moduleData.providers) {
|
|
130
|
+
const providerKey = this.providerKey(moduleName, provider.name);
|
|
131
|
+
const dependencies = this.getOrCreateSet(providerEdges, providerKey);
|
|
132
|
+
for (const dependency of provider.dependencies) {
|
|
133
|
+
const dependencyModule = graphOutput.modules[dependency.providedBy.name];
|
|
134
|
+
const dependencyKey = this.providerKey(dependency.providedBy.name, dependency.token);
|
|
135
|
+
const hasDependencyProvider = dependencyModule?.providers.some((candidate) => candidate.name === dependency.token);
|
|
136
|
+
if (hasDependencyProvider && providerKeys.has(dependencyKey)) {
|
|
137
|
+
dependencies.add(dependencyKey);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return this.findCircularWarnings(providerEdges, (providerKey) => this.providerDisplayNameFromKey(providerKey));
|
|
143
|
+
}
|
|
144
|
+
findModuleCircularWarnings(moduleEntries, graphOutput) {
|
|
145
|
+
const moduleEdges = this.createNodeMap(moduleEntries, ([moduleName]) => [
|
|
146
|
+
moduleName,
|
|
147
|
+
]);
|
|
148
|
+
for (const [moduleName, moduleData] of moduleEntries) {
|
|
149
|
+
const imports = this.getOrCreateSet(moduleEdges, moduleName);
|
|
150
|
+
for (const importedModuleName of moduleData.imports) {
|
|
151
|
+
if (!graphOutput.modules[importedModuleName]) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
imports.add(importedModuleName);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return this.findCircularWarnings(moduleEdges, (moduleName) => moduleName);
|
|
158
|
+
}
|
|
159
|
+
findUnusedImportWarnings(moduleEntries, graphOutput) {
|
|
160
|
+
const unusedImportWarnings = new Map();
|
|
161
|
+
for (const [moduleName, moduleData] of moduleEntries) {
|
|
162
|
+
if (moduleName === graphOutput.root ||
|
|
163
|
+
moduleName === this.nestCoreModuleName) {
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
const dependencies = [
|
|
167
|
+
...moduleData.providers.flatMap((provider) => provider.dependencies),
|
|
168
|
+
...moduleData.controllers.flatMap((controller) => controller.dependencies),
|
|
169
|
+
];
|
|
170
|
+
for (const importedModuleName of moduleData.imports) {
|
|
171
|
+
const importedModule = graphOutput.modules[importedModuleName];
|
|
172
|
+
if (!importedModule) {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
if (this.isModuleImportUsed(moduleData, importedModuleName, importedModule, dependencies)) {
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
this.addImportWarning(unusedImportWarnings, moduleName, importedModuleName, 'unused import module');
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return unusedImportWarnings;
|
|
182
|
+
}
|
|
183
|
+
isModuleImportUsed(moduleData, importedModuleName, importedModule, dependencies) {
|
|
184
|
+
if (moduleData.exports.includes(importedModuleName)) {
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
return dependencies.some((dependency) => {
|
|
188
|
+
if (dependency.providedBy.name === importedModuleName) {
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
if (importedModule.exports.includes(dependency.providedBy.name)) {
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
return importedModule.exports.includes(dependency.token);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
appendStringSection(lines, title, values, warnings = new Map()) {
|
|
198
|
+
if (values.length === 0) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
lines.push(`### ${title}`);
|
|
202
|
+
for (const value of values) {
|
|
203
|
+
lines.push(`- ${value}`);
|
|
204
|
+
this.appendWarningItems(lines, warnings.get(value), ' ');
|
|
205
|
+
}
|
|
206
|
+
lines.push('');
|
|
207
|
+
}
|
|
208
|
+
appendProviderSection(lines, title, moduleName, providers, circularWarnings) {
|
|
209
|
+
if (providers.length === 0) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
lines.push(`### ${title}`);
|
|
213
|
+
for (const provider of providers) {
|
|
214
|
+
this.appendNamedDependencyItem(lines, provider.name, provider.dependencies, circularWarnings.get(this.providerKey(moduleName, provider.name)));
|
|
215
|
+
}
|
|
216
|
+
lines.push('');
|
|
217
|
+
}
|
|
218
|
+
appendControllerSection(lines, title, controllers) {
|
|
219
|
+
if (controllers.length === 0) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
lines.push(`### ${title}`);
|
|
223
|
+
for (const controller of controllers) {
|
|
224
|
+
this.appendNamedDependencyItem(lines, controller.name, controller.dependencies);
|
|
225
|
+
}
|
|
226
|
+
lines.push('');
|
|
227
|
+
}
|
|
228
|
+
appendNamedDependencyItem(lines, name, dependencies, warnings = []) {
|
|
229
|
+
lines.push(`- ${name}`);
|
|
230
|
+
this.appendWarningItems(lines, warnings, ' ');
|
|
231
|
+
for (const dependency of dependencies) {
|
|
232
|
+
lines.push(` - depends on ${dependency.token} from ${dependency.providedBy.name}`);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
appendWarningItems(lines, warnings = [], indent = '') {
|
|
236
|
+
for (const warning of warnings) {
|
|
237
|
+
lines.push(`${indent}- Warning: ${warning}`);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
appendModuleWarningBlock(lines, warnings = []) {
|
|
241
|
+
if (warnings.length === 0) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
lines.push('> warnings');
|
|
245
|
+
for (const warning of warnings) {
|
|
246
|
+
lines.push(`> - ${warning}`);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
addImportWarning(warnings, moduleName, importedModuleName, warning) {
|
|
250
|
+
const moduleWarnings = this.getOrCreateMap(warnings, moduleName);
|
|
251
|
+
const importWarnings = this.getOrCreateArray(moduleWarnings, importedModuleName);
|
|
252
|
+
importWarnings.push(warning);
|
|
253
|
+
}
|
|
254
|
+
providerKey(moduleName, providerName) {
|
|
255
|
+
return `${moduleName}:${providerName}`;
|
|
256
|
+
}
|
|
257
|
+
providerDisplayName(moduleName, providerName) {
|
|
258
|
+
return `${providerName} from ${moduleName}`;
|
|
259
|
+
}
|
|
260
|
+
providerDisplayNameFromKey(providerKey) {
|
|
261
|
+
const separatorIndex = providerKey.indexOf(':');
|
|
262
|
+
return this.providerDisplayName(providerKey.slice(0, separatorIndex), providerKey.slice(separatorIndex + 1));
|
|
263
|
+
}
|
|
264
|
+
getOrCreateSet(map, key) {
|
|
265
|
+
const existingValue = map.get(key);
|
|
266
|
+
if (existingValue) {
|
|
267
|
+
return existingValue;
|
|
268
|
+
}
|
|
269
|
+
const value = new Set();
|
|
270
|
+
map.set(key, value);
|
|
271
|
+
return value;
|
|
272
|
+
}
|
|
273
|
+
getOrCreateMap(map, key) {
|
|
274
|
+
const existingValue = map.get(key);
|
|
275
|
+
if (existingValue) {
|
|
276
|
+
return existingValue;
|
|
277
|
+
}
|
|
278
|
+
const value = new Map();
|
|
279
|
+
map.set(key, value);
|
|
280
|
+
return value;
|
|
281
|
+
}
|
|
282
|
+
getOrCreateArray(map, key) {
|
|
283
|
+
const existingValue = map.get(key);
|
|
284
|
+
if (existingValue) {
|
|
285
|
+
return existingValue;
|
|
286
|
+
}
|
|
287
|
+
const value = [];
|
|
288
|
+
map.set(key, value);
|
|
289
|
+
return value;
|
|
290
|
+
}
|
|
291
|
+
createNodeMap(values, getKeys) {
|
|
292
|
+
const map = new Map();
|
|
293
|
+
for (const value of values) {
|
|
294
|
+
for (const key of getKeys(value)) {
|
|
295
|
+
this.getOrCreateSet(map, key);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
return map;
|
|
299
|
+
}
|
|
300
|
+
findCircularWarnings(graph, displayName) {
|
|
301
|
+
const circularWarnings = new Map();
|
|
302
|
+
const reachableKeys = new Map();
|
|
303
|
+
for (const source of graph.keys()) {
|
|
304
|
+
reachableKeys.set(source, this.findReachableKeys(source, graph));
|
|
305
|
+
}
|
|
306
|
+
for (const [source, targets] of graph) {
|
|
307
|
+
const warnings = [...targets]
|
|
308
|
+
.filter((target) => source === target || reachableKeys.get(target)?.has(source))
|
|
309
|
+
.map((target) => `circular dependency with ${displayName(target)}`);
|
|
310
|
+
if (warnings.length > 0) {
|
|
311
|
+
circularWarnings.set(source, warnings);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return circularWarnings;
|
|
315
|
+
}
|
|
316
|
+
findReachableKeys(source, graph) {
|
|
317
|
+
const reachableKeys = new Set();
|
|
318
|
+
const pendingKeys = [...(graph.get(source) ?? [])];
|
|
319
|
+
while (pendingKeys.length > 0) {
|
|
320
|
+
const currentKey = pendingKeys.pop();
|
|
321
|
+
if (!currentKey || reachableKeys.has(currentKey)) {
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
reachableKeys.add(currentKey);
|
|
325
|
+
for (const nextKey of graph.get(currentKey) ?? []) {
|
|
326
|
+
pendingKeys.push(nextKey);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return reachableKeys;
|
|
330
|
+
}
|
|
331
|
+
toMermaidNodeId(value) {
|
|
332
|
+
return value.replace(/[^a-zA-Z0-9_]/g, '_');
|
|
333
|
+
}
|
|
334
|
+
escapeMermaidLabel(value) {
|
|
335
|
+
return value.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
336
|
+
}
|
|
337
|
+
moduleGroupId(moduleName) {
|
|
338
|
+
return this.toMermaidNodeId(`module-group:${moduleName}`);
|
|
339
|
+
}
|
|
340
|
+
providerNodeId(moduleName, providerName) {
|
|
341
|
+
return this.toMermaidNodeId(`provider:${moduleName}:${providerName}`);
|
|
342
|
+
}
|
|
343
|
+
controllerNodeId(moduleName, controllerName) {
|
|
344
|
+
return this.toMermaidNodeId(`controller:${moduleName}:${controllerName}`);
|
|
345
|
+
}
|
|
346
|
+
dependencyNodeId(moduleName, ownerName, dependencyName) {
|
|
347
|
+
return this.toMermaidNodeId(`dependency:${moduleName}:${ownerName}:${dependencyName}`);
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
exports.FileOutputAdapter = FileOutputAdapter;
|
|
351
|
+
exports.FileOutputAdapter = FileOutputAdapter = __decorate([
|
|
352
|
+
(0, common_1.Injectable)()
|
|
353
|
+
], FileOutputAdapter);
|
|
354
|
+
//# sourceMappingURL=file-output.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-output.adapter.js","sourceRoot":"","sources":["../../../../../libs/nest-graph-inspector/src/adapters/file-output.adapter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+CAAoD;AACpD,2CAA4C;AAC5C,yCAA0C;AAgBnC,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IACX,aAAa,GAAG,yBAAyB,CAAC;IAC1C,yBAAyB,GACxC,sDAAsD,CAAC;IACxC,kBAAkB,GAAG,kBAAkB,CAAC;IAEzD,KAAK,CAAC,OAAO,CACX,WAAwB,EACxB,MAAwB;QAExB,MAAM,QAAQ,GAAG,IAAA,gBAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QAClD,MAAM,YAAY,GAAG,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;QAEzD,MAAM,IAAA,gBAAK,EAAC,IAAA,mBAAO,EAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACpD,MAAM,IAAA,oBAAS,EAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;QAEhD,OAAO;YACL,OAAO,EAAE,kDAAkD,QAAQ,EAAE;SACtE,CAAC;IACJ,CAAC;IAED,iBAAiB,CAAC,WAAwB;QACxC,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAE1D,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;QACtC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI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,GAAE;GACA,iBAAiB,CAwpB7B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { OutputAdapter } from '../ports/output.adapter';
|
|
2
|
+
import { NestGraphInspectorOutput } from '../nest-graph-inspector.type';
|
|
3
|
+
import type { GraphOutput } from '../types/graph-output.type';
|
|
4
|
+
import { FileOutputAdapter } from './file-output.adapter';
|
|
5
|
+
import { HttpServeAdapter } from './http-serve.adapter';
|
|
6
|
+
type HttpOutputConfig = Extract<NestGraphInspectorOutput, {
|
|
7
|
+
type: 'http';
|
|
8
|
+
}>;
|
|
9
|
+
interface HttpOutputInternalOptions {
|
|
10
|
+
httpAdapter?: HttpServeAdapter;
|
|
11
|
+
}
|
|
12
|
+
export declare class HttpOutputAdapter implements OutputAdapter<HttpOutputConfig> {
|
|
13
|
+
private readonly fileOutputAdapter;
|
|
14
|
+
private readonly httpServeAdapter;
|
|
15
|
+
private static readonly inspectorEndpointInfo;
|
|
16
|
+
static readonly defaultConfig: Readonly<Required<Pick<HttpOutputConfig, 'host' | 'port'>>>;
|
|
17
|
+
constructor(fileOutputAdapter: FileOutputAdapter, httpServeAdapter: HttpServeAdapter);
|
|
18
|
+
execute(graphOutput: GraphOutput, config: HttpOutputConfig & HttpOutputInternalOptions): Promise<{
|
|
19
|
+
message: string;
|
|
20
|
+
}>;
|
|
21
|
+
normalizePath(path?: string): string;
|
|
22
|
+
private get httpOrigin();
|
|
23
|
+
private joinPath;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var HttpOutputAdapter_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.HttpOutputAdapter = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const file_output_adapter_1 = require("./file-output.adapter");
|
|
16
|
+
const http_serve_adapter_1 = require("./http-serve.adapter");
|
|
17
|
+
let HttpOutputAdapter = class HttpOutputAdapter {
|
|
18
|
+
static { HttpOutputAdapter_1 = this; }
|
|
19
|
+
fileOutputAdapter;
|
|
20
|
+
httpServeAdapter;
|
|
21
|
+
static inspectorEndpointInfo = {
|
|
22
|
+
for: 'nest-graph-inspector',
|
|
23
|
+
};
|
|
24
|
+
static defaultConfig = {
|
|
25
|
+
host: 'localhost',
|
|
26
|
+
port: 53371,
|
|
27
|
+
};
|
|
28
|
+
constructor(fileOutputAdapter, httpServeAdapter) {
|
|
29
|
+
this.fileOutputAdapter = fileOutputAdapter;
|
|
30
|
+
this.httpServeAdapter = httpServeAdapter;
|
|
31
|
+
}
|
|
32
|
+
async execute(graphOutput, config) {
|
|
33
|
+
const origin = config.origin ?? this.httpOrigin;
|
|
34
|
+
const path = this.normalizePath(config.path);
|
|
35
|
+
const informationOutputPath = this.joinPath(path, 'information.json');
|
|
36
|
+
const jsonOutputPath = this.joinPath(path, 'output.json');
|
|
37
|
+
const markdownOutputPath = this.joinPath(path, 'output.md');
|
|
38
|
+
const isReuseHttpAdapter = !!config.httpAdapter;
|
|
39
|
+
const httpAdapter = config.httpAdapter ?? this.httpServeAdapter;
|
|
40
|
+
const registration = httpAdapter.register({
|
|
41
|
+
origin,
|
|
42
|
+
host: config.host,
|
|
43
|
+
port: config.port,
|
|
44
|
+
}, [
|
|
45
|
+
httpAdapter.get(informationOutputPath, () => HttpOutputAdapter_1.inspectorEndpointInfo, {
|
|
46
|
+
responseHeaders: {
|
|
47
|
+
'content-type': 'application/json; charset=utf-8',
|
|
48
|
+
},
|
|
49
|
+
}),
|
|
50
|
+
httpAdapter.get(jsonOutputPath, () => graphOutput, {
|
|
51
|
+
responseHeaders: {
|
|
52
|
+
'content-type': 'application/json; charset=utf-8',
|
|
53
|
+
},
|
|
54
|
+
}),
|
|
55
|
+
httpAdapter.get(markdownOutputPath, () => this.fileOutputAdapter.buildMarkdownText(graphOutput), {
|
|
56
|
+
responseHeaders: {
|
|
57
|
+
'content-type': 'text/markdown; charset=utf-8',
|
|
58
|
+
},
|
|
59
|
+
}),
|
|
60
|
+
]);
|
|
61
|
+
if (!isReuseHttpAdapter) {
|
|
62
|
+
try {
|
|
63
|
+
await httpAdapter.serve();
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
httpAdapter.close(registration.origin);
|
|
67
|
+
throw err;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const informationOutputUrl = new URL(informationOutputPath, registration.origin);
|
|
71
|
+
const jsonOutputUrl = new URL(jsonOutputPath, registration.origin);
|
|
72
|
+
const markdownOutputUrl = new URL(markdownOutputPath, registration.origin);
|
|
73
|
+
return {
|
|
74
|
+
message: `Graph inspector HTTP endpoints are installed at ${informationOutputUrl}, ${jsonOutputUrl}, and ${markdownOutputUrl}`,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
normalizePath(path = '/__nest-graph-inspector') {
|
|
78
|
+
return path.startsWith('/') ? path : `/${path}`;
|
|
79
|
+
}
|
|
80
|
+
get httpOrigin() {
|
|
81
|
+
const { host, port } = HttpOutputAdapter_1.defaultConfig;
|
|
82
|
+
return `http://${host}:${port}`;
|
|
83
|
+
}
|
|
84
|
+
joinPath(basePath, childPath) {
|
|
85
|
+
return `${basePath.replace(/\/$/, '')}/${childPath.replace(/^\//, '')}`;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
exports.HttpOutputAdapter = HttpOutputAdapter;
|
|
89
|
+
exports.HttpOutputAdapter = HttpOutputAdapter = HttpOutputAdapter_1 = __decorate([
|
|
90
|
+
(0, common_1.Injectable)(),
|
|
91
|
+
__metadata("design:paramtypes", [file_output_adapter_1.FileOutputAdapter,
|
|
92
|
+
http_serve_adapter_1.HttpServeAdapter])
|
|
93
|
+
], HttpOutputAdapter);
|
|
94
|
+
//# sourceMappingURL=http-output.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-output.adapter.js","sourceRoot":"","sources":["../../../../../libs/nest-graph-inspector/src/adapters/http-output.adapter.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAA4C;AAI5C,+DAA0D;AAC1D,6DAAwD;AAiBjD,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;;IAaT;IACA;IAbX,MAAM,CAAU,qBAAqB,GAAG;QAC9C,GAAG,EAAE,sBAAsB;KAC5B,CAAC;IAEF,MAAM,CAAU,aAAa,GAEzB;QACF,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,KAAK;KACZ,CAAC;IAEF,YACmB,iBAAoC,EACpC,gBAAkC;QADlC,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,qBAAgB,GAAhB,gBAAgB,CAAkB;IAClD,CAAC;IAEJ,KAAK,CAAC,OAAO,CACX,WAAwB,EACxB,MAAoD;QAEpD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC,UAAU,CAAC;QAChD,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC7C,MAAM,qBAAqB,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;QACtE,MAAM,cAAc,GAAG,IAA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,CAAC;QACF,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,cAAc,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;QACnE,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,kBAAkB,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;QAE3E,OAAO;YACL,OAAO,EAAE,mDAAmD,oBAAoB,KAAK,aAAa,SAAS,iBAAiB,EAAE;SAC/H,CAAC;IACJ,CAAC;IAED,aAAa,CAAC,IAAI,GAAG,yBAAyB;QAC5C,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;IAClD,CAAC;IAED,IAAY,UAAU;QACpB,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,mBAAiB,CAAC,aAAa,CAAC;QAEvD,OAAO,UAAU,IAAI,IAAI,IAAI,EAAE,CAAC;IAClC,CAAC;IAEO,QAAQ,CAAC,QAAgB,EAAE,SAAiB;QAClD,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC;IAC1E,CAAC;;AAhGU,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;qCAc2B,uCAAiB;QAClB,qCAAgB;GAd1C,iBAAiB,CAiG7B"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import http from 'node:http';
|
|
2
|
+
import { OnModuleDestroy } from '@nestjs/common';
|
|
3
|
+
export type HttpServeOptions = {
|
|
4
|
+
origin?: string;
|
|
5
|
+
host?: string;
|
|
6
|
+
port?: number;
|
|
7
|
+
};
|
|
8
|
+
export type HttpServeRoute = {
|
|
9
|
+
type: string;
|
|
10
|
+
path: string;
|
|
11
|
+
callback?: (context: HttpServeRequest) => unknown | Promise<unknown>;
|
|
12
|
+
rawCallback?: (req: http.IncomingMessage, res: http.ServerResponse) => void | Promise<void>;
|
|
13
|
+
requestHeaders?: http.OutgoingHttpHeaders;
|
|
14
|
+
responseHeaders?: http.OutgoingHttpHeaders;
|
|
15
|
+
contentType?: string;
|
|
16
|
+
statusCode?: number;
|
|
17
|
+
};
|
|
18
|
+
export type HttpServeRequest = {
|
|
19
|
+
request: http.IncomingMessage;
|
|
20
|
+
headers: http.IncomingHttpHeaders;
|
|
21
|
+
};
|
|
22
|
+
export type HttpServeResponse = {
|
|
23
|
+
statusCode?: number;
|
|
24
|
+
contentType?: string;
|
|
25
|
+
headers?: http.OutgoingHttpHeaders;
|
|
26
|
+
body?: unknown;
|
|
27
|
+
};
|
|
28
|
+
export declare class HttpServeAdapter implements OnModuleDestroy {
|
|
29
|
+
private readonly servers;
|
|
30
|
+
register(options: HttpServeOptions, routes: HttpServeRoute[]): {
|
|
31
|
+
origin: string;
|
|
32
|
+
};
|
|
33
|
+
get(path: string, callback: HttpServeRoute['callback'], options?: Omit<HttpServeRoute, 'type' | 'path' | 'callback'>): HttpServeRoute;
|
|
34
|
+
post(path: string, callback: HttpServeRoute['callback'], options?: Omit<HttpServeRoute, 'type' | 'path' | 'callback'>): HttpServeRoute;
|
|
35
|
+
all(path: string, rawCallback: NonNullable<HttpServeRoute['rawCallback']>, options?: Omit<HttpServeRoute, 'type' | 'path' | 'rawCallback'>): HttpServeRoute;
|
|
36
|
+
serve(): Promise<void>;
|
|
37
|
+
close(origin?: string): void;
|
|
38
|
+
onModuleDestroy(): void;
|
|
39
|
+
private serverState;
|
|
40
|
+
private serveState;
|
|
41
|
+
private listen;
|
|
42
|
+
private handleRequest;
|
|
43
|
+
private route;
|
|
44
|
+
private wildcardPathCandidates;
|
|
45
|
+
private routeKey;
|
|
46
|
+
private sendResult;
|
|
47
|
+
private normalizeResponse;
|
|
48
|
+
private isHttpServeResponse;
|
|
49
|
+
private serializeBody;
|
|
50
|
+
private sendText;
|
|
51
|
+
private requestHeadersMatch;
|
|
52
|
+
private headerValue;
|
|
53
|
+
private contentTypeHeader;
|
|
54
|
+
private setCorsHeaders;
|
|
55
|
+
private resolveDynamicPort;
|
|
56
|
+
private normalizeOrigin;
|
|
57
|
+
private normalizePath;
|
|
58
|
+
}
|