@expressots/core 2.16.2 → 3.0.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.
- package/README.md +2 -2
- package/lib/CHANGELOG.md +312 -322
- package/lib/README.md +2 -2
- package/lib/cjs/application/application-container.js +18 -21
- package/lib/cjs/application/application-factory.js +4 -5
- package/lib/cjs/{common/server-env.types.js → application/application.types.js} +1 -0
- package/lib/cjs/application/index.js +3 -1
- package/lib/cjs/console/console.js +8 -20
- package/lib/cjs/container-module/container-module.js +10 -18
- package/lib/cjs/decorator/scope-binding.js +12 -11
- package/lib/cjs/di/annotation/decorator_utils.js +121 -0
- package/lib/cjs/di/annotation/inject.js +44 -0
- package/lib/cjs/di/annotation/inject_base.js +17 -0
- package/lib/cjs/di/annotation/injectable.js +43 -0
- package/lib/cjs/di/annotation/lazy_service_identifier.js +12 -0
- package/lib/cjs/di/annotation/multi_inject.js +30 -0
- package/lib/cjs/di/annotation/named.js +34 -0
- package/lib/cjs/di/annotation/optional.js +32 -0
- package/lib/cjs/di/annotation/post_construct.js +31 -0
- package/lib/cjs/di/annotation/pre_destroy.js +31 -0
- package/lib/cjs/di/annotation/property_event_decorator.js +15 -0
- package/lib/cjs/di/annotation/tagged.js +9 -0
- package/lib/cjs/di/annotation/target_name.js +35 -0
- package/lib/cjs/di/annotation/unmanaged.js +35 -0
- package/lib/cjs/di/binding-decorator/constants.js +7 -0
- package/lib/cjs/di/binding-decorator/decorator/fluent_provide.js +20 -0
- package/lib/cjs/di/binding-decorator/decorator/provide.js +37 -0
- package/lib/cjs/di/binding-decorator/factory/module_factory.js +17 -0
- package/lib/cjs/di/binding-decorator/index.js +14 -0
- package/lib/cjs/di/binding-decorator/syntax/provide_done_syntax.js +42 -0
- package/lib/cjs/di/binding-decorator/syntax/provide_in_syntax.js +33 -0
- package/lib/cjs/di/binding-decorator/syntax/provide_in_when_on_syntax.js +64 -0
- package/lib/cjs/di/binding-decorator/syntax/provide_on_syntax.js +22 -0
- package/lib/cjs/di/binding-decorator/syntax/provide_when_on_syntax.js +57 -0
- package/lib/cjs/di/binding-decorator/syntax/provide_when_syntax.js +89 -0
- package/lib/cjs/di/binding-decorator/utils/auto_wire.js +18 -0
- package/lib/cjs/di/bindings/binding.js +40 -0
- package/lib/cjs/di/bindings/binding_count.js +8 -0
- package/lib/cjs/di/constants/error_msgs.js +60 -0
- package/lib/cjs/di/constants/literal_types.js +26 -0
- package/lib/cjs/di/constants/metadata_keys.js +38 -0
- package/lib/cjs/di/container/container.js +521 -0
- package/lib/cjs/di/container/container_module.js +18 -0
- package/lib/cjs/di/container/container_snapshot.js +15 -0
- package/lib/cjs/di/container/lookup.js +132 -0
- package/lib/cjs/di/container/module_activation_store.js +49 -0
- package/lib/cjs/di/interfaces/interfaces.js +2 -0
- package/lib/cjs/di/inversify.js +78 -0
- package/lib/cjs/di/planning/context.js +17 -0
- package/lib/cjs/di/planning/metadata.js +42 -0
- package/lib/cjs/di/planning/metadata_reader.js +45 -0
- package/lib/cjs/di/planning/plan.js +10 -0
- package/lib/cjs/di/planning/planner.js +186 -0
- package/lib/cjs/di/planning/queryable_string.js +27 -0
- package/lib/cjs/di/planning/reflection_utils.js +178 -0
- package/lib/cjs/di/planning/request.js +23 -0
- package/lib/cjs/di/planning/target.js +108 -0
- package/lib/cjs/di/resolution/instantiation.js +150 -0
- package/lib/cjs/di/resolution/resolver.js +188 -0
- package/lib/cjs/di/scope/scope.js +50 -0
- package/lib/cjs/di/syntax/binding_in_syntax.js +23 -0
- package/lib/cjs/di/syntax/binding_in_when_on_syntax.js +75 -0
- package/lib/cjs/di/syntax/binding_on_syntax.js +18 -0
- package/lib/cjs/di/syntax/binding_to_syntax.js +111 -0
- package/lib/cjs/di/syntax/binding_when_on_syntax.js +64 -0
- package/lib/cjs/di/syntax/binding_when_syntax.js +84 -0
- package/lib/cjs/di/syntax/constraint_helpers.js +68 -0
- package/lib/cjs/di/utils/async.js +15 -0
- package/lib/cjs/di/utils/binding_utils.js +77 -0
- package/lib/cjs/di/utils/clonable.js +9 -0
- package/lib/cjs/di/utils/exceptions.js +46 -0
- package/lib/cjs/di/utils/factory_type.js +9 -0
- package/lib/cjs/di/utils/id.js +7 -0
- package/lib/cjs/di/utils/js.js +15 -0
- package/lib/cjs/di/utils/serialization.js +132 -0
- package/lib/cjs/error/app-error.js +5 -2
- package/lib/cjs/error/report.js +24 -15
- package/lib/cjs/index.js +1 -2
- package/lib/cjs/middleware/middleware-interface.js +2 -0
- package/lib/cjs/middleware/middleware-service.js +9 -24
- package/lib/cjs/provider/db-in-memory/base-repo.repository.js +3 -8
- package/lib/cjs/provider/db-in-memory/db-in-memory.provider.js +8 -5
- package/lib/cjs/provider/dto-validator/dto-validator.provider.js +4 -4
- package/lib/cjs/provider/dto-validator/package-resolver.js +56 -0
- package/lib/cjs/provider/environment/env-validator.provider.js +14 -12
- package/lib/cjs/provider/logger/logger.provider.js +10 -5
- package/lib/cjs/provider/provider-manager.js +21 -17
- package/lib/cjs/types/application/application-container.d.ts +12 -25
- package/lib/cjs/types/application/application-factory.d.ts +10 -7
- package/lib/cjs/types/{common/server-env.types.d.ts → application/application.types.d.ts} +1 -0
- package/lib/cjs/types/application/index.d.ts +1 -0
- package/lib/cjs/types/console/console.d.ts +3 -10
- package/lib/cjs/types/console/index.d.ts +2 -1
- package/lib/cjs/types/container-module/container-module.d.ts +3 -1
- package/lib/cjs/types/decorator/scope-binding.d.ts +9 -9
- package/lib/cjs/types/di/annotation/decorator_utils.d.ts +16 -0
- package/lib/cjs/types/di/annotation/inject.d.ts +16 -0
- package/lib/cjs/types/di/annotation/inject_base.d.ts +3 -0
- package/lib/cjs/types/di/annotation/injectable.d.ts +7 -0
- package/lib/cjs/types/di/annotation/lazy_service_identifier.d.ts +7 -0
- package/lib/cjs/types/di/annotation/multi_inject.d.ts +2 -0
- package/lib/cjs/types/di/annotation/named.d.ts +2 -0
- package/lib/cjs/types/di/annotation/optional.d.ts +2 -0
- package/lib/cjs/types/di/annotation/post_construct.d.ts +4 -0
- package/lib/cjs/types/di/annotation/pre_destroy.d.ts +4 -0
- package/lib/cjs/types/di/annotation/property_event_decorator.d.ts +4 -0
- package/lib/cjs/types/di/annotation/tagged.d.ts +2 -0
- package/lib/cjs/types/di/annotation/target_name.d.ts +3 -0
- package/lib/cjs/types/di/annotation/unmanaged.d.ts +3 -0
- package/lib/cjs/types/di/binding-decorator/constants.d.ts +4 -0
- package/lib/cjs/types/di/binding-decorator/decorator/fluent_provide.d.ts +4 -0
- package/lib/cjs/types/di/binding-decorator/decorator/provide.d.ts +4 -0
- package/lib/cjs/types/di/binding-decorator/factory/module_factory.d.ts +4 -0
- package/lib/cjs/types/di/binding-decorator/index.d.ts +8 -0
- package/lib/cjs/types/di/binding-decorator/interfaces/interfaces.d.ts +39 -0
- package/lib/cjs/types/di/binding-decorator/syntax/provide_done_syntax.d.ts +7 -0
- package/lib/cjs/types/di/binding-decorator/syntax/provide_in_syntax.d.ts +11 -0
- package/lib/cjs/types/di/binding-decorator/syntax/provide_in_when_on_syntax.d.ts +27 -0
- package/lib/cjs/types/di/binding-decorator/syntax/provide_on_syntax.d.ts +10 -0
- package/lib/cjs/types/di/binding-decorator/syntax/provide_when_on_syntax.d.ts +24 -0
- package/lib/cjs/types/di/binding-decorator/syntax/provide_when_syntax.d.ts +23 -0
- package/lib/cjs/types/di/binding-decorator/utils/auto_wire.d.ts +3 -0
- package/lib/cjs/types/di/bindings/binding.d.ts +20 -0
- package/lib/cjs/types/di/bindings/binding_count.d.ts +5 -0
- package/lib/cjs/types/di/constants/error_msgs.d.ts +32 -0
- package/lib/cjs/types/di/constants/literal_types.d.ts +5 -0
- package/lib/cjs/types/di/constants/metadata_keys.d.ts +13 -0
- package/lib/cjs/types/di/container/container.d.ts +73 -0
- package/lib/cjs/types/di/container/container_module.d.ts +11 -0
- package/lib/cjs/types/di/container/container_snapshot.d.ts +10 -0
- package/lib/cjs/types/di/container/lookup.d.ts +16 -0
- package/lib/cjs/types/di/container/module_activation_store.d.ts +10 -0
- package/lib/cjs/types/di/interfaces/interfaces.d.ts +299 -0
- package/lib/cjs/types/di/inversify.d.ts +25 -0
- package/lib/cjs/types/di/planning/context.d.ts +11 -0
- package/lib/cjs/types/di/planning/metadata.d.ts +8 -0
- package/lib/cjs/types/di/planning/metadata_reader.d.ts +6 -0
- package/lib/cjs/types/di/planning/plan.d.ts +7 -0
- package/lib/cjs/types/di/planning/planner.d.ts +5 -0
- package/lib/cjs/types/di/planning/queryable_string.d.ts +11 -0
- package/lib/cjs/types/di/planning/reflection_utils.d.ts +5 -0
- package/lib/cjs/types/di/planning/request.d.ts +14 -0
- package/lib/cjs/types/di/planning/target.d.ts +23 -0
- package/lib/cjs/types/di/resolution/instantiation.d.ts +3 -0
- package/lib/cjs/types/di/resolution/resolver.d.ts +3 -0
- package/lib/cjs/types/di/scope/scope.d.ts +3 -0
- package/lib/cjs/types/di/syntax/binding_in_syntax.d.ts +9 -0
- package/lib/cjs/types/di/syntax/binding_in_when_on_syntax.d.ts +29 -0
- package/lib/cjs/types/di/syntax/binding_on_syntax.d.ts +8 -0
- package/lib/cjs/types/di/syntax/binding_to_syntax.d.ts +18 -0
- package/lib/cjs/types/di/syntax/binding_when_on_syntax.d.ts +25 -0
- package/lib/cjs/types/di/syntax/binding_when_syntax.d.ts +21 -0
- package/lib/cjs/types/di/syntax/constraint_helpers.d.ts +6 -0
- package/lib/cjs/types/di/utils/async.d.ts +3 -0
- package/lib/cjs/types/di/utils/binding_utils.d.ts +4 -0
- package/lib/cjs/types/di/utils/clonable.d.ts +3 -0
- package/lib/cjs/types/di/utils/exceptions.d.ts +2 -0
- package/lib/cjs/types/di/utils/factory_type.d.ts +5 -0
- package/lib/cjs/types/di/utils/id.d.ts +2 -0
- package/lib/cjs/types/di/utils/js.d.ts +1 -0
- package/lib/cjs/types/di/utils/serialization.d.ts +10 -0
- package/lib/cjs/types/error/report.d.ts +7 -5
- package/lib/cjs/types/index.d.ts +1 -2
- package/lib/cjs/types/middleware/index.d.ts +2 -1
- package/lib/cjs/types/middleware/middleware-interface.d.ts +185 -0
- package/lib/cjs/types/middleware/middleware-service.d.ts +11 -163
- package/lib/cjs/types/provider/db-in-memory/db-in-memory.provider.d.ts +4 -0
- package/lib/cjs/types/provider/dto-validator/dto-validator.provider.d.ts +2 -3
- package/lib/cjs/types/{common → provider/dto-validator}/package-resolver.d.ts +1 -2
- package/lib/cjs/types/provider/environment/env-validator.provider.d.ts +7 -3
- package/lib/cjs/types/provider/logger/logger.provider.d.ts +5 -0
- package/lib/cjs/types/provider/provider-manager.d.ts +22 -2
- package/lib/package.json +9 -15
- package/package.json +9 -15
- package/lib/cjs/common/index.js +0 -5
- package/lib/cjs/common/package-resolver.js +0 -34
- package/lib/cjs/controller/base-controller.js +0 -63
- package/lib/cjs/controller/index.js +0 -5
- package/lib/cjs/types/common/index.d.ts +0 -2
- package/lib/cjs/types/common/project-config.d.ts +0 -56
- package/lib/cjs/types/controller/base-controller.d.ts +0 -32
- package/lib/cjs/types/controller/index.d.ts +0 -1
- /package/lib/cjs/{common → console}/color-codes.js +0 -0
- /package/lib/cjs/{common/project-config.js → di/binding-decorator/interfaces/interfaces.js} +0 -0
- /package/lib/cjs/types/{common → console}/color-codes.d.ts +0 -0
package/lib/README.md
CHANGED
|
@@ -91,7 +91,7 @@ ExpressoTS is an independent open source project with ongoing development made p
|
|
|
91
91
|
|
|
92
92
|
## License
|
|
93
93
|
|
|
94
|
-
Distributed under the MIT License. See [`LICENSE.
|
|
94
|
+
Distributed under the MIT License. See [`LICENSE.md`](https://github.com/expressots/expressots/blob/main/LICENSE.md) for more information.
|
|
95
95
|
|
|
96
96
|
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
97
97
|
|
|
@@ -112,7 +112,7 @@ Distributed under the MIT License. See [`LICENSE.txt`](https://github.com/expres
|
|
|
112
112
|
[issues-shield]: https://img.shields.io/github/issues/expressots/expressots?style=for-the-badge
|
|
113
113
|
[issues-url]: https://github.com/expressots/expressots/issues
|
|
114
114
|
[license-shield]: https://img.shields.io/github/license/expressots/expressots?style=for-the-badge
|
|
115
|
-
[license-url]: https://github.com/expressots/expressots/blob/main/LICENSE
|
|
115
|
+
[license-url]: https://github.com/expressots/expressots/blob/main/LICENSE.md
|
|
116
116
|
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
|
|
117
117
|
[linkedin-url]: https://www.linkedin.com/company/expresso-ts/
|
|
118
118
|
[product-screenshot]: images/screenshot.png
|
|
@@ -1,18 +1,10 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.AppContainer = void 0;
|
|
13
4
|
require("reflect-metadata");
|
|
14
|
-
const inversify_1 = require("inversify");
|
|
15
|
-
const
|
|
5
|
+
const inversify_1 = require("../di/inversify");
|
|
6
|
+
const binding_decorator_1 = require("../di/binding-decorator");
|
|
7
|
+
const provider_1 = require("../provider");
|
|
16
8
|
/**
|
|
17
9
|
* The AppContainer class provides a container for managing dependency injection.
|
|
18
10
|
* It allows the creation of a container with custom options, including default binding scope
|
|
@@ -23,8 +15,10 @@ const inversify_binding_decorators_1 = require("inversify-binding-decorators");
|
|
|
23
15
|
* ```typescript
|
|
24
16
|
* const container = new AppContainer();
|
|
25
17
|
* container.create([new MyModule()]);
|
|
18
|
+
* ```
|
|
19
|
+
* @public API
|
|
26
20
|
*/
|
|
27
|
-
|
|
21
|
+
class AppContainer {
|
|
28
22
|
/**
|
|
29
23
|
* Constructs the AppContainer instance.
|
|
30
24
|
* @param options - The options for creating the container with default request scope.
|
|
@@ -52,12 +46,12 @@ let AppContainer = class AppContainer {
|
|
|
52
46
|
};
|
|
53
47
|
this.container = new inversify_1.Container(containerOptions);
|
|
54
48
|
this.container.bind(inversify_1.Container).toConstantValue(this.container);
|
|
55
|
-
this.container.load((0,
|
|
56
|
-
return this.container;
|
|
49
|
+
this.container.load((0, binding_decorator_1.buildProviderModule)(), ...modules);
|
|
57
50
|
}
|
|
58
51
|
/**
|
|
59
52
|
* Retrieves the binding dictionary of the container.
|
|
60
53
|
* @returns(void) Print table of the binding dictionary of the container.
|
|
54
|
+
* @public API
|
|
61
55
|
*/
|
|
62
56
|
viewContainerBindings() {
|
|
63
57
|
const dictionary = this.container["_bindingDictionary"]._map;
|
|
@@ -77,20 +71,23 @@ let AppContainer = class AppContainer {
|
|
|
77
71
|
/**
|
|
78
72
|
* Retrieves the container options.
|
|
79
73
|
* @returns The container options.
|
|
74
|
+
* @public API
|
|
80
75
|
*/
|
|
81
76
|
getContainerOptions() {
|
|
77
|
+
this.logger = new provider_1.Logger();
|
|
78
|
+
if (!this.container) {
|
|
79
|
+
this.logger.error("Container not created yet.", "app-container");
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
82
|
return this.container.options;
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
|
-
* Retrieves the container.
|
|
86
|
-
* @returns The container.
|
|
85
|
+
* Retrieves the container instance.
|
|
86
|
+
* @returns The container instance.
|
|
87
|
+
* @public API
|
|
87
88
|
*/
|
|
88
89
|
get Container() {
|
|
89
90
|
return this.container;
|
|
90
91
|
}
|
|
91
|
-
}
|
|
92
|
+
}
|
|
92
93
|
exports.AppContainer = AppContainer;
|
|
93
|
-
exports.AppContainer = AppContainer = __decorate([
|
|
94
|
-
(0, inversify_binding_decorators_1.provide)(AppContainer),
|
|
95
|
-
__metadata("design:paramtypes", [Object])
|
|
96
|
-
], AppContainer);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AppFactory = void 0;
|
|
4
|
+
exports.isWebServerConstructor = isWebServerConstructor;
|
|
4
5
|
const logger_provider_1 = require("../provider/logger/logger.provider");
|
|
5
6
|
/**
|
|
6
7
|
* Type guard to check if input is a constructor type of IWebServer.
|
|
@@ -14,23 +15,21 @@ function isWebServerConstructor(input) {
|
|
|
14
15
|
* AppFactory Class
|
|
15
16
|
*
|
|
16
17
|
* Responsible for creating an instance of the IWebServer implementation using a custom application type.
|
|
18
|
+
* @public API
|
|
17
19
|
*/
|
|
18
20
|
class AppFactory {
|
|
19
21
|
/**
|
|
20
22
|
* Create an instance of a web server.
|
|
21
|
-
* @param container - Dependency injection container.
|
|
22
23
|
* @param webServerType - Constructor of a class that implements IWebServer.
|
|
23
24
|
* @returns A promise that resolves to an instance of IWebServer.
|
|
24
25
|
*/
|
|
25
|
-
static async create(
|
|
26
|
-
AppFactory.container = container;
|
|
26
|
+
static async create(webServerType) {
|
|
27
27
|
if (isWebServerConstructor(webServerType)) {
|
|
28
28
|
const webServerInstance = new webServerType();
|
|
29
|
-
await webServerInstance.configure(container);
|
|
30
29
|
return webServerInstance;
|
|
31
30
|
}
|
|
32
31
|
else {
|
|
33
|
-
|
|
32
|
+
AppFactory.logger.error("Invalid web server type.", "app-factory:create");
|
|
34
33
|
throw new Error("Invalid web server type.");
|
|
35
34
|
}
|
|
36
35
|
}
|
|
@@ -5,6 +5,7 @@ exports.ServerEnvironment = void 0;
|
|
|
5
5
|
* Enum representing possible server environments.
|
|
6
6
|
* @options Development - Development environment.
|
|
7
7
|
* @options Production - Production environment.
|
|
8
|
+
* @public API
|
|
8
9
|
*/
|
|
9
10
|
var ServerEnvironment;
|
|
10
11
|
(function (ServerEnvironment) {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AppFactory = exports.AppContainer = void 0;
|
|
3
|
+
exports.ServerEnvironment = exports.AppFactory = exports.AppContainer = void 0;
|
|
4
4
|
var application_container_1 = require("./application-container");
|
|
5
5
|
Object.defineProperty(exports, "AppContainer", { enumerable: true, get: function () { return application_container_1.AppContainer; } });
|
|
6
6
|
var application_factory_1 = require("./application-factory");
|
|
7
7
|
Object.defineProperty(exports, "AppFactory", { enumerable: true, get: function () { return application_factory_1.AppFactory; } });
|
|
8
|
+
var application_types_1 = require("./application.types");
|
|
9
|
+
Object.defineProperty(exports, "ServerEnvironment", { enumerable: true, get: function () { return application_types_1.ServerEnvironment; } });
|
|
@@ -1,19 +1,13 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
3
|
exports.Console = void 0;
|
|
10
|
-
const
|
|
11
|
-
const color_codes_1 = require("
|
|
4
|
+
const process_1 = require("process");
|
|
5
|
+
const color_codes_1 = require("./color-codes");
|
|
12
6
|
/**
|
|
13
7
|
* The Console class provides methods for displaying styled messages in the console.
|
|
14
8
|
* @provide Console
|
|
15
9
|
*/
|
|
16
|
-
|
|
10
|
+
class Console {
|
|
17
11
|
/**
|
|
18
12
|
* Print a message to the console with the specified color style.
|
|
19
13
|
* @param message - The message to be printed.
|
|
@@ -22,7 +16,7 @@ let Console = class Console {
|
|
|
22
16
|
async printColor(message, colorStyle) {
|
|
23
17
|
const textColor = "black";
|
|
24
18
|
const bgColor = colorStyle;
|
|
25
|
-
|
|
19
|
+
process_1.stdout.write(`${color_codes_1.bgColorCodes[bgColor]}${color_codes_1.colorCodes[textColor]}${message}\x1b[0m\n`);
|
|
26
20
|
}
|
|
27
21
|
/**
|
|
28
22
|
* Display a message in the console with details about the running server.
|
|
@@ -32,7 +26,7 @@ let Console = class Console {
|
|
|
32
26
|
*/
|
|
33
27
|
async messageServer(port, environment, consoleMessage) {
|
|
34
28
|
const appConsoleMessage = {
|
|
35
|
-
appName: consoleMessage?.appName || "
|
|
29
|
+
appName: consoleMessage?.appName || "App",
|
|
36
30
|
appVersion: consoleMessage?.appVersion || "not provided",
|
|
37
31
|
};
|
|
38
32
|
let terminalColor = color_codes_1.ColorStyle.None;
|
|
@@ -40,9 +34,6 @@ let Console = class Console {
|
|
|
40
34
|
case "development":
|
|
41
35
|
terminalColor = color_codes_1.ColorStyle.Yellow;
|
|
42
36
|
break;
|
|
43
|
-
case "staging":
|
|
44
|
-
terminalColor = color_codes_1.ColorStyle.Blue;
|
|
45
|
-
break;
|
|
46
37
|
case "production":
|
|
47
38
|
terminalColor = color_codes_1.ColorStyle.Green;
|
|
48
39
|
break;
|
|
@@ -50,11 +41,8 @@ let Console = class Console {
|
|
|
50
41
|
terminalColor = color_codes_1.ColorStyle.Red;
|
|
51
42
|
break;
|
|
52
43
|
}
|
|
53
|
-
this.printColor(
|
|
54
|
-
`port ${port} - Environment: ${environment}`, terminalColor);
|
|
44
|
+
this.printColor(`[${appConsoleMessage.appName}] version [${appConsoleMessage.appVersion}] is running on ` +
|
|
45
|
+
`port [${port}] - Environment: [${environment}]`, terminalColor);
|
|
55
46
|
}
|
|
56
|
-
}
|
|
47
|
+
}
|
|
57
48
|
exports.Console = Console;
|
|
58
|
-
exports.Console = Console = __decorate([
|
|
59
|
-
(0, inversify_binding_decorators_1.provide)(Console)
|
|
60
|
-
], Console);
|
|
@@ -1,18 +1,11 @@
|
|
|
1
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 BaseModule_1;
|
|
9
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
3
|
exports.scope = exports.CreateModule = exports.BaseModule = exports.BINDING_TYPE_METADATA_KEY = void 0;
|
|
11
4
|
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
12
5
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
13
|
-
const inversify_1 = require("inversify");
|
|
14
|
-
const inversify_binding_decorators_1 = require("inversify-binding-decorators");
|
|
6
|
+
const inversify_1 = require("../di/inversify");
|
|
15
7
|
const decorator_1 = require("../decorator");
|
|
8
|
+
const binding_decorator_1 = require("../di/binding-decorator");
|
|
16
9
|
/**
|
|
17
10
|
* Key to be used for storing and retrieving binding type metadata.
|
|
18
11
|
*/
|
|
@@ -21,6 +14,7 @@ exports.BINDING_TYPE_METADATA_KEY = "binding-type";
|
|
|
21
14
|
* The scope decorator is a higher order function that can be used to decorate a class with a binding type.
|
|
22
15
|
* @param binding An instance of interfaces.BindingScope which represents the binding type.
|
|
23
16
|
* @returns A decorator function that can be used to decorate a class with a binding type.
|
|
17
|
+
* @public API
|
|
24
18
|
*/
|
|
25
19
|
const scope = (binding) => {
|
|
26
20
|
return function (target) {
|
|
@@ -34,7 +28,7 @@ const scope = (binding) => {
|
|
|
34
28
|
(0, decorator_1.provideTransient)(target);
|
|
35
29
|
break;
|
|
36
30
|
default:
|
|
37
|
-
(0,
|
|
31
|
+
(0, binding_decorator_1.provide)(target);
|
|
38
32
|
break;
|
|
39
33
|
}
|
|
40
34
|
}
|
|
@@ -45,7 +39,7 @@ exports.scope = scope;
|
|
|
45
39
|
* The BaseModule class provides methods for creating InversifyJS container modules.
|
|
46
40
|
* @provide BaseModule
|
|
47
41
|
*/
|
|
48
|
-
|
|
42
|
+
class BaseModule {
|
|
49
43
|
/**
|
|
50
44
|
* Create a map of symbols for the provided controllers.
|
|
51
45
|
* @param controllers - An array of controller classes.
|
|
@@ -82,25 +76,23 @@ let BaseModule = BaseModule_1 = class BaseModule {
|
|
|
82
76
|
* @param controllers - An array of controller classes.
|
|
83
77
|
* @param scope - An optional binding scope to be used for all controllers.
|
|
84
78
|
* @returns A ContainerModule with the controller bindings.
|
|
79
|
+
* @public API
|
|
85
80
|
*/
|
|
86
81
|
static createContainerModule(controllers, scope) {
|
|
87
|
-
const symbols =
|
|
82
|
+
const symbols = BaseModule.createSymbols(controllers);
|
|
88
83
|
return new inversify_1.ContainerModule((bind) => {
|
|
89
84
|
for (const [symbol, target] of symbols) {
|
|
90
85
|
if (scope) {
|
|
91
|
-
|
|
86
|
+
BaseModule.bindToScope(symbol, target, scope, bind);
|
|
92
87
|
}
|
|
93
88
|
else {
|
|
94
89
|
const bindingType = Reflect.getMetadata(exports.BINDING_TYPE_METADATA_KEY, target);
|
|
95
|
-
|
|
90
|
+
BaseModule.bindToScope(symbol, target, bindingType, bind);
|
|
96
91
|
}
|
|
97
92
|
}
|
|
98
93
|
});
|
|
99
94
|
}
|
|
100
|
-
}
|
|
95
|
+
}
|
|
101
96
|
exports.BaseModule = BaseModule;
|
|
102
|
-
exports.BaseModule = BaseModule = BaseModule_1 = __decorate([
|
|
103
|
-
(0, inversify_binding_decorators_1.provide)(BaseModule)
|
|
104
|
-
], BaseModule);
|
|
105
97
|
const CreateModule = BaseModule.createContainerModule;
|
|
106
98
|
exports.CreateModule = CreateModule;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.provideTransient = exports.provideSingleton = exports.provide = void 0;
|
|
4
2
|
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
5
3
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
6
|
-
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.provideTransient = exports.provideSingleton = exports.provide = void 0;
|
|
6
|
+
const binding_decorator_1 = require("../di/binding-decorator");
|
|
7
7
|
/**
|
|
8
8
|
* Provides a binding for the given identifier.
|
|
9
9
|
*
|
|
@@ -12,18 +12,18 @@ const inversify_binding_decorators_1 = require("inversify-binding-decorators");
|
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* ```typescript
|
|
15
|
-
*
|
|
15
|
+
* provide(ServiceIdentifier)
|
|
16
16
|
* class MyService {}
|
|
17
17
|
* ```
|
|
18
|
+
* @public API
|
|
18
19
|
*/
|
|
19
20
|
const provide = (identifier) => {
|
|
20
|
-
return (0,
|
|
21
|
+
return (0, binding_decorator_1.fluentProvide)(identifier).done();
|
|
21
22
|
};
|
|
22
23
|
exports.provide = provide;
|
|
23
24
|
/**
|
|
24
25
|
* Provides a singleton binding for the given identifier.
|
|
25
26
|
*
|
|
26
|
-
* @remarks
|
|
27
27
|
* Singleton binding ensures that the same instance of a dependency is reused within the entire container.
|
|
28
28
|
*
|
|
29
29
|
* @param identifier - The identifier (e.g., symbol, string, class) for the dependency being registered.
|
|
@@ -31,18 +31,18 @@ exports.provide = provide;
|
|
|
31
31
|
*
|
|
32
32
|
* @example
|
|
33
33
|
* ```typescript
|
|
34
|
-
*
|
|
34
|
+
* provideSingleton(ServiceIdentifier)
|
|
35
35
|
* class MyService {}
|
|
36
36
|
* ```
|
|
37
|
+
* @public API
|
|
37
38
|
*/
|
|
38
39
|
const provideSingleton = (identifier) => {
|
|
39
|
-
return (0,
|
|
40
|
+
return (0, binding_decorator_1.fluentProvide)(identifier).inSingletonScope().done();
|
|
40
41
|
};
|
|
41
42
|
exports.provideSingleton = provideSingleton;
|
|
42
43
|
/**
|
|
43
44
|
* Provides a transient binding for the given identifier.
|
|
44
45
|
*
|
|
45
|
-
* @remarks
|
|
46
46
|
* Transient binding ensures that a new instance of a dependency is created every time it is resolved.
|
|
47
47
|
*
|
|
48
48
|
* @param identifier - The identifier (e.g., symbol, string, class) for the dependency being registered.
|
|
@@ -50,11 +50,12 @@ exports.provideSingleton = provideSingleton;
|
|
|
50
50
|
*
|
|
51
51
|
* @example
|
|
52
52
|
* ```typescript
|
|
53
|
-
*
|
|
53
|
+
* provideTransient(ServiceIdentifier)
|
|
54
54
|
* class MyService {}
|
|
55
55
|
* ```
|
|
56
|
+
* @public API
|
|
56
57
|
*/
|
|
57
58
|
const provideTransient = (identifier) => {
|
|
58
|
-
return (0,
|
|
59
|
+
return (0, binding_decorator_1.fluentProvide)(identifier).inTransientScope().done();
|
|
59
60
|
};
|
|
60
61
|
exports.provideTransient = provideTransient;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.decorate = decorate;
|
|
27
|
+
exports.tagParameter = tagParameter;
|
|
28
|
+
exports.tagProperty = tagProperty;
|
|
29
|
+
exports.createTaggedDecorator = createTaggedDecorator;
|
|
30
|
+
const ERROR_MSGS = __importStar(require("../constants/error_msgs"));
|
|
31
|
+
const METADATA_KEY = __importStar(require("../constants/metadata_keys"));
|
|
32
|
+
const js_1 = require("../utils/js");
|
|
33
|
+
function targetIsConstructorFunction(target) {
|
|
34
|
+
return target.prototype !== undefined;
|
|
35
|
+
}
|
|
36
|
+
function _throwIfMethodParameter(parameterName) {
|
|
37
|
+
if (parameterName !== undefined) {
|
|
38
|
+
throw new Error(ERROR_MSGS.INVALID_DECORATOR_OPERATION);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function tagParameter(annotationTarget, parameterName, parameterIndex, metadata) {
|
|
42
|
+
_throwIfMethodParameter(parameterName);
|
|
43
|
+
_tagParameterOrProperty(METADATA_KEY.TAGGED, annotationTarget, parameterIndex.toString(), metadata);
|
|
44
|
+
}
|
|
45
|
+
function tagProperty(annotationTarget, propertyName, metadata) {
|
|
46
|
+
if (targetIsConstructorFunction(annotationTarget)) {
|
|
47
|
+
throw new Error(ERROR_MSGS.INVALID_DECORATOR_OPERATION);
|
|
48
|
+
}
|
|
49
|
+
_tagParameterOrProperty(METADATA_KEY.TAGGED_PROP, annotationTarget.constructor, propertyName, metadata);
|
|
50
|
+
}
|
|
51
|
+
function _ensureNoMetadataKeyDuplicates(metadata) {
|
|
52
|
+
let metadatas = [];
|
|
53
|
+
if (Array.isArray(metadata)) {
|
|
54
|
+
metadatas = metadata;
|
|
55
|
+
const duplicate = (0, js_1.getFirstArrayDuplicate)(metadatas.map((md) => md.key));
|
|
56
|
+
if (duplicate !== undefined) {
|
|
57
|
+
throw new Error(`${ERROR_MSGS.DUPLICATED_METADATA} ${duplicate.toString()}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
metadatas = [metadata];
|
|
62
|
+
}
|
|
63
|
+
return metadatas;
|
|
64
|
+
}
|
|
65
|
+
function _tagParameterOrProperty(metadataKey, annotationTarget, key, metadata) {
|
|
66
|
+
const metadatas = _ensureNoMetadataKeyDuplicates(metadata);
|
|
67
|
+
let paramsOrPropertiesMetadata = {};
|
|
68
|
+
// read metadata if available
|
|
69
|
+
if (Reflect.hasOwnMetadata(metadataKey, annotationTarget)) {
|
|
70
|
+
paramsOrPropertiesMetadata = Reflect.getMetadata(metadataKey, annotationTarget);
|
|
71
|
+
}
|
|
72
|
+
let paramOrPropertyMetadata = paramsOrPropertiesMetadata[key];
|
|
73
|
+
if (paramOrPropertyMetadata === undefined) {
|
|
74
|
+
paramOrPropertyMetadata = [];
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
for (const m of paramOrPropertyMetadata) {
|
|
78
|
+
if (metadatas.some((md) => md.key === m.key)) {
|
|
79
|
+
throw new Error(`${ERROR_MSGS.DUPLICATED_METADATA} ${m.key.toString()}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// set metadata
|
|
84
|
+
paramOrPropertyMetadata.push(...metadatas);
|
|
85
|
+
paramsOrPropertiesMetadata[key] = paramOrPropertyMetadata;
|
|
86
|
+
Reflect.defineMetadata(metadataKey, paramsOrPropertiesMetadata, annotationTarget);
|
|
87
|
+
}
|
|
88
|
+
function createTaggedDecorator(metadata) {
|
|
89
|
+
return (target, targetKey, indexOrPropertyDescriptor) => {
|
|
90
|
+
if (typeof indexOrPropertyDescriptor === "number") {
|
|
91
|
+
tagParameter(target, targetKey, indexOrPropertyDescriptor, metadata);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
tagProperty(target, targetKey, metadata);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function _decorate(decorators, target) {
|
|
99
|
+
Reflect.decorate(decorators, target);
|
|
100
|
+
}
|
|
101
|
+
function _param(paramIndex, decorator) {
|
|
102
|
+
return function (target, key) {
|
|
103
|
+
decorator(target, key, paramIndex);
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
// Allows VanillaJS developers to use decorators:
|
|
107
|
+
// decorate(injectable(), FooBar);
|
|
108
|
+
// decorate(targetName('foo', 'bar'), FooBar);
|
|
109
|
+
// decorate(named('foo'), FooBar, 0);
|
|
110
|
+
// decorate(tagged('bar'), FooBar, 1);
|
|
111
|
+
function decorate(decorator, target, parameterIndexOrProperty) {
|
|
112
|
+
if (typeof parameterIndexOrProperty === "number") {
|
|
113
|
+
_decorate([_param(parameterIndexOrProperty, decorator)], target);
|
|
114
|
+
}
|
|
115
|
+
else if (typeof parameterIndexOrProperty === "string") {
|
|
116
|
+
Reflect.decorate([decorator], target, parameterIndexOrProperty);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
_decorate([decorator], target);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.inject = void 0;
|
|
27
|
+
const METADATA_KEY = __importStar(require("../constants/metadata_keys"));
|
|
28
|
+
const inject_base_1 = require("./inject_base");
|
|
29
|
+
/**
|
|
30
|
+
* Marks a constructor parameter for injection.
|
|
31
|
+
* @param serviceIdentifier The service identifier
|
|
32
|
+
* @return The decorator function
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* class Engine {}
|
|
36
|
+
*
|
|
37
|
+
* class Car {
|
|
38
|
+
* constructor(@inject(Engine) engine: Engine) {}
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
* @public API
|
|
42
|
+
*/
|
|
43
|
+
const inject = (0, inject_base_1.injectBase)(METADATA_KEY.INJECT_TAG);
|
|
44
|
+
exports.inject = inject;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.injectBase = injectBase;
|
|
4
|
+
const error_msgs_1 = require("../constants/error_msgs");
|
|
5
|
+
const metadata_1 = require("../planning/metadata");
|
|
6
|
+
const decorator_utils_1 = require("./decorator_utils");
|
|
7
|
+
function injectBase(metadataKey) {
|
|
8
|
+
return (serviceIdentifier) => {
|
|
9
|
+
return (target, targetKey, indexOrPropertyDescriptor) => {
|
|
10
|
+
if (serviceIdentifier === undefined) {
|
|
11
|
+
const className = typeof target === "function" ? target.name : target.constructor.name;
|
|
12
|
+
throw new Error((0, error_msgs_1.UNDEFINED_INJECT_ANNOTATION)(className));
|
|
13
|
+
}
|
|
14
|
+
return (0, decorator_utils_1.createTaggedDecorator)(new metadata_1.Metadata(metadataKey, serviceIdentifier))(target, targetKey, indexOrPropertyDescriptor);
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.injectable = injectable;
|
|
27
|
+
const ERRORS_MSGS = __importStar(require("../constants/error_msgs"));
|
|
28
|
+
const METADATA_KEY = __importStar(require("../constants/metadata_keys"));
|
|
29
|
+
/**
|
|
30
|
+
* Marks a class as injectable.
|
|
31
|
+
* @returns A decorator function
|
|
32
|
+
* @public API
|
|
33
|
+
*/
|
|
34
|
+
function injectable() {
|
|
35
|
+
return function (target) {
|
|
36
|
+
if (Reflect.hasOwnMetadata(METADATA_KEY.PARAM_TYPES, target)) {
|
|
37
|
+
throw new Error(ERRORS_MSGS.DUPLICATED_INJECTABLE_DECORATOR);
|
|
38
|
+
}
|
|
39
|
+
const types = Reflect.getMetadata(METADATA_KEY.DESIGN_PARAM_TYPES, target) || [];
|
|
40
|
+
Reflect.defineMetadata(METADATA_KEY.PARAM_TYPES, types, target);
|
|
41
|
+
return target;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LazyServiceIdentifier = void 0;
|
|
4
|
+
class LazyServiceIdentifier {
|
|
5
|
+
constructor(cb) {
|
|
6
|
+
this._cb = cb;
|
|
7
|
+
}
|
|
8
|
+
unwrap() {
|
|
9
|
+
return this._cb();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.LazyServiceIdentifier = LazyServiceIdentifier;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.multiInject = void 0;
|
|
27
|
+
const METADATA_KEY = __importStar(require("../constants/metadata_keys"));
|
|
28
|
+
const inject_base_1 = require("./inject_base");
|
|
29
|
+
const multiInject = (0, inject_base_1.injectBase)(METADATA_KEY.MULTI_INJECT_TAG);
|
|
30
|
+
exports.multiInject = multiInject;
|