nest-graph-inspector 0.2.9 → 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.
Files changed (39) hide show
  1. package/README.md +20 -11
  2. package/package.json +1 -1
  3. package/src/{drivers/file-output.driver.d.ts → adapters/file-output.adapter.d.ts} +17 -2
  4. package/src/adapters/file-output.adapter.js +284 -0
  5. package/src/adapters/file-output.adapter.js.map +1 -0
  6. package/src/adapters/http-output.adapter.d.ts +25 -0
  7. package/src/adapters/http-output.adapter.js +94 -0
  8. package/src/adapters/http-output.adapter.js.map +1 -0
  9. package/src/adapters/http-serve.adapter.d.ts +58 -0
  10. package/src/adapters/http-serve.adapter.js +298 -0
  11. package/src/adapters/http-serve.adapter.js.map +1 -0
  12. package/src/{drivers/json-output.driver.d.ts → adapters/json-output.adapter.d.ts} +1 -1
  13. package/src/{drivers/json-output.driver.js → adapters/json-output.adapter.js} +6 -6
  14. package/src/adapters/json-output.adapter.js.map +1 -0
  15. package/src/adapters/proxy.adapter.d.ts +21 -0
  16. package/src/adapters/proxy.adapter.js +153 -0
  17. package/src/adapters/proxy.adapter.js.map +1 -0
  18. package/src/adapters/viewer-output.adapter.d.ts +22 -0
  19. package/src/adapters/viewer-output.adapter.js +82 -0
  20. package/src/adapters/viewer-output.adapter.js.map +1 -0
  21. package/src/nest-graph-inspector.module.js +22 -9
  22. package/src/nest-graph-inspector.module.js.map +1 -1
  23. package/src/nest-graph-inspector.setup.d.ts +19 -5
  24. package/src/nest-graph-inspector.setup.js +217 -9
  25. package/src/nest-graph-inspector.setup.js.map +1 -1
  26. package/src/nest-graph-inspector.type.d.ts +10 -0
  27. package/src/ports/proxy.gateway.d.ts +15 -0
  28. package/src/ports/proxy.gateway.js +3 -0
  29. package/src/ports/proxy.gateway.js.map +1 -0
  30. package/src/types/graph-output.type.d.ts +27 -0
  31. package/src/drivers/file-output.driver.js +0 -187
  32. package/src/drivers/file-output.driver.js.map +0 -1
  33. package/src/drivers/http-output.driver.d.ts +0 -19
  34. package/src/drivers/http-output.driver.js +0 -62
  35. package/src/drivers/http-output.driver.js.map +0 -1
  36. package/src/drivers/json-output.driver.js.map +0 -1
  37. package/src/drivers/viewer-output.driver.d.ts +0 -16
  38. package/src/drivers/viewer-output.driver.js +0 -42
  39. package/src/drivers/viewer-output.driver.js.map +0 -1
