@nexus-ioc/core 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +134 -0
- package/dist/browser.d.ts +1 -0
- package/dist/browser.js +6 -0
- package/dist/browser.js.map +1 -0
- package/dist/core/graph/analyze-module.d.ts +36 -0
- package/dist/core/graph/analyze-module.js +82 -0
- package/dist/core/graph/analyze-module.js.map +1 -0
- package/dist/core/graph/analyze-provider.d.ts +24 -0
- package/dist/core/graph/analyze-provider.js +57 -0
- package/dist/core/graph/analyze-provider.js.map +1 -0
- package/dist/core/graph/helpers/index.d.ts +9 -0
- package/dist/core/graph/helpers/index.js +23 -0
- package/dist/core/graph/helpers/index.js.map +1 -0
- package/dist/core/graph/module-graph.d.ts +34 -0
- package/dist/core/graph/module-graph.js +399 -0
- package/dist/core/graph/module-graph.js.map +1 -0
- package/dist/core/graph/providers/analyze-class-provider.d.ts +7 -0
- package/dist/core/graph/providers/analyze-class-provider.js +17 -0
- package/dist/core/graph/providers/analyze-class-provider.js.map +1 -0
- package/dist/core/graph/providers/analyze-factory-provider.d.ts +7 -0
- package/dist/core/graph/providers/analyze-factory-provider.js +17 -0
- package/dist/core/graph/providers/analyze-factory-provider.js.map +1 -0
- package/dist/core/graph/providers/analyze-function-provider.d.ts +5 -0
- package/dist/core/graph/providers/analyze-function-provider.js +11 -0
- package/dist/core/graph/providers/analyze-function-provider.js.map +1 -0
- package/dist/core/graph/providers/analyze-value-provider.d.ts +7 -0
- package/dist/core/graph/providers/analyze-value-provider.js +17 -0
- package/dist/core/graph/providers/analyze-value-provider.js.map +1 -0
- package/dist/core/graph/providers/provider-factory.d.ts +6 -0
- package/dist/core/graph/providers/provider-factory.js +24 -0
- package/dist/core/graph/providers/provider-factory.js.map +1 -0
- package/dist/core/modules/container.d.ts +15 -0
- package/dist/core/modules/container.js +40 -0
- package/dist/core/modules/container.js.map +1 -0
- package/dist/core/modules/module-container-factory.d.ts +9 -0
- package/dist/core/modules/module-container-factory.js +25 -0
- package/dist/core/modules/module-container-factory.js.map +1 -0
- package/dist/core/modules/module-container.d.ts +16 -0
- package/dist/core/modules/module-container.js +63 -0
- package/dist/core/modules/module-container.js.map +1 -0
- package/dist/core/modules/module-token-factory.d.ts +12 -0
- package/dist/core/modules/module-token-factory.js +48 -0
- package/dist/core/modules/module-token-factory.js.map +1 -0
- package/dist/core/modules/modules-container.d.ts +16 -0
- package/dist/core/modules/modules-container.js +43 -0
- package/dist/core/modules/modules-container.js.map +1 -0
- package/dist/core/nexus-applications.browser.d.ts +13 -0
- package/dist/core/nexus-applications.browser.js +36 -0
- package/dist/core/nexus-applications.browser.js.map +1 -0
- package/dist/core/nexus-applications.server.d.ts +13 -0
- package/dist/core/nexus-applications.server.js +36 -0
- package/dist/core/nexus-applications.server.js.map +1 -0
- package/dist/core/resolver/providers-container.d.ts +3 -0
- package/dist/core/resolver/providers-container.js +8 -0
- package/dist/core/resolver/providers-container.js.map +1 -0
- package/dist/core/resolver/resolver.d.ts +10 -0
- package/dist/core/resolver/resolver.js +126 -0
- package/dist/core/resolver/resolver.js.map +1 -0
- package/dist/decorators/global.d.ts +2 -0
- package/dist/decorators/global.js +12 -0
- package/dist/decorators/global.js.map +1 -0
- package/dist/decorators/inject.d.ts +3 -0
- package/dist/decorators/inject.js +27 -0
- package/dist/decorators/inject.js.map +1 -0
- package/dist/decorators/injectable.d.ts +3 -0
- package/dist/decorators/injectable.js +12 -0
- package/dist/decorators/injectable.js.map +1 -0
- package/dist/decorators/nsModule.d.ts +3 -0
- package/dist/decorators/nsModule.js +16 -0
- package/dist/decorators/nsModule.js.map +1 -0
- package/dist/decorators/optional.d.ts +2 -0
- package/dist/decorators/optional.js +20 -0
- package/dist/decorators/optional.js.map +1 -0
- package/dist/errors/container-not-compiled.error.d.ts +3 -0
- package/dist/errors/container-not-compiled.error.js +12 -0
- package/dist/errors/container-not-compiled.error.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/abstract.interface.d.ts +3 -0
- package/dist/interfaces/abstract.interface.js +3 -0
- package/dist/interfaces/abstract.interface.js.map +1 -0
- package/dist/interfaces/constants.d.ts +12 -0
- package/dist/interfaces/constants.js +16 -0
- package/dist/interfaces/constants.js.map +1 -0
- package/dist/interfaces/dynamic-module.interface.d.ts +13 -0
- package/dist/interfaces/dynamic-module.interface.js +3 -0
- package/dist/interfaces/dynamic-module.interface.js.map +1 -0
- package/dist/interfaces/index.d.ts +15 -0
- package/dist/interfaces/index.js +19 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/interfaces/injectable.interface.d.ts +4 -0
- package/dist/interfaces/injectable.interface.js +3 -0
- package/dist/interfaces/injectable.interface.js.map +1 -0
- package/dist/interfaces/injection-token.interface.d.ts +3 -0
- package/dist/interfaces/injection-token.interface.js +3 -0
- package/dist/interfaces/injection-token.interface.js.map +1 -0
- package/dist/interfaces/module-metadata.interface.d.ts +8 -0
- package/dist/interfaces/module-metadata.interface.js +3 -0
- package/dist/interfaces/module-metadata.interface.js.map +1 -0
- package/dist/interfaces/module-types.interface.d.ts +20 -0
- package/dist/interfaces/module-types.interface.js +3 -0
- package/dist/interfaces/module-types.interface.js.map +1 -0
- package/dist/interfaces/modules/container.interface.d.ts +16 -0
- package/dist/interfaces/modules/container.interface.js +3 -0
- package/dist/interfaces/modules/container.interface.js.map +1 -0
- package/dist/interfaces/modules/index.d.ts +7 -0
- package/dist/interfaces/modules/index.js +11 -0
- package/dist/interfaces/modules/index.js.map +1 -0
- package/dist/interfaces/modules/module-container-factory.interface.d.ts +7 -0
- package/dist/interfaces/modules/module-container-factory.interface.js +3 -0
- package/dist/interfaces/modules/module-container-factory.interface.js.map +1 -0
- package/dist/interfaces/modules/module-container.interface.d.ts +13 -0
- package/dist/interfaces/modules/module-container.interface.js +3 -0
- package/dist/interfaces/modules/module-container.interface.js.map +1 -0
- package/dist/interfaces/modules/module-graph.interface.d.ts +59 -0
- package/dist/interfaces/modules/module-graph.interface.js +16 -0
- package/dist/interfaces/modules/module-graph.interface.js.map +1 -0
- package/dist/interfaces/modules/module-token-factory.interface.d.ts +5 -0
- package/dist/interfaces/modules/module-token-factory.interface.js +3 -0
- package/dist/interfaces/modules/module-token-factory.interface.js.map +1 -0
- package/dist/interfaces/modules/modules-container.interface.d.ts +8 -0
- package/dist/interfaces/modules/modules-container.interface.js +3 -0
- package/dist/interfaces/modules/modules-container.interface.js.map +1 -0
- package/dist/interfaces/modules/provider-token-factory.interface.d.ts +4 -0
- package/dist/interfaces/modules/provider-token-factory.interface.js +3 -0
- package/dist/interfaces/modules/provider-token-factory.interface.js.map +1 -0
- package/dist/interfaces/nexus-application.interface.d.ts +8 -0
- package/dist/interfaces/nexus-application.interface.js +3 -0
- package/dist/interfaces/nexus-application.interface.js.map +1 -0
- package/dist/interfaces/on-module-init.interface.d.ts +3 -0
- package/dist/interfaces/on-module-init.interface.js +3 -0
- package/dist/interfaces/on-module-init.interface.js.map +1 -0
- package/dist/interfaces/plugins/index.d.ts +2 -0
- package/dist/interfaces/plugins/index.js +6 -0
- package/dist/interfaces/plugins/index.js.map +1 -0
- package/dist/interfaces/plugins/module-plugin.interface.d.ts +4 -0
- package/dist/interfaces/plugins/module-plugin.interface.js +3 -0
- package/dist/interfaces/plugins/module-plugin.interface.js.map +1 -0
- package/dist/interfaces/plugins/scanner-plugin.interface.d.ts +6 -0
- package/dist/interfaces/plugins/scanner-plugin.interface.js +3 -0
- package/dist/interfaces/plugins/scanner-plugin.interface.js.map +1 -0
- package/dist/interfaces/scope.interface.d.ts +4 -0
- package/dist/interfaces/scope.interface.js +9 -0
- package/dist/interfaces/scope.interface.js.map +1 -0
- package/dist/interfaces/type.interface.d.ts +3 -0
- package/dist/interfaces/type.interface.js +3 -0
- package/dist/interfaces/type.interface.js.map +1 -0
- package/dist/interfaces/utils/hash-utils.interface.d.ts +5 -0
- package/dist/interfaces/utils/hash-utils.interface.js +3 -0
- package/dist/interfaces/utils/hash-utils.interface.js.map +1 -0
- package/dist/interfaces/utils/index.d.ts +1 -0
- package/dist/interfaces/utils/index.js +5 -0
- package/dist/interfaces/utils/index.js.map +1 -0
- package/dist/interfaces/validate-module-keys.d.ts +7 -0
- package/dist/interfaces/validate-module-keys.js +26 -0
- package/dist/interfaces/validate-module-keys.js.map +1 -0
- package/dist/server.d.ts +1 -0
- package/dist/server.js +6 -0
- package/dist/server.js.map +1 -0
- package/dist/utils/hash-utils.browser.d.ts +6 -0
- package/dist/utils/hash-utils.browser.js +22 -0
- package/dist/utils/hash-utils.browser.js.map +1 -0
- package/dist/utils/hash-utils.server.d.ts +6 -0
- package/dist/utils/hash-utils.server.js +19 -0
- package/dist/utils/hash-utils.server.js.map +1 -0
- package/dist/utils/helpers.d.ts +16 -0
- package/dist/utils/helpers.js +83 -0
- package/dist/utils/helpers.js.map +1 -0
- package/dist/utils/random-string-generator.util.d.ts +1 -0
- package/dist/utils/random-string-generator.util.js +7 -0
- package/dist/utils/random-string-generator.util.js.map +1 -0
- package/dist/utils/shared.utils.d.ts +13 -0
- package/dist/utils/shared.utils.js +66 -0
- package/dist/utils/shared.utils.js.map +1 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Aleksandr Melnik
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+

