@nestjs/core 9.2.0 → 9.3.0-beta.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.
Files changed (60) hide show
  1. package/LICENSE +1 -1
  2. package/Readme.md +8 -3
  3. package/constants.d.ts +2 -0
  4. package/constants.js +7 -1
  5. package/errors/messages.js +16 -4
  6. package/injector/container.d.ts +9 -5
  7. package/injector/container.js +14 -9
  8. package/injector/injector.d.ts +4 -0
  9. package/injector/injector.js +7 -1
  10. package/injector/instance-loader.d.ts +6 -4
  11. package/injector/instance-loader.js +17 -7
  12. package/injector/instance-wrapper.d.ts +3 -0
  13. package/injector/instance-wrapper.js +10 -1
  14. package/injector/internal-core-module/internal-core-module-factory.d.ts +2 -1
  15. package/injector/internal-core-module/internal-core-module-factory.js +16 -8
  16. package/injector/module.d.ts +18 -7
  17. package/injector/module.js +50 -13
  18. package/injector/modules-container.d.ts +1 -0
  19. package/injector/modules-container.js +3 -0
  20. package/inspector/deterministic-uuid-registry.d.ts +5 -0
  21. package/inspector/deterministic-uuid-registry.js +20 -0
  22. package/inspector/graph-inspector.d.ts +25 -0
  23. package/inspector/graph-inspector.js +136 -0
  24. package/inspector/interfaces/edge.interface.d.ts +28 -0
  25. package/inspector/interfaces/edge.interface.js +2 -0
  26. package/inspector/interfaces/enhancer-metadata-cache-entry.interface.d.ts +12 -0
  27. package/inspector/interfaces/enhancer-metadata-cache-entry.interface.js +2 -0
  28. package/inspector/interfaces/entrypoint.interface.d.ts +23 -0
  29. package/inspector/interfaces/entrypoint.interface.js +2 -0
  30. package/inspector/interfaces/extras.interface.d.ts +18 -0
  31. package/inspector/interfaces/extras.interface.js +2 -0
  32. package/inspector/interfaces/node.interface.d.ts +47 -0
  33. package/inspector/interfaces/node.interface.js +2 -0
  34. package/inspector/noop-graph-inspector.d.ts +2 -0
  35. package/inspector/noop-graph-inspector.js +5 -0
  36. package/inspector/serialized-graph.d.ts +56 -0
  37. package/inspector/serialized-graph.js +104 -0
  38. package/middleware/container.js +2 -1
  39. package/middleware/middleware-module.d.ts +3 -1
  40. package/middleware/middleware-module.js +18 -2
  41. package/middleware/resolver.d.ts +3 -2
  42. package/middleware/resolver.js +7 -8
  43. package/middleware/routes-mapper.d.ts +1 -1
  44. package/middleware/routes-mapper.js +3 -3
  45. package/nest-application-context.d.ts +10 -5
  46. package/nest-application-context.js +39 -4
  47. package/nest-application.d.ts +6 -4
  48. package/nest-application.js +28 -8
  49. package/nest-factory.d.ts +5 -4
  50. package/nest-factory.js +27 -14
  51. package/package.json +2 -2
  52. package/router/paths-explorer.d.ts +18 -0
  53. package/router/paths-explorer.js +37 -0
  54. package/router/router-explorer.d.ts +8 -9
  55. package/router/router-explorer.js +22 -31
  56. package/router/routes-resolver.d.ts +3 -2
  57. package/router/routes-resolver.js +2 -2
  58. package/scanner.d.ts +14 -8
  59. package/scanner.js +67 -36
  60. package/tsconfig.build.json +21 -0
@@ -9,6 +9,7 @@ const exceptions_1 = require("../errors/exceptions");
9
9
  const context_id_factory_1 = require("../helpers/context-id-factory");
10
10
  const get_class_scope_1 = require("../helpers/get-class-scope");
11
11
  const is_durable_1 = require("../helpers/is-durable");
12
+ const deterministic_uuid_registry_1 = require("../inspector/deterministic-uuid-registry");
12
13
  const constants_1 = require("./constants");
13
14
  const instance_wrapper_1 = require("./instance-wrapper");
14
15
  const module_ref_1 = require("./module-ref");