@@ -1,187 +0,0 @@
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.FileOutputDriver = 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 FileOutputDriver = class FileOutputDriver {
14
- nestCoreModuleName = 'NestJSCoreModule';
15
- async execute(graphOutput, config) {
16
- const filePath = (0, node_path_1.join)(process.cwd(), config.path);
17
- const markdownText = this.buildMarkdownText(graphOutput);
18
- await (0, promises_1.mkdir)((0, node_path_1.dirname)(filePath), { recursive: true });
19
- await (0, promises_1.writeFile)(filePath, markdownText, 'utf8');
20
- return {
21
- message: `Graph inspector markdown output was written to ${filePath}`,
22
- };
23
- }
24
- buildMarkdownText(graphOutput) {
25
- const lines = [];
26
- const moduleEntries = Object.entries(graphOutput.modules);
27
- lines.push('# NestJS Dependency Graph');
28
- lines.push('');
29
- lines.push(`Root Module: \`${graphOutput.root}\``);
30
- lines.push(`Version: \`${graphOutput.version}\``);
31
- lines.push('');
32
- lines.push('```mermaid');
33
- lines.push('graph TD');
34
- lines.push('');
35
- this.appendMermaidModuleGroups(lines, moduleEntries);
36
- this.appendMermaidModuleRelations(lines, moduleEntries, graphOutput);
37
- lines.push('```');
38
- lines.push('');
39
- this.appendLegend(lines);
40
- this.appendModuleSections(lines, moduleEntries);
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 moduleGroupId = 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
- lines.push(` ${this.moduleGroupId(importedModuleName)} --> ${moduleGroupId}`);
72
- }
73
- }
74
- appendMermaidProviderRelations(lines, moduleName, moduleData, graphOutput) {
75
- for (const provider of moduleData.providers) {
76
- const providerNodeId = this.providerNodeId(moduleName, provider.name);
77
- this.appendDependencyRelations(lines, providerNodeId, moduleName, provider.name, provider.dependencies, graphOutput);
78
- }
79
- }
80
- appendMermaidControllerRelations(lines, moduleName, moduleData, graphOutput) {
81
- for (const controller of moduleData.controllers) {
82
- const controllerNodeId = this.controllerNodeId(moduleName, controller.name);
83
- this.appendDependencyRelations(lines, controllerNodeId, moduleName, controller.name, controller.dependencies, graphOutput);
84
- }
85
- }
86
- appendDependencyRelations(lines, ownerNodeId, moduleName, ownerName, dependencies, graphOutput) {
87
- for (const dep of dependencies) {
88
- const targetModule = graphOutput.modules[dep.providedBy.name];
89
- const hasProvider = targetModule?.providers.some((p) => p.name === dep.token);
90
- if (hasProvider) {
91
- lines.push(` ${this.providerNodeId(dep.providedBy.name, dep.token)} --> ${ownerNodeId}`);
92
- continue;
93
- }
94
- const depLabel = `${dep.providedBy.name}:${dep.token}`;
95
- const dependencyNodeId = this.dependencyNodeId(moduleName, ownerName, depLabel);
96
- lines.push(` ${dependencyNodeId}["${this.escapeMermaidLabel(depLabel)}"]`);
97
- lines.push(` ${dependencyNodeId} --> ${ownerNodeId}`);
98
- }
99
- }
100
- appendLegend(lines) {
101
- lines.push('## Legend');
102
- lines.push('');
103
- lines.push('- Each module is rendered as a Mermaid group');
104
- lines.push('- Inside each module group: providers and controllers owned by that module');
105
- lines.push('- Arrows between groups: imported module points to importing module');
106
- lines.push('- Arrows point from dependency/owned node to the dependent/owner node');
107
- lines.push('- Providers and controllers are grouped inside their owning module without extra ownership arrows');
108
- lines.push('- Internal and external runtime dependencies point to the provider/controller that uses them');
109
- lines.push('- Standalone dependency nodes are only used when a dependency cannot be resolved to a provider node');
110
- lines.push('');
111
- }
112
- appendModuleSections(lines, moduleEntries) {
113
- for (const [moduleName, moduleData] of moduleEntries) {
114
- lines.push(`## ${moduleName}`);
115
- lines.push('');
116
- this.appendStringSection(lines, 'Imports', moduleData.imports);
117
- this.appendStringSection(lines, 'Exports', moduleData.exports);
118
- this.appendProviderSection(lines, 'Providers', moduleData.providers);
119
- this.appendControllerSection(lines, 'Controllers', moduleData.controllers);
120
- }
121
- }
122
- appendStringSection(lines, title, values) {
123
- lines.push(`### ${title}`);
124
- if (values.length === 0) {
125
- lines.push('- None');
126
- lines.push('');
127
- return;
128
- }
129
- for (const value of values) {
130
- lines.push(`- ${value}`);
131
- }
132
- lines.push('');
133
- }
134
- appendProviderSection(lines, title, providers) {
135
- lines.push(`### ${title}`);
136
- if (providers.length === 0) {
137
- lines.push('- None');
138
- lines.push('');
139
- return;
140
- }
141
- for (const provider of providers) {
142
- this.appendNamedDependencyItem(lines, provider.name, provider.dependencies);
143
- }
144
- lines.push('');
145
- }
146
- appendControllerSection(lines, title, controllers) {
147
- lines.push(`### ${title}`);
148
- if (controllers.length === 0) {
149
- lines.push('- None');
150
- lines.push('');
151
- return;
152
- }
153
- for (const controller of controllers) {
154
- this.appendNamedDependencyItem(lines, controller.name, controller.dependencies);
155
- }
156
- lines.push('');
157
- }
158
- appendNamedDependencyItem(lines, name, dependencies) {
159
- lines.push(`- ${name}`);
160
- for (const dep of dependencies) {
161
- lines.push(` - depends on: ${dep.providedBy.name}:${dep.token}`);
162
- }
163
- }
164
- toMermaidNodeId(value) {
165
- return value.replace(/[^a-zA-Z0-9_]/g, '_');
166
- }
167
- escapeMermaidLabel(value) {
168
- return value.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
169
- }
170
- moduleGroupId(moduleName) {
171
- return this.toMermaidNodeId(`module-group:${moduleName}`);
172
- }
173
- providerNodeId(moduleName, providerName) {
174
- return this.toMermaidNodeId(`provider:${moduleName}:${providerName}`);
175
- }
176
- controllerNodeId(moduleName, controllerName) {
177
- return this.toMermaidNodeId(`controller:${moduleName}:${controllerName}`);
178
- }
179
- dependencyNodeId(moduleName, ownerName, dependencyName) {
180
- return this.toMermaidNodeId(`dependency:${moduleName}:${ownerName}:${dependencyName}`);
181
- }
182
- };
183
- exports.FileOutputDriver = FileOutputDriver;
184
- exports.FileOutputDriver = FileOutputDriver = __decorate([
185
- (0, common_1.Injectable)()
186
- ], FileOutputDriver);
187
- //# sourceMappingURL=file-output.driver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-output.driver.js","sourceRoot":"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AgB,CACtB,UAAkB,EAClB,SAAiB,EACjB,cAAsB;QAEtB,OAAO,IAAI,CAAC,eAAe,CACzB,cAAc,UAAU,IAAI,SAAS,IAAI,cAAc,EAAE,CAC1D,CAAC;IACJ,CAAC;CACF,CAAA;AA1VY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;GACA,gBAAgB,CA0V5B"}
@@ -1,19 +0,0 @@
1
- import { HttpAdapterHost } from '@nestjs/core';
2
- import { OutputAdapter } from '../ports/output.adapter';
3
- import { NestGraphInspectorOutput } from '../nest-graph-inspector.type';
4
- import type { GraphOutput } from '../types/graph-output.type';
5
- import { FileOutputDriver } from './file-output.driver';
6
- type HttpOutputConfig = Extract<NestGraphInspectorOutput, {
7
- type: 'http';
8
- }>;
9
- export declare class HttpOutputDriver implements OutputAdapter<HttpOutputConfig> {
10
- private readonly adapterHost;
11
- private readonly fileOutputDriver;
12
- constructor(adapterHost: HttpAdapterHost, fileOutputDriver: FileOutputDriver);
13
- execute(graphOutput: GraphOutput, config: HttpOutputConfig): Promise<{
14
- message: string;
15
- }>;
16
- normalizePath(path?: string): string;
17
- private joinPath;
18
- }
19
- export {};
@@ -1,62 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.HttpOutputDriver = void 0;
13
- const common_1 = require("@nestjs/common");
14
- const core_1 = require("@nestjs/core");
15
- const file_output_driver_1 = require("./file-output.driver");
16
- const INSPECTOR_ENDPOINT_INFO = { for: 'nest-graph-inspector' };
17
- let HttpOutputDriver = class HttpOutputDriver {
18
- adapterHost;
19
- fileOutputDriver;
20
- constructor(adapterHost, fileOutputDriver) {
21
- this.adapterHost = adapterHost;
22
- this.fileOutputDriver = fileOutputDriver;
23
- }
24
- execute(graphOutput, config) {
25
- const httpAdapter = this.adapterHost.httpAdapter;
26
- const path = this.normalizePath(config.path);
27
- const informationOutputPath = this.joinPath(path, 'information.json');
28
- const jsonOutputPath = this.joinPath(path, 'output.json');
29
- const markdownOutputPath = this.joinPath(path, 'output.md');
30
- httpAdapter.get(informationOutputPath, (_req, res) => {
31
- res.setHeader('Access-Control-Allow-Origin', '*');
32
- res.setHeader('Content-Type', 'application/json; charset=utf-8');
33
- httpAdapter.reply(res, INSPECTOR_ENDPOINT_INFO, 200);
34
- });
35
- httpAdapter.get(jsonOutputPath, (_req, res) => {
36
- res.setHeader('Access-Control-Allow-Origin', '*');
37
- res.setHeader('Content-Type', 'application/json; charset=utf-8');
38
- httpAdapter.reply(res, graphOutput, 200);
39
- });
40
- httpAdapter.get(markdownOutputPath, (_req, res) => {
41
- res.setHeader('Access-Control-Allow-Origin', '*');
42
- res.setHeader('Content-Type', 'text/markdown; charset=utf-8');
43
- httpAdapter.reply(res, this.fileOutputDriver.buildMarkdownText(graphOutput), 200);
44
- });
45
- return Promise.resolve({
46
- message: `Graph inspector HTTP endpoints are installed at ${informationOutputPath}, ${jsonOutputPath}, and ${markdownOutputPath}`,
47
- });
48
- }
49
- normalizePath(path = '/__nest-graph-inspector') {
50
- return path.startsWith('/') ? path : `/${path}`;
51
- }
52
- joinPath(basePath, childPath) {
53
- return `${basePath.replace(/\/$/, '')}/${childPath.replace(/^\//, '')}`;
54
- }
55
- };
56
- exports.HttpOutputDriver = HttpOutputDriver;
57
- exports.HttpOutputDriver = HttpOutputDriver = __decorate([
58
- (0, common_1.Injectable)(),
59
- __metadata("design:paramtypes", [core_1.HttpAdapterHost,
60
- file_output_driver_1.FileOutputDriver])
61
- ], HttpOutputDriver);
62
- //# sourceMappingURL=http-output.driver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"http-output.driver.js","sourceRoot":"","sources":["../../../../../libs/nest-graph-inspector/src/drivers/http-output.driver.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,uCAA+C;AAI/C,6DAAwD;AAOxD,MAAM,uBAAuB,GAAG,EAAE,GAAG,EAAE,sBAAsB,EAAE,CAAC;AAGzD,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAER;IACA;IAFnB,YACmB,WAA4B,EAC5B,gBAAkC;QADlC,gBAAW,GAAX,WAAW,CAAiB;QAC5B,qBAAgB,GAAhB,gBAAgB,CAAkB;IAClD,CAAC;IAEJ,OAAO,CACL,WAAwB,EACxB,MAAwB;QAExB,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC;QACjD,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,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;QAC1D,MAAM,kBAAkB,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAE5D,WAAW,CAAC,GAAG,CAAC,qBAAqB,EAAE,CAAC,IAAa,EAAE,GAAmB,EAAE,EAAE;YAC5E,GAAG,CAAC,SAAS,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC;YAClD,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,iCAAiC,CAAC,CAAC;YACjE,WAAW,CAAC,KAAK,CAAC,GAAG,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AgB;IAD5B,IAAA,mBAAU,GAAE;qCAGqB,sBAAe;QACV,qCAAgB;GAH1C,gBAAgB,CAqD5B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"json-output.driver.js","sourceRoot":"","sources":["../../../../../libs/nest-graph-inspector/src/drivers/json-output.driver.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+CAAoD;AACpD,2CAA4C;AAC5C,yCAA0C;AAQnC,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAC3B,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,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAElD,MAAM,IAAA,gBAAK,EAAC,IAAA,mBAAO,EAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACpD,MAAM,IAAA,oBAAS,EAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAEhC,OAAO;YACL,OAAO,EAAE,8CAA8C,QAAQ,EAAE;SAClE,CAAC;IACJ,CAAC;CACF,CAAA;AAfY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;GACA,gBAAgB,CAe5B"}
@@ -1,16 +0,0 @@
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 { HttpOutputDriver } from './http-output.driver';
5
- type ViewerOutputConfig = Extract<NestGraphInspectorOutput, {
6
- type: 'viewer';
7
- }>;
8
- export declare class ViewerOutputDriver implements OutputAdapter<ViewerOutputConfig> {
9
- private readonly httpOutputDriver;
10
- private readonly viewerBaseUrl;
11
- constructor(httpOutputDriver: HttpOutputDriver);
12
- execute(graphOutput: GraphOutput, config: ViewerOutputConfig): Promise<{
13
- message: string;
14
- }>;
15
- }
16
- export {};
@@ -1,42 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ViewerOutputDriver = void 0;
13
- const common_1 = require("@nestjs/common");
14
- const http_output_driver_1 = require("./http-output.driver");
15
- let ViewerOutputDriver = class ViewerOutputDriver {
16
- httpOutputDriver;
17
- viewerBaseUrl = process.env.____DEV_VIEWER_BASE_URL || 'https://albasyir.github.io/nest-graph-inspector';
18
- constructor(httpOutputDriver) {
19
- this.httpOutputDriver = httpOutputDriver;
20
- }
21
- async execute(graphOutput, config) {
22
- const path = this.httpOutputDriver.normalizePath(config.path ?? '/__graph-inspector');
23
- await this.httpOutputDriver.execute(graphOutput, { type: 'http', path });
24
- if (!config.origin) {
25
- return {
26
- message: `Graph Viewer is available at ${this.viewerBaseUrl}/view and follow the configuration instructions.`,
27
- };
28
- }
29
- const graphEndpoint = new URL(path, config.origin).toString();
30
- const base64Origin = Buffer.from(graphEndpoint).toString('base64url');
31
- const viewerLink = `${this.viewerBaseUrl}/view/${base64Origin}`;
32
- return {
33
- message: `Graph Viewer is available at ${viewerLink}`,
34
- };
35
- }
36
- };
37
- exports.ViewerOutputDriver = ViewerOutputDriver;
38
- exports.ViewerOutputDriver = ViewerOutputDriver = __decorate([
39
- (0, common_1.Injectable)(),
40
- __metadata("design:paramtypes", [http_output_driver_1.HttpOutputDriver])
41
- ], ViewerOutputDriver);
42
- //# sourceMappingURL=viewer-output.driver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"viewer-output.driver.js","sourceRoot":"","sources":["../../../../../libs/nest-graph-inspector/src/drivers/viewer-output.driver.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAI5C,6DAAwD;AAKjD,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAIA;IAHZ,aAAa,GAC5B,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAI,iDAAiD,CAAC;IAE3F,YAA6B,gBAAkC;QAAlC,qBAAgB,GAAhB,gBAAgB,CAAkB;IAAG,CAAC;IAEnE,KAAK,CAAC,OAAO,CACX,WAAwB,EACxB,MAA0B;QAE1B,MAAM,IAAI,GAAG,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAC9C,MAAM,CAAC,IAAI,IAAI,oBAAoB,CACpC,CAAC;QAEF,MAAM,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAEzE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACnB,OAAO;gBACL,OAAO,EAAE,gCAAgC,IAAI,CAAC,aAAa,kDAAkD;aAC9G,CAAC;QACJ,CAAC;QAED,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC9D,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAEtE,MAAM,UAAU,GAAG,GAAG,IAAI,CAAC,aAAa,SAAS,YAAY,EAAE,CAAC;QAEhE,OAAO;YACL,OAAO,EAAE,gCAAgC,U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