|
|
2
|
+

|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
Nexus IoC is a powerful and flexible Inversion of Control (IoC) container for TypeScript applications. Inspired by Angular and NestJS, it leverages decorators to provide a simple and efficient way to manage dependencies and modules.
|
|
6
|
+
|
|
7
|
+
## Table of Contents
|
|
8
|
+
|
|
9
|
+
- [Features](#features)
|
|
10
|
+
- [Installation](#installation)
|
|
11
|
+
- [Quick Start](#quick-start)
|
|
12
|
+
- [Testing](#testing)
|
|
13
|
+
- [License](#license)
|
|
14
|
+
- [Author](#author)
|
|
15
|
+
- [Contributing](#contributing)
|
|
16
|
+
- [Acknowledgements](#acknowledgements)
|
|
17
|
+
- [Wiki](#wiki)
|
|
18
|
+
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
- **Modular Architecture**: Easily create and manage modules.
|
|
22
|
+
- **Dependency Injection**: Use decorators to inject dependencies into your classes.
|
|
23
|
+
- **Lifecycle Management**: Manage the lifecycle of your components seamlessly.
|
|
24
|
+
- **Asynchronous Module Loading**: Load modules asynchronously for improved performance.
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install nexus-ioc reflect-metadata
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
### Step 1: Define Your Modules and Providers
|
|
35
|
+
|
|
36
|
+
Create a module and a provider using decorators.
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import { NsModule, Injectable, Inject } from 'nexus-ioc';
|
|
40
|
+
|
|
41
|
+
@Injectable()
|
|
42
|
+
class DependencyService {
|
|
43
|
+
public readonly name = 'World';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@Injectable()
|
|
47
|
+
export class AppService {
|
|
48
|
+
constructor(
|
|
49
|
+
@Inject(DependencyService)
|
|
50
|
+
private readonly dependencyService: DependencyService,
|
|
51
|
+
) {
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
getHello(): string {
|
|
55
|
+
return `Hello ${this.dependencyService.name}!`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@NsModule({
|
|
60
|
+
providers: [AppService, DependencyService],
|
|
61
|
+
})
|
|
62
|
+
export class AppModule {}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Step 2: Create an Application
|
|
66
|
+
|
|
67
|
+
Create and bootstrap your application.
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import { NexusApplicationsBrowser } from 'nexus-ioc/dist/server';
|
|
71
|
+
import { AppModule, AppService } from './app.module';
|
|
72
|
+
|
|
73
|
+
async function bootstrap() {
|
|
74
|
+
const app = await NexusApplicationsBrowser
|
|
75
|
+
.create(AppModule)
|
|
76
|
+
.bootstrap();
|
|
77
|
+
|
|
78
|
+
const appService = app.get<AppService>(AppService);
|
|
79
|
+
|
|
80
|
+
console.log(appService?.getHello());
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
bootstrap();
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Testing
|
|
88
|
+
|
|
89
|
+
### Installation
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
npm install nexus-ioc-testing
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Usage
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
import { Injectable } from 'nexus-ioc';
|
|
99
|
+
import { Test } from 'nexus-ioc-testing';
|
|
100
|
+
|
|
101
|
+
describe('AppModule', () => {
|
|
102
|
+
it('should create instance', async () => {
|
|
103
|
+
@Injectable()
|
|
104
|
+
class AppService {}
|
|
105
|
+
|
|
106
|
+
const appModule = await Test.createModule({
|
|
107
|
+
providers: [AppService],
|
|
108
|
+
}).compile();
|
|
109
|
+
|
|
110
|
+
const appService = await appModule.get<AppService>(AppService);
|
|
111
|
+
expect(appService).toBeInstanceOf(AppService);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## License
|
|
117
|
+
|
|
118
|
+
This project is licensed under the MIT License. See the LICENSE file for details.
|
|
119
|
+
|
|
120
|
+
## Author
|
|
121
|
+
|
|
122
|
+
Isqanderm (Aleksandr Melnik) - [LinkedIn](www.linkedin.com/in/isqander-melnik)
|
|
123
|
+
|
|
124
|
+
## Contributing
|
|
125
|
+
|
|
126
|
+
Contributions are welcome! Please open an issue or submit a pull request.
|
|
127
|
+
|
|
128
|
+
## Acknowledgements
|
|
129
|
+
|
|
130
|
+
Special thanks to the developers of Angular and NestJS for the inspiration.
|
|
131
|
+
|
|
132
|
+
## Wiki
|
|
133
|
+
|
|
134
|
+
For more detailed documentation, please visit the [Wiki](https://github.com/Isqanderm/ioc/wiki).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NexusApplicationsBrowser } from "./core/nexus-applications.browser";
|
package/dist/browser.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NexusApplicationsBrowser = void 0;
|
|
4
|
+
var nexus_applications_browser_1 = require("./core/nexus-applications.browser");
|
|
5
|
+
Object.defineProperty(exports, "NexusApplicationsBrowser", { enumerable: true, get: function () { return nexus_applications_browser_1.NexusApplicationsBrowser; } });
|
|
6
|
+
//# sourceMappingURL=browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":";;;AAAA,gFAA6E;AAApE,sIAAA,wBAAwB,OAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { EdgeTypeEnum, type ModuleContainerInterface, NodeTypeEnum } from "../../interfaces";
|
|
2
|
+
export declare class AnalyzeModule {
|
|
3
|
+
private readonly _module;
|
|
4
|
+
private readonly _isDynamic;
|
|
5
|
+
private readonly _metatype;
|
|
6
|
+
private readonly _token;
|
|
7
|
+
private readonly _label;
|
|
8
|
+
constructor(_module: ModuleContainerInterface);
|
|
9
|
+
get type(): NodeTypeEnum.MODULE;
|
|
10
|
+
get id(): string;
|
|
11
|
+
get label(): string;
|
|
12
|
+
get moduleContainer(): ModuleContainerInterface;
|
|
13
|
+
get metatype(): import("../../interfaces").Module;
|
|
14
|
+
get isDynamic(): boolean;
|
|
15
|
+
get node(): {
|
|
16
|
+
type: NodeTypeEnum.MODULE;
|
|
17
|
+
id: string;
|
|
18
|
+
label: string;
|
|
19
|
+
metatype: import("../../interfaces").Module;
|
|
20
|
+
moduleContainer: ModuleContainerInterface;
|
|
21
|
+
isGlobal: boolean;
|
|
22
|
+
isDynamic: boolean;
|
|
23
|
+
};
|
|
24
|
+
get edges(): Promise<{
|
|
25
|
+
type: EdgeTypeEnum;
|
|
26
|
+
source: string;
|
|
27
|
+
target: string;
|
|
28
|
+
metadata: {
|
|
29
|
+
isCircular: boolean;
|
|
30
|
+
};
|
|
31
|
+
}[]>;
|
|
32
|
+
get providers(): import("../../interfaces").Provider[];
|
|
33
|
+
get isGlobal(): boolean;
|
|
34
|
+
get imports(): Promise<ModuleContainerInterface[]>;
|
|
35
|
+
get exports(): (import("../../interfaces").Module | import("../../interfaces").InjectionToken)[];
|
|
36
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AnalyzeModule = void 0;
|
|
4
|
+
const interfaces_1 = require("../../interfaces");
|
|
5
|
+
const helpers_1 = require("../../utils/helpers");
|
|
6
|
+
class AnalyzeModule {
|
|
7
|
+
constructor(_module) {
|
|
8
|
+
this._module = _module;
|
|
9
|
+
this._isDynamic = (0, helpers_1.isDynamicModule)(this._module.metatype);
|
|
10
|
+
this._metatype = (0, helpers_1.isDynamicModule)(this._module.metatype)
|
|
11
|
+
? this._module.metatype.module
|
|
12
|
+
: this._module.metatype;
|
|
13
|
+
this._token = this._module.token;
|
|
14
|
+
this._label = this._metatype.name;
|
|
15
|
+
}
|
|
16
|
+
get type() {
|
|
17
|
+
return interfaces_1.NodeTypeEnum.MODULE;
|
|
18
|
+
}
|
|
19
|
+
get id() {
|
|
20
|
+
return this._token;
|
|
21
|
+
}
|
|
22
|
+
get label() {
|
|
23
|
+
return this._label.toString();
|
|
24
|
+
}
|
|
25
|
+
get moduleContainer() {
|
|
26
|
+
return this._module;
|
|
27
|
+
}
|
|
28
|
+
get metatype() {
|
|
29
|
+
return this._metatype;
|
|
30
|
+
}
|
|
31
|
+
get isDynamic() {
|
|
32
|
+
return this._isDynamic;
|
|
33
|
+
}
|
|
34
|
+
get node() {
|
|
35
|
+
return {
|
|
36
|
+
type: this.type,
|
|
37
|
+
id: this.id,
|
|
38
|
+
label: this.label,
|
|
39
|
+
metatype: this.metatype,
|
|
40
|
+
moduleContainer: this.moduleContainer,
|
|
41
|
+
isGlobal: this.isGlobal,
|
|
42
|
+
isDynamic: this.isDynamic,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
get edges() {
|
|
46
|
+
return Promise.resolve().then(async () => {
|
|
47
|
+
const imports = await this._module.imports;
|
|
48
|
+
return imports.map((importModule) => {
|
|
49
|
+
const analyzeModule = new AnalyzeModule(importModule);
|
|
50
|
+
return {
|
|
51
|
+
type: interfaces_1.EdgeTypeEnum.IMPORT,
|
|
52
|
+
source: analyzeModule.id,
|
|
53
|
+
target: this.id,
|
|
54
|
+
metadata: {
|
|
55
|
+
isCircular: false,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
get providers() {
|
|
62
|
+
return [...this._module.providers];
|
|
63
|
+
}
|
|
64
|
+
get isGlobal() {
|
|
65
|
+
let isGlobal = (0, helpers_1.isGlobalModule)(this._metatype);
|
|
66
|
+
if ((0, helpers_1.isDynamicModule)(this._module.metatype)) {
|
|
67
|
+
if (this._module.metatype.module.forRoot ||
|
|
68
|
+
this._module.metatype.module.forRootAsync) {
|
|
69
|
+
isGlobal = true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return isGlobal;
|
|
73
|
+
}
|
|
74
|
+
get imports() {
|
|
75
|
+
return this._module.imports || [];
|
|
76
|
+
}
|
|
77
|
+
get exports() {
|
|
78
|
+
return this._module.exports || [];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.AnalyzeModule = AnalyzeModule;
|
|
82
|
+
//# sourceMappingURL=analyze-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyze-module.js","sourceRoot":"","sources":["../../../src/core/graph/analyze-module.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Edge, type ModuleContainerInterface, NodeTypeEnum, type Provider } from "../../interfaces";
|
|
2
|
+
export declare abstract class AnalyzeProvider {
|
|
3
|
+
protected readonly provider: Provider;
|
|
4
|
+
protected readonly module: ModuleContainerInterface;
|
|
5
|
+
private readonly _token;
|
|
6
|
+
private readonly _label;
|
|
7
|
+
private readonly _scope;
|
|
8
|
+
constructor(provider: Provider, module: ModuleContainerInterface);
|
|
9
|
+
get type(): NodeTypeEnum.PROVIDER;
|
|
10
|
+
get id(): import("../../interfaces").InjectionToken;
|
|
11
|
+
get label(): string;
|
|
12
|
+
get metatype(): Provider;
|
|
13
|
+
get moduleContainer(): ModuleContainerInterface;
|
|
14
|
+
get scope(): import("../../interfaces").Scope;
|
|
15
|
+
get node(): {
|
|
16
|
+
type: NodeTypeEnum.PROVIDER;
|
|
17
|
+
id: import("../../interfaces").InjectionToken;
|
|
18
|
+
label: string;
|
|
19
|
+
metatype: Provider;
|
|
20
|
+
moduleContainer: ModuleContainerInterface;
|
|
21
|
+
scope: import("../../interfaces").Scope;
|
|
22
|
+
};
|
|
23
|
+
get edge(): Edge;
|
|
24
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AnalyzeProvider = void 0;
|
|
4
|
+
const interfaces_1 = require("../../interfaces");
|
|
5
|
+
const helpers_1 = require("../../utils/helpers");
|
|
6
|
+
class AnalyzeProvider {
|
|
7
|
+
constructor(provider, module) {
|
|
8
|
+
this.provider = provider;
|
|
9
|
+
this.module = module;
|
|
10
|
+
this._token = (0, helpers_1.getProviderToken)(this.provider);
|
|
11
|
+
this._label = (0, helpers_1.isFunctionToken)(this._token)
|
|
12
|
+
? this._token.name
|
|
13
|
+
: this._token;
|
|
14
|
+
this._scope = (0, helpers_1.getProviderScope)(this.provider);
|
|
15
|
+
}
|
|
16
|
+
get type() {
|
|
17
|
+
return interfaces_1.NodeTypeEnum.PROVIDER;
|
|
18
|
+
}
|
|
19
|
+
get id() {
|
|
20
|
+
return this._token;
|
|
21
|
+
}
|
|
22
|
+
get label() {
|
|
23
|
+
return this._label.toString();
|
|
24
|
+
}
|
|
25
|
+
get metatype() {
|
|
26
|
+
return this.provider;
|
|
27
|
+
}
|
|
28
|
+
get moduleContainer() {
|
|
29
|
+
return this.module;
|
|
30
|
+
}
|
|
31
|
+
get scope() {
|
|
32
|
+
return this._scope;
|
|
33
|
+
}
|
|
34
|
+
get node() {
|
|
35
|
+
return {
|
|
36
|
+
type: this.type,
|
|
37
|
+
id: this.id,
|
|
38
|
+
label: this.label,
|
|
39
|
+
metatype: this.metatype,
|
|
40
|
+
moduleContainer: this.moduleContainer,
|
|
41
|
+
scope: this.scope,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
get edge() {
|
|
45
|
+
return {
|
|
46
|
+
type: interfaces_1.EdgeTypeEnum.PROVIDER,
|
|
47
|
+
source: this.id,
|
|
48
|
+
target: this.module.token,
|
|
49
|
+
metadata: {
|
|
50
|
+
unreached: false,
|
|
51
|
+
isCircular: false,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.AnalyzeProvider = AnalyzeProvider;
|
|
57
|
+
//# sourceMappingURL=analyze-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyze-provider.js","sourceRoot":"","sources":["../../../src/core/graph/analyze-provider.ts"],"names":[],"mappings":";;;AAAA,iDAM0B;AAC1B,iDAI6B;AAE7B,MAAsB,eAAe;IAOpC,YACoB,QAAkB,EAClB,MAAgC;QADhC,aAAQ,GAAR,QAAQ,CAAU;QAClB,WAAM,GAAN,MAAM,CAA0B;QARnC,WAAM,GAAG,IAAA,0BAAgB,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzC,WAAM,GAAG,IAAA,yBAAe,EAAC,IAAI,CAAC,MAAM,CAAC;YACrD,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI;YAClB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;QACE,WAAM,GAAG,IAAA,0BAAgB,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAKvD,CAAC;IAEJ,IAAW,IAAI;QACd,OAAO,yBAAY,CAAC,QAAQ,CAAC;IAC9B,CAAC;IAED,IAAW,EAAE;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED,IAAW,KAAK;QACf,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;IAC/B,CAAC;IAED,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;IAED,IAAW,eAAe;QACzB,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED,IAAW,KAAK;QACf,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED,IAAW,IAAI;QACd,OAAO;YACN,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,KAAK,EAAE,IAAI,CAAC,KAAK;SACjB,CAAC;IACH,CAAC;IAED,IAAW,IAAI;QACd,OAAO;YACN,IAAI,EAAE,yBAAY,CAAC,QAAQ;YAC3B,MAAM,EAAE,IAAI,CAAC,EAAE;YACf,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK;YACzB,QAAQ,EAAE;gBACT,SAAS,EAAE,KAAK;gBAChB,UAAU,EAAE,KAAK;aACjB;SACD,CAAC;IACH,CAAC;CACD;AA1DD,0CA0DC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AnalyzeProvider } from "../analyze-provider";
|
|
2
|
+
import { AnalyzeClassProvider } from "../providers/analyze-class-provider";
|
|
3
|
+
import { AnalyzeFactoryProvider } from "../providers/analyze-factory-provider";
|
|
4
|
+
import { AnalyzeFunctionProvider } from "../providers/analyze-function-provider";
|
|
5
|
+
import { AnalyzeValueProvider } from "../providers/analyze-value-provider";
|
|
6
|
+
export declare function isAnalyzeClassProvider(target: AnalyzeProvider): target is AnalyzeClassProvider;
|
|
7
|
+
export declare function isAnalyzeFactoryProvider(target: AnalyzeProvider): target is AnalyzeFactoryProvider;
|
|
8
|
+
export declare function isAnalyzeFunctionProvider(target: AnalyzeProvider): target is AnalyzeFunctionProvider;
|
|
9
|
+
export declare function isAnalyzeValueProvider(target: AnalyzeProvider): target is AnalyzeValueProvider;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isAnalyzeClassProvider = isAnalyzeClassProvider;
|
|
4
|
+
exports.isAnalyzeFactoryProvider = isAnalyzeFactoryProvider;
|
|
5
|
+
exports.isAnalyzeFunctionProvider = isAnalyzeFunctionProvider;
|
|
6
|
+
exports.isAnalyzeValueProvider = isAnalyzeValueProvider;
|
|
7
|
+
const analyze_class_provider_1 = require("../providers/analyze-class-provider");
|
|
8
|
+
const analyze_factory_provider_1 = require("../providers/analyze-factory-provider");
|
|
9
|
+
const analyze_function_provider_1 = require("../providers/analyze-function-provider");
|
|
10
|
+
const analyze_value_provider_1 = require("../providers/analyze-value-provider");
|
|
11
|
+
function isAnalyzeClassProvider(target) {
|
|
12
|
+
return target instanceof analyze_class_provider_1.AnalyzeClassProvider;
|
|
13
|
+
}
|
|
14
|
+
function isAnalyzeFactoryProvider(target) {
|
|
15
|
+
return target instanceof analyze_factory_provider_1.AnalyzeFactoryProvider;
|
|
16
|
+
}
|
|
17
|
+
function isAnalyzeFunctionProvider(target) {
|
|
18
|
+
return target instanceof analyze_function_provider_1.AnalyzeFunctionProvider;
|
|
19
|
+
}
|
|
20
|
+
function isAnalyzeValueProvider(target) {
|
|
21
|
+
return target instanceof analyze_value_provider_1.AnalyzeValueProvider;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/graph/helpers/index.ts"],"names":[],"mappings":";;AAMA,wDAIC;AAED,4DAIC;AAED,8DAIC;AAED,wDAIC;AA3BD,gFAA2E;AAC3E,oFAA+E;AAC/E,sFAAiF;AACjF,gFAA2E;AAE3E,SAAgB,sBAAsB,CACrC,MAAuB;IAEvB,OAAO,MAAM,YAAY,6CAAoB,CAAC;AAC/C,CAAC;AAED,SAAgB,wBAAwB,CACvC,MAAuB;IAEvB,OAAO,MAAM,YAAY,iDAAsB,CAAC;AACjD,CAAC;AAED,SAAgB,yBAAyB,CACxC,MAAuB;IAEvB,OAAO,MAAM,YAAY,mDAAuB,CAAC;AAClD,CAAC;AAED,SAAgB,sBAAsB,CACrC,MAAuB;IAEvB,OAAO,MAAM,YAAY,6CAAoB,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type Edge, type GraphError, type InjectionToken, type ModuleContainerInterface, type ModuleGraphInterface, type Node } from "../../interfaces";
|
|
2
|
+
export declare class ModuleGraph implements ModuleGraphInterface {
|
|
3
|
+
private readonly _root;
|
|
4
|
+
private _nodes;
|
|
5
|
+
private _edges;
|
|
6
|
+
private _globalModules;
|
|
7
|
+
private readonly _errors;
|
|
8
|
+
constructor(_root: ModuleContainerInterface);
|
|
9
|
+
get nodes(): Map<InjectionToken, Node>;
|
|
10
|
+
get edges(): Map<InjectionToken, Edge[]>;
|
|
11
|
+
get errors(): GraphError[];
|
|
12
|
+
compile(): Promise<void>;
|
|
13
|
+
getNode(token: InjectionToken): Node;
|
|
14
|
+
getEdge(token: InjectionToken): Edge[];
|
|
15
|
+
getAllEdges(): Edge[][];
|
|
16
|
+
getAllNodes(): Node[];
|
|
17
|
+
private addModules;
|
|
18
|
+
private addModule;
|
|
19
|
+
private addModuleImports;
|
|
20
|
+
private addModuleProviders;
|
|
21
|
+
private addEdge;
|
|
22
|
+
private addNode;
|
|
23
|
+
private addDependencies;
|
|
24
|
+
private addClassDependency;
|
|
25
|
+
private addClassProviderDependency;
|
|
26
|
+
private addFactoryProviderDependency;
|
|
27
|
+
private isProviderExported;
|
|
28
|
+
private detectCircularDependencies;
|
|
29
|
+
private detectCircularImports;
|
|
30
|
+
private getConstructorDependencies;
|
|
31
|
+
private getOptionalConstructorDependencies;
|
|
32
|
+
private getOptionalPropertyDependencies;
|
|
33
|
+
private getPropertiesDependencies;
|
|
34
|
+
}
|