@@ -23,8 +24,9 @@ class Module {
23
24
  this._controllers = new Map();
24
25
  this._exports = new Set();
25
26
  this._distance = 0;
27
+ this._isGlobal = false;
26
28
  this.addCoreProviders();
27
- this._id = (0, random_string_generator_util_1.randomStringGenerator)();
29
+ this._id = this.generateUuid();
28
30
  }
29
31
  get id() {
30
32
  return this._id;
@@ -35,6 +37,15 @@ class Module {
35
37
  set token(token) {
36
38
  this._token = token;
37
39
  }
40
+ get name() {
41
+ return this.metatype.name;
42
+ }
43
+ get isGlobal() {
44
+ return this._isGlobal;
45
+ }
46
+ set isGlobal(global) {
47
+ this._isGlobal = global;
48
+ }
38
49
  get providers() {
39
50
  return this._providers;
40
51
  }
@@ -122,7 +133,7 @@ class Module {
122
133
  host: this,
123
134
  }));
124
135
  }
125
- addInjectable(injectable, host) {
136
+ addInjectable(injectable, enhancerSubtype, host) {
126
137
  if (this.isCustomProvider(injectable)) {
127
138
  return this.addCustomProvider(injectable, this._injectables);
128
139
  }
@@ -136,6 +147,7 @@ class Module {
136
147
  isResolved: false,
137
148
  scope: (0, get_class_scope_1.getClassScope)(injectable),
138
149
  durable: (0, is_durable_1.isDurable)(injectable),
150
+ subtype: enhancerSubtype,
139
151
  host: this,
140
152
  });
141
153
  this._injectables.set(injectable, instanceWrapper);
@@ -144,10 +156,11 @@ class Module {
144
156
  const hostWrapper = this._controllers.get(host) || this._providers.get(host);
145
157
  hostWrapper && hostWrapper.addEnhancerMetadata(instanceWrapper);
146
158
  }
159
+ return instanceWrapper;
147
160
  }
148
- addProvider(provider) {
161
+ addProvider(provider, enhancerSubtype) {
149
162
  if (this.isCustomProvider(provider)) {
150
- return this.addCustomProvider(provider, this._providers);
163
+ return this.addCustomProvider(provider, this._providers, enhancerSubtype);
151
164
  }
152
165
  this._providers.set(provider, new instance_wrapper_1.InstanceWrapper({
153
166
  token: provider,
@@ -164,18 +177,18 @@ class Module {
164
177
  isCustomProvider(provider) {
165
178
  return !(0, shared_utils_1.isNil)(provider.provide);
166
179
  }
167
- addCustomProvider(provider, collection) {
180
+ addCustomProvider(provider, collection, enhancerSubtype) {
168
181
  if (this.isCustomClass(provider)) {
169
- this.addCustomClass(provider, collection);
182
+ this.addCustomClass(provider, collection, enhancerSubtype);
170
183
  }
171
184
  else if (this.isCustomValue(provider)) {
172
- this.addCustomValue(provider, collection);
185
+ this.addCustomValue(provider, collection, enhancerSubtype);
173
186
  }
174
187
  else if (this.isCustomFactory(provider)) {
175
- this.addCustomFactory(provider, collection);
188
+ this.addCustomFactory(provider, collection, enhancerSubtype);
176
189
  }
177
190
  else if (this.isCustomUseExisting(provider)) {
178
- this.addCustomUseExisting(provider, collection);
191
+ this.addCustomUseExisting(provider, collection, enhancerSubtype);
179
192
  }
180
193
  return provider.provide;
181
194
  }
@@ -194,7 +207,7 @@ class Module {
194
207
  isDynamicModule(exported) {
195
208
  return exported && exported.module;
196
209
  }
197
- addCustomClass(provider, collection) {
210
+ addCustomClass(provider, collection, enhancerSubtype) {
198
211
  let { scope, durable } = provider;
199
212
  const { useClass } = provider;
200
213
  if ((0, shared_utils_1.isUndefined)(scope)) {
@@ -212,9 +225,10 @@ class Module {
212
225
  scope,
213
226
  durable,
214
227
  host: this,
228
+ subtype: enhancerSubtype,
215
229
  }));
216
230
  }
217
- addCustomValue(provider, collection) {
231
+ addCustomValue(provider, collection, enhancerSubtype) {
218
232
  const { useValue: value, provide: providerToken } = provider;
219
233
  collection.set(providerToken, new instance_wrapper_1.InstanceWrapper({
220
234
  token: providerToken,
@@ -224,9 +238,10 @@ class Module {
224
238
  isResolved: true,
225
239
  async: value instanceof Promise,
226
240
  host: this,
241
+ subtype: enhancerSubtype,
227
242
  }));
228
243
  }
229
- addCustomFactory(provider, collection) {
244
+ addCustomFactory(provider, collection, enhancerSubtype) {
230
245
  const { useFactory: factory, inject, scope, durable, provide: providerToken, } = provider;
231
246
  collection.set(providerToken, new instance_wrapper_1.InstanceWrapper({
232
247
  token: providerToken,
@@ -238,9 +253,10 @@ class Module {
238
253
  scope,
239
254
  durable,
240
255
  host: this,
256
+ subtype: enhancerSubtype,
241
257
  }));
242
258
  }
243
- addCustomUseExisting(provider, collection) {
259
+ addCustomUseExisting(provider, collection, enhancerSubtype) {
244
260
  const { useExisting, provide: providerToken } = provider;
245
261
  collection.set(providerToken, new instance_wrapper_1.InstanceWrapper({
246
262
  token: providerToken,
@@ -251,6 +267,7 @@ class Module {
251
267
  inject: [useExisting],
252
268
  host: this,
253
269
  isAlias: true,
270
+ subtype: enhancerSubtype,
254
271
  }));
255
272
  }
256
273
  addExportedProvider(provider) {
@@ -333,6 +350,18 @@ class Module {
333
350
  getProviderByKey(name) {
334
351
  return this._providers.get(name);
335
352
  }
353
+ getProviderById(id) {
354
+ return Array.from(this._providers.values()).find(item => item.id === id);
355
+ }
356
+ getControllerById(id) {
357
+ return Array.from(this._controllers.values()).find(item => item.id === id);
358
+ }
359
+ getInjectableById(id) {
360
+ return Array.from(this._injectables.values()).find(item => item.id === id);
361
+ }
362
+ getMiddlewareById(id) {
363
+ return Array.from(this._middlewares.values()).find(item => item.id === id);
364
+ }
336
365
  getNonAliasProviders() {
337
366
  return [...this._providers].filter(([_, wrapper]) => !wrapper.isAlias);
338
367
  }
@@ -362,5 +391,13 @@ class Module {
362
391
  }
363
392
  };
364
393
  }
394
+ generateUuid() {
395
+ var _a, _b, _c;
396
+ const UUID_NAMESPACE = 'fb848993-0c82-4b9e-ae95-3c3c1dbe3d6b';
397
+ const key = (_b = (_a = this.name) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : (_c = this.token) === null || _c === void 0 ? void 0 : _c.toString();
398
+ return key
399
+ ? deterministic_uuid_registry_1.DeterministicUuidRegistry.get(key, UUID_NAMESPACE)
400
+ : (0, random_string_generator_util_1.randomStringGenerator)();
401
+ }
365
402
  }
366
403
  exports.Module = Module;
@@ -2,4 +2,5 @@ import { Module } from './module';
2
2
  export declare class ModulesContainer extends Map<string, Module> {
3
3
  private readonly _applicationId;
4
4
  get applicationId(): string;
5
+ getById(id: string): Module | undefined;
5
6
  }
@@ -10,5 +10,8 @@ class ModulesContainer extends Map {
10
10
  get applicationId() {
11
11
  return this._applicationId;
12
12
  }
13
+ getById(id) {
14
+ return Array.from(this.values()).find(moduleRef => moduleRef.id === id);
15
+ }
13
16
  }
14
17
  exports.ModulesContainer = ModulesContainer;
@@ -0,0 +1,5 @@
1
+ export declare class DeterministicUuidRegistry {
2
+ private static readonly registry;
3
+ static get(str: string, namespace?: string, inc?: number): any;
4
+ static clear(): void;
5
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeterministicUuidRegistry = void 0;
4
+ const uuid_1 = require("uuid");
5
+ const DEFAULT_UUID_NAMESPACE = 'efa0df42-88af-474f-9cad-4206a2319f07';
6
+ class DeterministicUuidRegistry {
7
+ static get(str, namespace = DEFAULT_UUID_NAMESPACE, inc = 0) {
8
+ const id = inc ? (0, uuid_1.v5)(str + `${inc}`, namespace) : (0, uuid_1.v5)(str, namespace);
9
+ if (this.registry.has(id)) {
10
+ return this.get(str, namespace, inc + 1);
11
+ }
12
+ this.registry.add(id);
13
+ return id;
14
+ }
15
+ static clear() {
16
+ this.registry.clear();
17
+ }
18
+ }
19
+ exports.DeterministicUuidRegistry = DeterministicUuidRegistry;
20
+ DeterministicUuidRegistry.registry = new Set();
@@ -0,0 +1,25 @@
1
+ import { NestContainer } from '../injector/container';
2
+ import { InstanceWrapper } from '../injector/instance-wrapper';
3
+ import { Module } from '../injector/module';
4
+ import { EnhancerMetadataCacheEntry } from './interfaces/enhancer-metadata-cache-entry.interface';
5
+ import { Entrypoint } from './interfaces/entrypoint.interface';
6
+ import { OrphanedEnhancerDefinition } from './interfaces/extras.interface';
7
+ import { Node } from './interfaces/node.interface';
8
+ export declare class GraphInspector {
9
+ private readonly container;
10
+ private readonly graph;
11
+ private readonly enhancersMetadataCache;
12
+ constructor(container: NestContainer);
13
+ inspectModules(modules?: Map<string, Module>): void;
14
+ inspectInstanceWrapper<T = any>(source: InstanceWrapper<T>, moduleRef: Module): void;
15
+ insertEnhancerMetadataCache(entry: EnhancerMetadataCacheEntry): void;
16
+ insertOrphanedEnhancer(entry: OrphanedEnhancerDefinition): void;
17
+ insertAttachedEnhancer(wrapper: InstanceWrapper): void;
18
+ insertEntrypointDefinition<T>(definition: Entrypoint<T>, parentId: string): void;
19
+ insertClassNode(moduleRef: Module, wrapper: InstanceWrapper, type: Exclude<Node['metadata']['type'], 'module'>): void;
20
+ private insertModuleNode;
21
+ private insertModuleToModuleEdges;
22
+ private insertEnhancerEdge;
23
+ private insertClassToClassEdge;
24
+ private insertClassNodes;
25
+ }
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GraphInspector = void 0;
4
+ const deterministic_uuid_registry_1 = require("./deterministic-uuid-registry");
5
+ class GraphInspector {
6
+ constructor(container) {
7
+ this.container = container;
8
+ this.enhancersMetadataCache = new Array();
9
+ this.graph = container.serializedGraph;
10
+ }
11
+ inspectModules(modules = this.container.getModules()) {
12
+ for (const moduleRef of modules.values()) {
13
+ this.insertModuleNode(moduleRef);
14
+ this.insertClassNodes(moduleRef);
15
+ this.insertModuleToModuleEdges(moduleRef);
16
+ }
17
+ this.enhancersMetadataCache.forEach(entry => this.insertEnhancerEdge(entry));
18
+ deterministic_uuid_registry_1.DeterministicUuidRegistry.clear();
19
+ }
20
+ inspectInstanceWrapper(source, moduleRef) {
21
+ const ctorMetadata = source.getCtorMetadata();
22
+ ctorMetadata === null || ctorMetadata === void 0 ? void 0 : ctorMetadata.forEach((target, index) => this.insertClassToClassEdge(source, target, moduleRef, index, 'constructor'));
23
+ const propertiesMetadata = source.getPropertiesMetadata();
24
+ propertiesMetadata === null || propertiesMetadata === void 0 ? void 0 : propertiesMetadata.forEach(({ key, wrapper: target }) => this.insertClassToClassEdge(source, target, moduleRef, key, 'property'));
25
+ }
26
+ insertEnhancerMetadataCache(entry) {
27
+ this.enhancersMetadataCache.push(entry);
28
+ }
29
+ insertOrphanedEnhancer(entry) {
30
+ var _a, _b, _c;
31
+ this.graph.insertOrphanedEnhancer(Object.assign(Object.assign({}, entry), { ref: (_c = (_b = (_a = entry.ref) === null || _a === void 0 ? void 0 : _a.constructor) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : 'Object' }));
32
+ }
33
+ insertAttachedEnhancer(wrapper) {
34
+ const existingNode = this.graph.getNodeById(wrapper.id);
35
+ existingNode.metadata.global = true;
36
+ this.graph.insertAttachedEnhancer(existingNode.id);
37
+ }
38
+ insertEntrypointDefinition(definition, parentId) {
39
+ definition = Object.assign(Object.assign({}, definition), { id: `${definition.classNodeId}_${definition.methodName}` });
40
+ this.graph.insertEntrypoint(definition, parentId);
41
+ }
42
+ insertClassNode(moduleRef, wrapper, type) {
43
+ this.graph.insertNode({
44
+ id: wrapper.id,
45
+ label: wrapper.name,
46
+ parent: moduleRef.id,
47
+ metadata: {
48
+ type,
49
+ internal: wrapper.metatype === moduleRef.metatype,
50
+ sourceModuleName: moduleRef.name,
51
+ durable: wrapper.isDependencyTreeDurable(),
52
+ static: wrapper.isDependencyTreeStatic(),
53
+ scope: wrapper.scope,
54
+ transient: wrapper.isTransient,
55
+ exported: moduleRef.exports.has(wrapper.token),
56
+ token: wrapper.token,
57
+ subtype: wrapper.subtype,
58
+ },
59
+ });
60
+ }
61
+ insertModuleNode(moduleRef) {
62
+ const dynamicMetadata = this.container.getDynamicMetadataByToken(moduleRef.token);
63
+ const node = {
64
+ id: moduleRef.id,
65
+ label: moduleRef.name,
66
+ metadata: {
67
+ type: 'module',
68
+ global: moduleRef.isGlobal,
69
+ dynamic: !!dynamicMetadata,
70
+ internal: moduleRef.name === 'InternalCoreModule',
71
+ },
72
+ };
73
+ this.graph.insertNode(node);
74
+ }
75
+ insertModuleToModuleEdges(moduleRef) {
76
+ for (const targetModuleRef of moduleRef.imports) {
77
+ this.graph.insertEdge({
78
+ source: moduleRef.id,
79
+ target: targetModuleRef.id,
80
+ metadata: {
81
+ type: 'module-to-module',
82
+ sourceModuleName: moduleRef.name,
83
+ targetModuleName: targetModuleRef.name,
84
+ },
85
+ });
86
+ }
87
+ }
88
+ insertEnhancerEdge(entry) {
89
+ var _a, _b, _c, _d;
90
+ const moduleRef = this.container.getModuleByKey(entry.moduleToken);
91
+ const sourceInstanceWrapper = (_a = moduleRef.controllers.get(entry.classRef)) !== null && _a !== void 0 ? _a : moduleRef.providers.get(entry.classRef);
92
+ const existingSourceNode = this.graph.getNodeById(sourceInstanceWrapper.id);
93
+ const enhancers = (_b = existingSourceNode.metadata.enhancers) !== null && _b !== void 0 ? _b : [];
94
+ if (entry.enhancerInstanceWrapper) {
95
+ this.insertClassToClassEdge(sourceInstanceWrapper, entry.enhancerInstanceWrapper, moduleRef, undefined, 'decorator');
96
+ enhancers.push({
97
+ id: entry.enhancerInstanceWrapper.id,
98
+ methodKey: entry.methodKey,
99
+ subtype: entry.subtype,
100
+ });
101
+ }
102
+ else {
103
+ const name = (_d = (_c = entry.enhancerRef.constructor) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : entry.enhancerRef.name;
104
+ enhancers.push({
105
+ name,
106
+ methodKey: entry.methodKey,
107
+ subtype: entry.subtype,
108
+ });
109
+ }
110
+ existingSourceNode.metadata.enhancers = enhancers;
111
+ }
112
+ insertClassToClassEdge(source, target, moduleRef, keyOrIndex, injectionType) {
113
+ var _a;
114
+ this.graph.insertEdge({
115
+ source: source.id,
116
+ target: target.id,
117
+ metadata: {
118
+ type: 'class-to-class',
119
+ sourceModuleName: moduleRef.name,
120
+ sourceClassName: source.name,
121
+ targetClassName: target.name,
122
+ sourceClassToken: source.token,
123
+ targetClassToken: target.token,
124
+ targetModuleName: (_a = target.host) === null || _a === void 0 ? void 0 : _a.name,
125
+ keyOrIndex,
126
+ injectionType,
127
+ },
128
+ });
129
+ }
130
+ insertClassNodes(moduleRef) {
131
+ moduleRef.providers.forEach(value => this.insertClassNode(moduleRef, value, 'provider'));
132
+ moduleRef.injectables.forEach(value => this.insertClassNode(moduleRef, value, 'injectable'));
133
+ moduleRef.controllers.forEach(value => this.insertClassNode(moduleRef, value, 'controller'));
134
+ }
135
+ }
136
+ exports.GraphInspector = GraphInspector;
@@ -0,0 +1,28 @@
1
+ import { InjectionToken } from '@nestjs/common';
2
+ declare type CommonEdgeMetadata = {
3
+ sourceModuleName: string;
4
+ targetModuleName: string;
5
+ };
6
+ declare type ModuleToModuleEdgeMetadata = {
7
+ type: 'module-to-module';
8
+ } & CommonEdgeMetadata;
9
+ declare type ClassToClassEdgeMetadata = {
10
+ type: 'class-to-class';
11
+ sourceClassName: string;
12
+ targetClassName: string;
13
+ sourceClassToken: InjectionToken;
14
+ targetClassToken: InjectionToken;
15
+ injectionType: 'constructor' | 'property' | 'decorator';
16
+ keyOrIndex?: string | number | symbol;
17
+ /**
18
+ * If true, indicates that this edge represents an internal providers connection
19
+ */
20
+ internal?: boolean;
21
+ } & CommonEdgeMetadata;
22
+ export interface Edge {
23
+ id: string;
24
+ source: string;
25
+ target: string;
26
+ metadata: ModuleToModuleEdgeMetadata | ClassToClassEdgeMetadata;
27
+ }
28
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,12 @@
1
+ import { Type } from '@nestjs/common';
2
+ import { EnhancerSubtype } from '@nestjs/common/constants';
3
+ import { InstanceWrapper } from '../../injector/instance-wrapper';
4
+ export interface EnhancerMetadataCacheEntry {
5
+ targetNodeId?: string;
6
+ moduleToken: string;
7
+ classRef: Type;
8
+ methodKey: string | undefined;
9
+ enhancerRef?: unknown;
10
+ enhancerInstanceWrapper?: InstanceWrapper;
11
+ subtype: EnhancerSubtype;
12
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,23 @@
1
+ import { RequestMethod } from '@nestjs/common';
2
+ import { VersionValue } from '@nestjs/common/interfaces';
3
+ export declare type HttpEntrypointMetadata = {
4
+ path: string;
5
+ requestMethod: keyof typeof RequestMethod;
6
+ methodVersion?: VersionValue;
7
+ controllerVersion?: VersionValue;
8
+ };
9
+ export declare type MiddlewareEntrypointMetadata = {
10
+ path: string;
11
+ requestMethod: keyof typeof RequestMethod;
12
+ version?: VersionValue;
13
+ };
14
+ export declare type Entrypoint<T> = {
15
+ id?: string;
16
+ type: string;
17
+ methodName: string;
18
+ className: string;
19
+ classNodeId: string;
20
+ metadata: {
21
+ key: string;
22
+ } & T;
23
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,18 @@
1
+ import { EnhancerSubtype } from '@nestjs/common/constants';
2
+ /**
3
+ * Enhancers attached through APP_PIPE, APP_GUARD, APP_INTERCEPTOR, and APP_FILTER tokens.
4
+ */
5
+ export interface AttachedEnhancerDefinition {
6
+ nodeId: string;
7
+ }
8
+ /**
9
+ * Enhancers registered through "app.useGlobalPipes()", "app.useGlobalGuards()", "app.useGlobalInterceptors()", and "app.useGlobalFilters()" methods.
10
+ */
11
+ export interface OrphanedEnhancerDefinition {
12
+ subtype: EnhancerSubtype;
13
+ ref: unknown;
14
+ }
15
+ export interface Extras {
16
+ orphanedEnhancers: Array<OrphanedEnhancerDefinition>;
17
+ attachedEnhancers: Array<AttachedEnhancerDefinition>;
18
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,47 @@
1
+ import { InjectionToken, Scope } from '@nestjs/common';
2
+ import { EnhancerSubtype } from '@nestjs/common/constants';
3
+ export declare type ModuleNode = {
4
+ metadata: {
5
+ type: 'module';
6
+ global: boolean;
7
+ dynamic: boolean;
8
+ internal: boolean;
9
+ };
10
+ };
11
+ export declare type ClassNode = {
12
+ parent: string;
13
+ metadata: {
14
+ type: 'provider' | 'controller' | 'middleware' | 'injectable';
15
+ subtype?: EnhancerSubtype;
16
+ sourceModuleName: string;
17
+ durable: boolean;
18
+ static: boolean;
19
+ transient: boolean;
20
+ exported: boolean;
21
+ scope: Scope;
22
+ token: InjectionToken;
23
+ /**
24
+ * Enhancers metadata collection
25
+ */
26
+ enhancers?: Array<{
27
+ id: string;
28
+ subtype: EnhancerSubtype;
29
+ } | {
30
+ name: string;
31
+ methodKey?: string;
32
+ subtype: EnhancerSubtype;
33
+ }>;
34
+ /**
35
+ * If true, node is a globally registered enhancer
36
+ */
37
+ global?: boolean;
38
+ /**
39
+ * If true, indicates that this node represents an internal provider
40
+ */
41
+ internal?: boolean;
42
+ };
43
+ };
44
+ export declare type Node = {
45
+ id: string;
46
+ label: string;
47
+ } & (ClassNode | ModuleNode);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ import { GraphInspector } from './graph-inspector';
2
+ export declare const NoopGraphInspector: GraphInspector;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NoopGraphInspector = void 0;
4
+ const graph_inspector_1 = require("./graph-inspector");
5
+ exports.NoopGraphInspector = Object.create(graph_inspector_1.GraphInspector.prototype);
@@ -0,0 +1,56 @@
1
+ import { InjectionToken } from '@nestjs/common';
2
+ import { Edge } from './interfaces/edge.interface';
3
+ import { Entrypoint } from './interfaces/entrypoint.interface';
4
+ import { Extras, OrphanedEnhancerDefinition } from './interfaces/extras.interface';
5
+ import { Node } from './interfaces/node.interface';
6
+ declare type WithOptionalId<T extends Record<'id', string>> = Omit<T, 'id'> & Partial<Pick<T, 'id'>>;
7
+ export declare class SerializedGraph {
8
+ private readonly nodes;
9
+ private readonly edges;
10
+ private readonly entrypoints;
11
+ private readonly extras;
12
+ private static readonly INTERNAL_PROVIDERS;
13
+ insertNode(nodeDefinition: Node): Node;
14
+ insertEdge(edgeDefinition: WithOptionalId<Edge>): {
15
+ id: string;
16
+ metadata: ({
17
+ type: "module-to-module";
18
+ } & {
19
+ sourceModuleName: string;
20
+ targetModuleName: string;
21
+ }) | ({
22
+ type: "class-to-class";
23
+ sourceClassName: string;
24
+ targetClassName: string;
25
+ sourceClassToken: InjectionToken;
26
+ targetClassToken: InjectionToken;
27
+ injectionType: "constructor" | "property" | "decorator";
28
+ keyOrIndex?: string | number | symbol;
29
+ internal?: boolean;
30
+ } & {
31
+ sourceModuleName: string;
32
+ targetModuleName: string;
33
+ });
34
+ source: string;
35
+ target: string;
36
+ };
37
+ insertEntrypoint<T>(definition: Entrypoint<T>, parentId: string): void;
38
+ insertOrphanedEnhancer(entry: OrphanedEnhancerDefinition): void;
39
+ insertAttachedEnhancer(nodeId: string): void;
40
+ getNodeById(id: string): Node;
41
+ toJSON(): {
42
+ nodes: {
43
+ [k: string]: Node;
44
+ };
45
+ edges: {
46
+ [k: string]: Edge;
47
+ };
48
+ entrypoints: {
49
+ [k: string]: Entrypoint<unknown>[];
50
+ };
51
+ extras: Extras;
52
+ };
53
+ toString(): string;
54
+ private generateUuidByEdgeDefinition;
55
+ }
56
+ export {};