@adaas/a-concept 0.0.2
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/.nvmrc +1 -0
- package/LICENSE +22 -0
- package/README.md +19 -0
- package/dist/examples/sdk/concept.d.ts +0 -0
- package/dist/examples/sdk/concept.js +21 -0
- package/dist/examples/sdk/concept.js.map +1 -0
- package/dist/examples/sdk/orders.api.d.ts +0 -0
- package/dist/examples/sdk/orders.api.js +16 -0
- package/dist/examples/sdk/orders.api.js.map +1 -0
- package/dist/examples/sdk/users.api.d.ts +0 -0
- package/dist/examples/sdk/users.api.js +16 -0
- package/dist/examples/sdk/users.api.js.map +1 -0
- package/dist/examples/simple/concept.d.ts +0 -0
- package/dist/examples/simple/concept.js +13 -0
- package/dist/examples/simple/concept.js.map +1 -0
- package/dist/examples/simple-http-server/concept.d.ts +1 -0
- package/dist/examples/simple-http-server/concept.js +36 -0
- package/dist/examples/simple-http-server/concept.js.map +1 -0
- package/dist/examples/simple-http-server/containers/http-server.container.d.ts +12 -0
- package/dist/examples/simple-http-server/containers/http-server.container.js +69 -0
- package/dist/examples/simple-http-server/containers/http-server.container.js.map +1 -0
- package/dist/examples/simple-http-server/containers/http-server.controller.d.ts +7 -0
- package/dist/examples/simple-http-server/containers/http-server.controller.js +37 -0
- package/dist/examples/simple-http-server/containers/http-server.controller.js.map +1 -0
- package/dist/examples/simple-http-server/containers/http-server.router.d.ts +6 -0
- package/dist/examples/simple-http-server/containers/http-server.router.js +39 -0
- package/dist/examples/simple-http-server/containers/http-server.router.js.map +1 -0
- package/dist/examples/simple-http-server/contexts/http-server.context.types.d.ts +4 -0
- package/dist/examples/simple-http-server/contexts/http-server.context.types.js +100 -0
- package/dist/examples/simple-http-server/contexts/http-server.context.types.js.map +1 -0
- package/dist/examples/simple-http-server/contexts/http-server.namespace.d.ts +10 -0
- package/dist/examples/simple-http-server/contexts/http-server.namespace.js +26 -0
- package/dist/examples/simple-http-server/contexts/http-server.namespace.js.map +1 -0
- package/dist/examples/simple-http-server/controllers/orders.controller.d.ts +5 -0
- package/dist/examples/simple-http-server/controllers/orders.controller.js +32 -0
- package/dist/examples/simple-http-server/controllers/orders.controller.js.map +1 -0
- package/dist/examples/simple-http-server/controllers/users.controller.d.ts +0 -0
- package/dist/examples/simple-http-server/controllers/users.controller.js +87 -0
- package/dist/examples/simple-http-server/controllers/users.controller.js.map +1 -0
- package/dist/examples/simple-http-server/modules/simple-http-server.context.d.ts +5 -0
- package/dist/examples/simple-http-server/modules/simple-http-server.context.js +25 -0
- package/dist/examples/simple-http-server/modules/simple-http-server.context.js.map +1 -0
- package/dist/examples/simple-http-server/modules/simple-http-server.module.d.ts +16 -0
- package/dist/examples/simple-http-server/modules/simple-http-server.module.js +8 -0
- package/dist/examples/simple-http-server/modules/simple-http-server.module.js.map +1 -0
- package/dist/examples/simple-http-server/modules/simple-http-server.types.d.ts +2 -0
- package/dist/examples/simple-http-server/modules/simple-http-server.types.js +3 -0
- package/dist/examples/simple-http-server/modules/simple-http-server.types.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/src/constants/A_ConceptLifecycle.constants.d.ts +2 -0
- package/dist/src/constants/A_ConceptLifecycle.constants.js +12 -0
- package/dist/src/constants/A_ConceptLifecycle.constants.js.map +1 -0
- package/dist/src/containers/A-Config/A-Config.container.d.ts +7 -0
- package/dist/src/containers/A-Config/A-Config.container.js +65 -0
- package/dist/src/containers/A-Config/A-Config.container.js.map +1 -0
- package/dist/src/containers/A-Config/A-Config.namespace.d.ts +28 -0
- package/dist/src/containers/A-Config/A-Config.namespace.js +54 -0
- package/dist/src/containers/A-Config/A-Config.namespace.js.map +1 -0
- package/dist/src/containers/A-Config/A-Config.types.d.ts +12 -0
- package/dist/src/containers/A-Config/A-Config.types.js +3 -0
- package/dist/src/containers/A-Config/A-Config.types.js.map +1 -0
- package/dist/src/containers/A-Config/components/ConfigReader.component.d.ts +18 -0
- package/dist/src/containers/A-Config/components/ConfigReader.component.js +37 -0
- package/dist/src/containers/A-Config/components/ConfigReader.component.js.map +1 -0
- package/dist/src/containers/A-Config/components/ENVConfigReader.component.d.ts +10 -0
- package/dist/src/containers/A-Config/components/ENVConfigReader.component.js +37 -0
- package/dist/src/containers/A-Config/components/ENVConfigReader.component.js.map +1 -0
- package/dist/src/containers/A-Config/components/FileConfigReader.component.d.ts +11 -0
- package/dist/src/containers/A-Config/components/FileConfigReader.component.js +47 -0
- package/dist/src/containers/A-Config/components/FileConfigReader.component.js.map +1 -0
- package/dist/src/containers/A-Errors/A-Errors.container.d.ts +5 -0
- package/dist/src/containers/A-Errors/A-Errors.container.js +32 -0
- package/dist/src/containers/A-Errors/A-Errors.container.js.map +1 -0
- package/dist/src/containers/A-Errors/A-Errors.namespace.d.ts +40 -0
- package/dist/src/containers/A-Errors/A-Errors.namespace.js +76 -0
- package/dist/src/containers/A-Errors/A-Errors.namespace.js.map +1 -0
- package/dist/src/containers/A-Errors/A-Errors.types.d.ts +5 -0
- package/dist/src/containers/A-Errors/A-Errors.types.js +3 -0
- package/dist/src/containers/A-Errors/A-Errors.types.js.map +1 -0
- package/dist/src/containers/A-Logger/A-Logger.container.d.ts +6 -0
- package/dist/src/containers/A-Logger/A-Logger.container.js +41 -0
- package/dist/src/containers/A-Logger/A-Logger.container.js.map +1 -0
- package/dist/src/containers/A-Logger/A-Logger.namespace.d.ts +17 -0
- package/dist/src/containers/A-Logger/A-Logger.namespace.js +22 -0
- package/dist/src/containers/A-Logger/A-Logger.namespace.js.map +1 -0
- package/dist/src/containers/A-Logger/A-Logger.types.d.ts +0 -0
- package/dist/src/containers/A-Logger/A-Logger.types.js +2 -0
- package/dist/src/containers/A-Logger/A-Logger.types.js.map +1 -0
- package/dist/src/containers/A-Logger/components/Logger.component.d.ts +29 -0
- package/dist/src/containers/A-Logger/components/Logger.component.js +128 -0
- package/dist/src/containers/A-Logger/components/Logger.component.js.map +1 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-ConceptLifecycle.decorator.types.d.ts +34 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-ConceptLifecycle.decorator.types.js +3 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-ConceptLifecycle.decorator.types.js.map +1 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator.d.ts +11 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator.js +36 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator.js.map +1 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator.types.d.ts +7 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator.types.js +3 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator.types.js.map +1 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-Run/A-Run.decorator.d.ts +17 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-Run/A-Run.decorator.js +42 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-Run/A-Run.decorator.js.map +1 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-Run/A-Run.decorator.types.d.ts +8 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-Run/A-Run.decorator.types.js +3 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-Run/A-Run.decorator.types.js.map +1 -0
- package/dist/src/decorators/A-ConceptLifecycle/index.d.ts +7 -0
- package/dist/src/decorators/A-ConceptLifecycle/index.js +11 -0
- package/dist/src/decorators/A-ConceptLifecycle/index.js.map +1 -0
- package/dist/src/decorators/A-Feature/A-Feature.decorator.d.ts +0 -0
- package/dist/src/decorators/A-Feature/A-Feature.decorator.js +11 -0
- package/dist/src/decorators/A-Feature/A-Feature.decorator.js.map +1 -0
- package/dist/src/decorators/A-Feature/A-Feature.decorator.types.d.ts +0 -0
- package/dist/src/decorators/A-Feature/A-Feature.decorator.types.js +2 -0
- package/dist/src/decorators/A-Feature/A-Feature.decorator.types.js.map +1 -0
- package/dist/src/decorators/A-Inject/A-Inject.decorator.d.ts +22 -0
- package/dist/src/decorators/A-Inject/A-Inject.decorator.js +32 -0
- package/dist/src/decorators/A-Inject/A-Inject.decorator.js.map +1 -0
- package/dist/src/decorators/A-Inject/A-Inject.decorator.types.d.ts +4 -0
- package/dist/src/decorators/A-Inject/A-Inject.decorator.types.js +3 -0
- package/dist/src/decorators/A-Inject/A-Inject.decorator.types.js.map +1 -0
- package/dist/src/decorators/A_ConceptMethods.decorator.d.ts +0 -0
- package/dist/src/decorators/A_ConceptMethods.decorator.js +2 -0
- package/dist/src/decorators/A_ConceptMethods.decorator.js.map +1 -0
- package/dist/src/decorators/A_Lazy.decorator.d.ts +5 -0
- package/dist/src/decorators/A_Lazy.decorator.js +20 -0
- package/dist/src/decorators/A_Lazy.decorator.js.map +1 -0
- package/dist/src/global/A-Component/A-Component.class.d.ts +16 -0
- package/dist/src/global/A-Component/A-Component.class.js +18 -0
- package/dist/src/global/A-Component/A-Component.class.js.map +1 -0
- package/dist/src/global/A-Concept/A_Concept.class.d.ts +46 -0
- package/dist/src/global/A-Concept/A_Concept.class.js +106 -0
- package/dist/src/global/A-Concept/A_Concept.class.js.map +1 -0
- package/dist/src/global/A-Concept/A_Concept.types.d.ts +26 -0
- package/dist/src/global/A-Concept/A_Concept.types.js +3 -0
- package/dist/src/global/A-Concept/A_Concept.types.js.map +1 -0
- package/dist/src/global/A-Container/A-Container.class.d.ts +14 -0
- package/dist/src/global/A-Container/A-Container.class.js +21 -0
- package/dist/src/global/A-Container/A-Container.class.js.map +1 -0
- package/dist/src/global/A-Context/A-Context.class.d.ts +88 -0
- package/dist/src/global/A-Context/A-Context.class.js +118 -0
- package/dist/src/global/A-Context/A-Context.class.js.map +1 -0
- package/dist/src/global/A-Context/A-Context.types.d.ts +0 -0
- package/dist/src/global/A-Context/A-Context.types.js +2 -0
- package/dist/src/global/A-Context/A-Context.types.js.map +1 -0
- package/dist/src/global/A-Dependency/A-DependencyReference.class.d.ts +17 -0
- package/dist/src/global/A-Dependency/A-DependencyReference.class.js +67 -0
- package/dist/src/global/A-Dependency/A-DependencyReference.class.js.map +1 -0
- package/dist/src/global/A-Dependency/A-DependencyReference.types.d.ts +55 -0
- package/dist/src/global/A-Dependency/A-DependencyReference.types.js +3 -0
- package/dist/src/global/A-Dependency/A-DependencyReference.types.js.map +1 -0
- package/dist/src/global/A-Namespace/A_Namespace.class.d.ts +47 -0
- package/dist/src/global/A-Namespace/A_Namespace.class.js +112 -0
- package/dist/src/global/A-Namespace/A_Namespace.class.js.map +1 -0
- package/dist/src/global/A-Namespace/A_Namespace.types.d.ts +19 -0
- package/dist/src/global/A-Namespace/A_Namespace.types.js +3 -0
- package/dist/src/global/A-Namespace/A_Namespace.types.js.map +1 -0
- package/dist/src/managers/A_DependencyManager.class.d.ts +24 -0
- package/dist/src/managers/A_DependencyManager.class.js +129 -0
- package/dist/src/managers/A_DependencyManager.class.js.map +1 -0
- package/dist/src/storage/A_Concept.storage.d.ts +19 -0
- package/dist/src/storage/A_Concept.storage.js +29 -0
- package/dist/src/storage/A_Concept.storage.js.map +1 -0
- package/dist/src/types/A_DependencyManager.types.d.ts +15 -0
- package/dist/src/types/A_DependencyManager.types.js +3 -0
- package/dist/src/types/A_DependencyManager.types.js.map +1 -0
- package/dist/src/types/A_Module.types.d.ts +17 -0
- package/dist/src/types/A_Module.types.js +22 -0
- package/dist/src/types/A_Module.types.js.map +1 -0
- package/docs/logo.png +0 -0
- package/examples/sdk/concept.ts +24 -0
- package/examples/sdk/orders.api.ts +21 -0
- package/examples/sdk/users.api.ts +21 -0
- package/examples/simple/concept.ts +16 -0
- package/examples/simple-http-server/concept.ts +30 -0
- package/examples/simple-http-server/containers/http-server.container.ts +69 -0
- package/examples/simple-http-server/containers/http-server.controller.ts +24 -0
- package/examples/simple-http-server/containers/http-server.router.ts +23 -0
- package/examples/simple-http-server/contexts/http-server.context.types.ts +108 -0
- package/examples/simple-http-server/contexts/http-server.namespace.ts +36 -0
- package/examples/simple-http-server/controllers/orders.controller.ts +20 -0
- package/examples/simple-http-server/controllers/users.controller.ts +104 -0
- package/index.ts +14 -0
- package/jest.config.ts +22 -0
- package/package.json +73 -0
- package/src/constants/A_ConceptLifecycle.constants.ts +12 -0
- package/src/containers/A-Config/A-Config.container.ts +60 -0
- package/src/containers/A-Config/A-Config.namespace.ts +98 -0
- package/src/containers/A-Config/A-Config.types.ts +31 -0
- package/src/containers/A-Config/components/ConfigReader.component.ts +30 -0
- package/src/containers/A-Config/components/ENVConfigReader.component.ts +31 -0
- package/src/containers/A-Config/components/FileConfigReader.component.ts +42 -0
- package/src/containers/A-Errors/A-Errors.container.ts +14 -0
- package/src/containers/A-Errors/A-Errors.namespace.ts +104 -0
- package/src/containers/A-Errors/A-Errors.types.ts +6 -0
- package/src/containers/A-Logger/A-Logger.container.ts +22 -0
- package/src/containers/A-Logger/A-Logger.namespace.ts +26 -0
- package/src/containers/A-Logger/A-Logger.types.ts +0 -0
- package/src/containers/A-Logger/components/Logger.component.ts +169 -0
- package/src/decorators/A-ConceptLifecycle/A-ConceptLifecycle.decorator.types.ts +46 -0
- package/src/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator.ts +55 -0
- package/src/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator.types.ts +20 -0
- package/src/decorators/A-ConceptLifecycle/A-Run/A-Run.decorator.ts +62 -0
- package/src/decorators/A-ConceptLifecycle/A-Run/A-Run.decorator.types.ts +28 -0
- package/src/decorators/A-ConceptLifecycle/index.ts +9 -0
- package/src/decorators/A-Feature/A-Feature.decorator.ts +13 -0
- package/src/decorators/A-Feature/A-Feature.decorator.types.ts +0 -0
- package/src/decorators/A-Inject/A-Inject.decorator.ts +75 -0
- package/src/decorators/A-Inject/A-Inject.decorator.types.ts +10 -0
- package/src/decorators/A_ConceptMethods.decorator.ts +0 -0
- package/src/decorators/A_Lazy.decorator.ts +31 -0
- package/src/global/A-Component/A-Component.class.ts +33 -0
- package/src/global/A-Concept/A_Concept.class.ts +143 -0
- package/src/global/A-Concept/A_Concept.types.ts +44 -0
- package/src/global/A-Container/A-Container.class.ts +39 -0
- package/src/global/A-Context/A-Context.class.ts +230 -0
- package/src/global/A-Context/A-Context.types.ts +0 -0
- package/src/global/A-Dependency/A-DependencyReference.class.ts +61 -0
- package/src/global/A-Dependency/A-DependencyReference.types.ts +61 -0
- package/src/global/A-Namespace/A_Namespace.class.ts +128 -0
- package/src/global/A-Namespace/A_Namespace.types.ts +24 -0
- package/src/storage/A_Concept.storage.ts +45 -0
- package/src/types/A_Module.types.ts +23 -0
- package/tests/context.test.ts +124 -0
- package/tests/default.test.ts +159 -0
- package/tests/log.ts +54 -0
- package/tests/polyfill.test.ts +37 -0
- package/tsconfig.json +61 -0
- package/tslint.json +98 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.A_Context = void 0;
|
|
4
|
+
const a_utils_1 = require("@adaas/a-utils");
|
|
5
|
+
const A_Namespace_class_1 = require("../A-Namespace/A_Namespace.class");
|
|
6
|
+
const A_Component_class_1 = require("../A-Component/A-Component.class");
|
|
7
|
+
/**
|
|
8
|
+
* Namespace Provider is responsible for providing the Namespace to the Containers and other Namespaces.
|
|
9
|
+
* This class stores all Namespaces across the Program.
|
|
10
|
+
*
|
|
11
|
+
* Namespace provider is a singleton class that is used to store all the Namespaces in the program.
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
class A_Context {
|
|
15
|
+
constructor() {
|
|
16
|
+
/**
|
|
17
|
+
* Stores all the Namespaces by namespace.
|
|
18
|
+
* There might be a Namespaces of the same type but with different namespaces.
|
|
19
|
+
* That might be useful for the cases when you need to have multiple instances of the same Namespace e.g.
|
|
20
|
+
* - multiple http servers
|
|
21
|
+
* - multitenant applications
|
|
22
|
+
* - etc.
|
|
23
|
+
*/
|
|
24
|
+
this.namespaced = new Map();
|
|
25
|
+
/**
|
|
26
|
+
* Stores the singleton Namespaces.
|
|
27
|
+
* Singleton Namespaces are the Namespaces that are used only once in the program.
|
|
28
|
+
* In most cases, the singleton Namespace is the main Namespace of the program.
|
|
29
|
+
* It could be :
|
|
30
|
+
* - the main Namespace of the Program
|
|
31
|
+
* - the authentication Namespace
|
|
32
|
+
* - the main database Namespace
|
|
33
|
+
* - etc.
|
|
34
|
+
*/
|
|
35
|
+
this.singleton = new WeakMap();
|
|
36
|
+
/**
|
|
37
|
+
* Stores the components that are used in the program.
|
|
38
|
+
*/
|
|
39
|
+
this.components = new Map();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get the instance of the Namespace Provider.
|
|
43
|
+
*
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
static getInstance() {
|
|
47
|
+
if (!A_Context.instance) {
|
|
48
|
+
A_Context.instance = new A_Context();
|
|
49
|
+
}
|
|
50
|
+
return A_Context.instance;
|
|
51
|
+
}
|
|
52
|
+
static get root() {
|
|
53
|
+
return this.getInstance()._root;
|
|
54
|
+
}
|
|
55
|
+
static get environment() {
|
|
56
|
+
return a_utils_1.A_Polyfills.env;
|
|
57
|
+
}
|
|
58
|
+
static register(param1, param2) {
|
|
59
|
+
const instance = this.getInstance();
|
|
60
|
+
let Namespace;
|
|
61
|
+
let namespace;
|
|
62
|
+
if (typeof param2 === 'string') {
|
|
63
|
+
namespace = param2;
|
|
64
|
+
Namespace = param1;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
Namespace = param1;
|
|
68
|
+
namespace = Namespace.name;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* If the namespace is not provided, then use the root namespace.
|
|
72
|
+
* If the root namespace is not provided, then use the default namespace.
|
|
73
|
+
*/
|
|
74
|
+
if (!namespace)
|
|
75
|
+
namespace = this.root
|
|
76
|
+
|| process.env.ADAAS_NAMESPACE
|
|
77
|
+
|| process.env.A_NAMESPACE
|
|
78
|
+
|| process.env.ADAAS_APP_NAMESPACE
|
|
79
|
+
|| 'a-concept';
|
|
80
|
+
if (!this.root)
|
|
81
|
+
instance._root = namespace;
|
|
82
|
+
instance.namespaced.set(namespace, Namespace);
|
|
83
|
+
return namespace;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get the Namespace by namespace.
|
|
87
|
+
* @param namespace
|
|
88
|
+
*/
|
|
89
|
+
static get(namespace) {
|
|
90
|
+
const instance = this.getInstance();
|
|
91
|
+
return instance.namespaced.get(namespace);
|
|
92
|
+
}
|
|
93
|
+
static resolve(param1, param2) {
|
|
94
|
+
switch (true) {
|
|
95
|
+
// If the first parameter is a Namespace
|
|
96
|
+
case Array.isArray(param1) && param1.every(namespace => a_utils_1.A_CommonHelper.isInheritedFrom(namespace, A_Namespace_class_1.A_Namespace)):
|
|
97
|
+
return param1.map(namespace => this.resolveNamespace(namespace));
|
|
98
|
+
// If the first parameter is a Namespace and the second parameter is a string
|
|
99
|
+
case !!param2 && typeof param1 === 'function' && a_utils_1.A_CommonHelper.isInheritedFrom(param1, A_Namespace_class_1.A_Namespace):
|
|
100
|
+
return this.resolveNamespace(param1, param2);
|
|
101
|
+
// If the first parameter is a Component
|
|
102
|
+
case !!param2 && typeof param1 === 'function' && a_utils_1.A_CommonHelper.isInheritedFrom(param1, A_Component_class_1.A_Component):
|
|
103
|
+
return this.resolveComponent(param1);
|
|
104
|
+
default:
|
|
105
|
+
throw new Error(`[!] A-Concept Context: Unknown type of the parameter.`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
static resolveComponent(component) {
|
|
109
|
+
const instance = this.getInstance();
|
|
110
|
+
return instance.components.get(component.name);
|
|
111
|
+
}
|
|
112
|
+
static resolveNamespace(param1, param2) {
|
|
113
|
+
const instance = this.getInstance();
|
|
114
|
+
return instance.namespaced.get(param2 || param1.name);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.A_Context = A_Context;
|
|
118
|
+
//# sourceMappingURL=A-Context.class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"A-Context.class.js","sourceRoot":"","sources":["../../../../src/global/A-Context/A-Context.class.ts"],"names":[],"mappings":";;;AAAA,4CAA6D;AAC7D,wEAA+D;AAC/D,wEAA+D;AAG/D;;;;;;GAMG;AACH,MAAa,SAAS;IAuClB;QAlCA;;;;;;;WAOG;QACH,eAAU,GAA6B,IAAI,GAAG,EAAE,CAAC;QAEjD;;;;;;;;;WASG;QACH,cAAS,GAA+D,IAAI,OAAO,EAAE,CAAC;QAGtF;;WAEG;QACH,eAAU,GAAqB,IAAI,GAAG,EAAE,CAAC;IAUzC,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,WAAW;QACd,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;YACtB,SAAS,CAAC,QAAQ,GAAG,IAAI,SAAS,EAAE,CAAC;QACzC,CAAC;QAED,OAAO,SAAS,CAAC,QAAQ,CAAC;IAC9B,CAAC;IAED,MAAM,KAAK,IAAI;QACX,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC;IACpC,CAAC;IAED,MAAM,KAAK,WAAW;QAClB,OAAO,qBAAW,CAAC,GAAG,CAAC;IAC3B,CAAC;IAWD,MAAM,CAAC,QAAQ,CACX,MAAmB,EACnB,MAA6B;QAG7B,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAEpC,IAAI,SAAsB,CAAC;QAC3B,IAAI,SAAiB,CAAC;QAEtB,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC7B,SAAS,GAAG,MAAM,CAAC;YACnB,SAAS,GAAG,MAAM,CAAC;QACvB,CAAC;aAAM,CAAC;YACJ,SAAS,GAAG,MAAqB,CAAC;YAClC,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC;QAC/B,CAAC;QAED;;;WAGG;QACH,IAAI,CAAC,SAAS;YACV,SAAS,GAAG,IAAI,CA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,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAA8C,CAAM,CAAC;YAEtF;gBACI,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;QACjF,CAAC;IACL,CAAC;IAIO,MAAM,CAAC,gBAAgB,CAC3B,SAAqC;QAErC,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAEpC,OAAO,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAM,CAAC;IACxD,CAAC;IAkBO,MAAM,CAAC,gBAAgB,CAC3B,MAAkC,EAClC,MAAe;QAEf,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAEpC,OAAO,QAAQ,CAAC,UAAU,CAAC,GAAG,CAC1B,MAAM,IAAI,MAAM,CAAC,IAAI,CACnB,CAAC;IACX,CAAC;CAIJ;AAzND,8BAyNC"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"A-Context.types.js","sourceRoot":"","sources":["../../../../src/global/A-Context/A-Context.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare class RealDependency {
|
|
2
|
+
private name;
|
|
3
|
+
constructor(name: string);
|
|
4
|
+
getName(): string;
|
|
5
|
+
performAction(): void;
|
|
6
|
+
}
|
|
7
|
+
declare class DependencyReference<T> {
|
|
8
|
+
private realClass;
|
|
9
|
+
private args;
|
|
10
|
+
private proxyInstance;
|
|
11
|
+
private realInstance;
|
|
12
|
+
constructor(realClass: {
|
|
13
|
+
new (...args: any[]): T;
|
|
14
|
+
}, args: any[]);
|
|
15
|
+
private loadInstance;
|
|
16
|
+
resolve(): Promise<T>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
class RealDependency {
|
|
12
|
+
constructor(name) {
|
|
13
|
+
this.name = name;
|
|
14
|
+
}
|
|
15
|
+
getName() {
|
|
16
|
+
return this.name;
|
|
17
|
+
}
|
|
18
|
+
performAction() {
|
|
19
|
+
console.log(`${this.name} is performing an action.`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
class DependencyReference {
|
|
23
|
+
constructor(realClass, args) {
|
|
24
|
+
this.realClass = realClass;
|
|
25
|
+
this.args = args;
|
|
26
|
+
this.proxyInstance = null;
|
|
27
|
+
this.realInstance = null;
|
|
28
|
+
}
|
|
29
|
+
// Simulate async loading (e.g., dynamic imports, API calls, etc.)
|
|
30
|
+
loadInstance() {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
if (!this.realInstance) {
|
|
33
|
+
console.log('Loading real dependency...');
|
|
34
|
+
// Simulate async loading with a delay
|
|
35
|
+
yield new Promise((resolve) => setTimeout(resolve, 1000));
|
|
36
|
+
this.realInstance = new this.realClass(...this.args);
|
|
37
|
+
}
|
|
38
|
+
return this.realInstance;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
resolve() {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
if (!this.proxyInstance) {
|
|
44
|
+
const realInstance = yield this.loadInstance();
|
|
45
|
+
this.proxyInstance = new Proxy({}, {
|
|
46
|
+
get: (target, prop) => {
|
|
47
|
+
const value = realInstance[prop];
|
|
48
|
+
// If the property is a method, return a bound function
|
|
49
|
+
if (typeof value === 'function') {
|
|
50
|
+
return value.bind(realInstance);
|
|
51
|
+
}
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return this.proxyInstance;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// Example usage:
|
|
61
|
+
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
62
|
+
const lazyDependency = new DependencyReference(RealDependency, ['ComponentA']);
|
|
63
|
+
const proxy = yield lazyDependency.resolve(); // Loads the instance asynchronously
|
|
64
|
+
proxy.performAction(); // Will call the method on the real instance
|
|
65
|
+
console.log(proxy.getName()); // Calls method on the real instance
|
|
66
|
+
}))();
|
|
67
|
+
//# sourceMappingURL=A-DependencyReference.class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"A-DependencyReference.class.js","sourceRoot":"","sources":["../../../../src/global/A-Dependency/A-DependencyReference.class.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,MAAM,cAAc;IAChB,YAAoB,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAI,CAAC;IAErC,OAAO;QACH,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,aAAa;QACT,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,2BAA2B,CAAC,CAAC;IACzD,CAAC;CACJ;AAED,MAAM,mBAAmB;IAIrB,YAAoB,SAAqC,EAAU,IAAW;QAA1D,cAAS,GAAT,SAAS,CAA4B;QAAU,SAAI,GAAJ,IAAI,CAAO;QAHtE,kBAAa,GAAa,IAAI,CAAC;QAC/B,iBAAY,GAAa,IAAI,CAAC;IAE4C,CAAC;IAEnF,kEAAkE;IACpD,YAAY;;YACtB,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;gBACrB,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;gBAC1C,s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1,55 @@
|
|
|
1
|
+
import { A_Namespace } from "../A-Namespace/A_Namespace.class";
|
|
2
|
+
export type A_TYPES__A_DependencyReferenceConstructor = {
|
|
3
|
+
/**
|
|
4
|
+
* The name of the dependency
|
|
5
|
+
*/
|
|
6
|
+
name: string;
|
|
7
|
+
/**
|
|
8
|
+
* The version of the module
|
|
9
|
+
* By default it is 1.0.0
|
|
10
|
+
*/
|
|
11
|
+
version: string;
|
|
12
|
+
/**
|
|
13
|
+
* The dependencies of the module
|
|
14
|
+
* Could be:
|
|
15
|
+
* - other Modules
|
|
16
|
+
* - other Contexts
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
dependencies: Array<typeof A_Namespace>;
|
|
20
|
+
/**
|
|
21
|
+
* The source of the dependency
|
|
22
|
+
* Could be:
|
|
23
|
+
* - a string representing the path to the module
|
|
24
|
+
* - a module class (in case when config should be provided via the module constructor)
|
|
25
|
+
* - a module class constructor
|
|
26
|
+
* - a context class (in case when config should be provided via the context constructor)
|
|
27
|
+
* - a context class constructor
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
source: A_Namespace;
|
|
31
|
+
};
|
|
32
|
+
export type A_TYPES__A_DependencyReferenceConstructorConfig = {
|
|
33
|
+
/**
|
|
34
|
+
* Sync - blocks A-Express Application initialization until module is ready
|
|
35
|
+
* Async - allows to initialize module after A-Express Application initialization
|
|
36
|
+
*/
|
|
37
|
+
behavior: 'async' | 'sync';
|
|
38
|
+
/**
|
|
39
|
+
* Allows to define a scheme of retries
|
|
40
|
+
*/
|
|
41
|
+
retries: {
|
|
42
|
+
/**
|
|
43
|
+
* The number of retries
|
|
44
|
+
* Default is 3
|
|
45
|
+
*/
|
|
46
|
+
n: number;
|
|
47
|
+
/**
|
|
48
|
+
* The timeout between retries
|
|
49
|
+
* Multiplied by the number of retries
|
|
50
|
+
* So after each retry the timeout is increased e.g. 1000ms * 1, 1000ms * 2, 1000ms * 3
|
|
51
|
+
* Default is 1000
|
|
52
|
+
*/
|
|
53
|
+
timeout: number;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"A-DependencyReference.types.js","sourceRoot":"","sources":["../../../../src/global/A-Dependency/A-DependencyReference.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { A_TYPES__NamespaceConstructor, A_TYPES__INamespace } from './A_Namespace.types';
|
|
2
|
+
/**
|
|
3
|
+
* A_Namespace is a base class for all Namespaces in the A
|
|
4
|
+
*
|
|
5
|
+
* Namespace is a shared object within some environment, service or Application.
|
|
6
|
+
* It is used to share some data, configuration, dependencies, etc. between different parts of the application.
|
|
7
|
+
*
|
|
8
|
+
* Namespace allow to :
|
|
9
|
+
* - share some data between different parts of the application,
|
|
10
|
+
* - share some configuration between different parts of the application,
|
|
11
|
+
* - share some dependencies between different parts of the application,
|
|
12
|
+
* - extend the capabilities of the application by adding new features or modifying existing ones into base classes
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
export declare class A_Namespace<_ConstructorConfigType extends A_TYPES__NamespaceConstructor = any> implements A_TYPES__INamespace {
|
|
16
|
+
protected config?: _ConstructorConfigType | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Namespace namespace
|
|
19
|
+
*/
|
|
20
|
+
name: string;
|
|
21
|
+
/**
|
|
22
|
+
* Ready Promise to ensure the SDK is ready to use
|
|
23
|
+
*/
|
|
24
|
+
ready: Promise<void>;
|
|
25
|
+
constructor(config?: _ConstructorConfigType | undefined);
|
|
26
|
+
private hasInherited;
|
|
27
|
+
/**
|
|
28
|
+
* Initializes the Namespace or can be used to reinitialize the Namespace
|
|
29
|
+
*/
|
|
30
|
+
protected init(): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Before init hook to be used in inherited classes
|
|
33
|
+
*
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
protected onBeforeInit(): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Main initialization method for the SDK
|
|
39
|
+
*/
|
|
40
|
+
protected onInit(): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* After init hook to be used in inherited classes
|
|
43
|
+
*
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
protected onAfterInit(): Promise<void>;
|
|
47
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.A_Namespace = void 0;
|
|
13
|
+
const A_Context_class_1 = require("../A-Context/A-Context.class");
|
|
14
|
+
/**
|
|
15
|
+
* A_Namespace is a base class for all Namespaces in the A
|
|
16
|
+
*
|
|
17
|
+
* Namespace is a shared object within some environment, service or Application.
|
|
18
|
+
* It is used to share some data, configuration, dependencies, etc. between different parts of the application.
|
|
19
|
+
*
|
|
20
|
+
* Namespace allow to :
|
|
21
|
+
* - share some data between different parts of the application,
|
|
22
|
+
* - share some configuration between different parts of the application,
|
|
23
|
+
* - share some dependencies between different parts of the application,
|
|
24
|
+
* - extend the capabilities of the application by adding new features or modifying existing ones into base classes
|
|
25
|
+
*
|
|
26
|
+
*/
|
|
27
|
+
class A_Namespace {
|
|
28
|
+
constructor(config) {
|
|
29
|
+
this.config = config;
|
|
30
|
+
/**
|
|
31
|
+
* Register the Namespace in the global Namespace provider
|
|
32
|
+
*/
|
|
33
|
+
this.name = A_Context_class_1.A_Context
|
|
34
|
+
.register(this, config === null || config === void 0 ? void 0 : config.name);
|
|
35
|
+
/**
|
|
36
|
+
* Run Async Initialization
|
|
37
|
+
*/
|
|
38
|
+
this.init();
|
|
39
|
+
}
|
|
40
|
+
hasInherited(cl) {
|
|
41
|
+
return this.constructor === cl
|
|
42
|
+
? false
|
|
43
|
+
: true;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Initializes the Namespace or can be used to reinitialize the Namespace
|
|
47
|
+
*/
|
|
48
|
+
init() {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
if (!this.ready)
|
|
51
|
+
this.ready = new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
try {
|
|
53
|
+
yield this.onBeforeInit();
|
|
54
|
+
yield this.onInit();
|
|
55
|
+
yield this.onAfterInit();
|
|
56
|
+
return resolve();
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
return reject(error);
|
|
60
|
+
}
|
|
61
|
+
}));
|
|
62
|
+
else
|
|
63
|
+
yield this.ready;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
// ==============================================================
|
|
67
|
+
// ======================= HOOKS ================================
|
|
68
|
+
// ==============================================================
|
|
69
|
+
/**
|
|
70
|
+
* Before init hook to be used in inherited classes
|
|
71
|
+
*
|
|
72
|
+
* @returns
|
|
73
|
+
*/
|
|
74
|
+
onBeforeInit() {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
return;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Main initialization method for the SDK
|
|
81
|
+
*/
|
|
82
|
+
onInit() {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
// global logger configuration
|
|
85
|
+
if (A_Context_class_1.A_Context.environment === 'server' && !this.hasInherited(A_Namespace)) {
|
|
86
|
+
// eslint-disable-next-line no-use-before-define
|
|
87
|
+
// process.on('uncaughtException', (error) => {
|
|
88
|
+
// // log only in case of A_AUTH_Error
|
|
89
|
+
// if (error instanceof A_Error)
|
|
90
|
+
// this.Logger.error(error);
|
|
91
|
+
// });
|
|
92
|
+
// // eslint-disable-next-line no-use-before-define
|
|
93
|
+
// process.on('unhandledRejection', (error) => {
|
|
94
|
+
// if (error instanceof A_Error)
|
|
95
|
+
// this.Logger.error(error);
|
|
96
|
+
// });
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* After init hook to be used in inherited classes
|
|
102
|
+
*
|
|
103
|
+
* @returns
|
|
104
|
+
*/
|
|
105
|
+
onAfterInit() {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
return;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.A_Namespace = A_Namespace;
|
|
112
|
+
//# sourceMappingURL=A_Namespace.class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"A_Namespace.class.js","sourceRoot":"","sources":["../../../../src/global/A-Namespace/A_Namespace.class.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA,kEAAyD;AAGzD;;;;;;;;;;;;GAYG;AACH,MAAa,WAAW;IAcpB,YACc,MAA+B;QAA/B,WAAM,GAAN,MAAM,CAAyB;QAEzC;;WAEG;QACH,IAAI,CAAC,IAAI,GAAG,2BAAS;aAChB,QAAQ,CACL,IAAI,EACJ,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,CACf,CAAC;QAEN;;WAEG;QACH,IAAI,CAAC,IAAI,EAAE,CAAC;IAChB,CAAC;IAIO,YAAY,CAAC,EAA2B;QAC5C,OAAO,IAAI,CAAC,WAAW,KAAK,EAAE;YAC1B,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,IAAI,CAA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* Namespace Interface
|
|
9
|
+
*/
|
|
10
|
+
export interface A_TYPES__INamespace {
|
|
11
|
+
name: string;
|
|
12
|
+
ready: Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Global Namespace Interface uses for extending the Namespace from other modules or SDKs
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
export interface A_TYPES__IGlobalNamespace extends A_TYPES__INamespace {
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"A_Namespace.types.js","sourceRoot":"","sources":["../../../../src/global/A-Namespace/A_Namespace.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { A_TYPES__A_DependencyDecoratorConfig } from "../decorators/A-Dependency/A-Dependency.decorator.types";
|
|
2
|
+
import { A_Concept } from "../global/A-Concept/A_Concept.class";
|
|
3
|
+
import { A_Context } from "../global/A-Namespace/A_Namespace.class";
|
|
4
|
+
import { A_TYPES__IContext } from "../global/A-Namespace/A_Namespace.types";
|
|
5
|
+
import { A_Module } from "../global/A_Module.class";
|
|
6
|
+
export declare class A_DependencyManager {
|
|
7
|
+
private dependencies;
|
|
8
|
+
protected Concept: A_Concept;
|
|
9
|
+
ready: Promise<void>;
|
|
10
|
+
constructor(concept: A_Concept, dependencies: Array<A_TYPES__A_DependencyDecoratorConfig>);
|
|
11
|
+
add(dependency: A_TYPES__A_DependencyDecoratorConfig): void;
|
|
12
|
+
resolve<T extends Array<typeof A_Module<any> | typeof A_Context>>(dependencies: [...T]): Promise<{
|
|
13
|
+
[K in keyof T]: InstanceType<T[K]>;
|
|
14
|
+
}>;
|
|
15
|
+
resolve<T extends (A_Module<any> | A_TYPES__IContext)>(dependency: {
|
|
16
|
+
new (...args: any[]): T;
|
|
17
|
+
}): Promise<T>;
|
|
18
|
+
private resolveModule;
|
|
19
|
+
private resolveContext;
|
|
20
|
+
hasModule(moduleConstructor: typeof A_SDK_Module.constructor): boolean;
|
|
21
|
+
useModule(module: A_SDK_Module): void;
|
|
22
|
+
init(): Promise<any>;
|
|
23
|
+
private activateModuleWithDependencies;
|
|
24
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.A_DependencyManager = void 0;
|
|
13
|
+
const A_Namespace_class_1 = require("../global/A-Namespace/A_Namespace.class");
|
|
14
|
+
const A_Module_class_1 = require("../global/A_Module.class");
|
|
15
|
+
class A_DependencyManager {
|
|
16
|
+
constructor(concept, dependencies) {
|
|
17
|
+
this.dependencies = [];
|
|
18
|
+
this.Concept = concept;
|
|
19
|
+
this.dependencies = dependencies;
|
|
20
|
+
}
|
|
21
|
+
add(dependency) {
|
|
22
|
+
this.dependencies.push(dependency);
|
|
23
|
+
}
|
|
24
|
+
resolve(param1) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
let dependencies = [
|
|
27
|
+
...(Array.isArray(param1) ? param1 : [param1])
|
|
28
|
+
];
|
|
29
|
+
const resolvedDependencies = [];
|
|
30
|
+
for (const dependency of dependencies) {
|
|
31
|
+
switch (true) {
|
|
32
|
+
case dependency instanceof A_Module_class_1.A_Module:
|
|
33
|
+
resolvedDependencies.push(yield this.resolveModule(dependency));
|
|
34
|
+
break;
|
|
35
|
+
case dependency instanceof A_Namespace_class_1.A_Context:
|
|
36
|
+
resolvedDependencies.push(yield this.resolveContext(dependency));
|
|
37
|
+
break;
|
|
38
|
+
default:
|
|
39
|
+
throw new Error(`[!] A-Concept Dependency Manager: Unknown dependency type.`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return Array.isArray(param1) ? resolvedDependencies : resolvedDependencies[0];
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
resolveModule(module) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
const resolvedDependencies = yield this.resolveDependencies(module.dependencies);
|
|
48
|
+
return yield module.init(resolvedDependencies);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
resolveContext(context) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const resolvedDependencies = yield this.resolveDependencies(context.dependencies);
|
|
54
|
+
return yield context.init(resolvedDependencies);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
hasModule(moduleConstructor) {
|
|
58
|
+
const targetModule = this.modules.get(moduleConstructor);
|
|
59
|
+
return !!targetModule;
|
|
60
|
+
}
|
|
61
|
+
useModule(module) {
|
|
62
|
+
const existedModule = this.modules.get(A_SDK_Module.constructor);
|
|
63
|
+
if (!existedModule) {
|
|
64
|
+
module.useContext(this.context);
|
|
65
|
+
this.modules.set(A_SDK_Module.constructor, module);
|
|
66
|
+
}
|
|
67
|
+
this.context.Logger.warning(`[!] A-Express Module of type ${module.constructor} already included.`);
|
|
68
|
+
}
|
|
69
|
+
init() {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
if (!this.ready) {
|
|
72
|
+
this.ready = new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
try {
|
|
74
|
+
for (const dependency of this.dependencies) {
|
|
75
|
+
// await this.activateModuleWithDependencies(instance);
|
|
76
|
+
const { source } = dependency;
|
|
77
|
+
const targetInstance = new source();
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Then we have to ensure that all modules are loaded even if some has async behavior
|
|
81
|
+
* To do this we have to wait for all modules to be ready before resolving the promise
|
|
82
|
+
*
|
|
83
|
+
* TODO: maybe it's not a case
|
|
84
|
+
*/
|
|
85
|
+
// this.readyStateInterval = setInterval(() => {
|
|
86
|
+
// if (!this.checkingReadyState()) {
|
|
87
|
+
// clearInterval(this.readyStateInterval);
|
|
88
|
+
// resolve();
|
|
89
|
+
// }
|
|
90
|
+
// }, 1000);
|
|
91
|
+
return resolve();
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
this.context.Logger.error(`[!] A-SDK Dependency Manager activation failed with Error: `, error);
|
|
95
|
+
reject(error);
|
|
96
|
+
}
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
return this.activationPromise;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
// Recursively activate a module and its dependencies
|
|
103
|
+
activateModuleWithDependencies(module_1) {
|
|
104
|
+
return __awaiter(this, arguments, void 0, function* (module, path = []) {
|
|
105
|
+
if (this.activatedModules.has(module.constructor)) {
|
|
106
|
+
// Module is already activated
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (path.includes(module.constructor)) {
|
|
110
|
+
throw new Error(`Circular dependency detected: ${[...path, module.constructor].join(' -> ')}`);
|
|
111
|
+
}
|
|
112
|
+
// Recursively activate dependencies first
|
|
113
|
+
for (const dependency of module.dependencies) {
|
|
114
|
+
const dependencyModule = this.modules.get(dependency);
|
|
115
|
+
if (!dependencyModule) {
|
|
116
|
+
this.context.Logger.warning(`[!] Missing dependency: ${dependency.constructor} for module ${module.constructor}`, ` Module ${dependency.constructor} initialization will be skipped...`);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
yield this.activateModuleWithDependencies(dependencyModule, [...path, module.constructor]);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// Activate the module itself
|
|
123
|
+
yield module.load();
|
|
124
|
+
this.activatedModules.add(module.constructor);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
exports.A_DependencyManager = A_DependencyManager;
|
|
129
|
+
//# sourceMappingURL=A_DependencyManager.class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"A_DependencyManager.class.js","sourceRoot":"","sources":["../../../src/managers/A_DependencyManager.class.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,+EAAoE;AAEpE,6DAAoD;AAGpD,MAAa,mBAAmB;IAQ5B,YACI,OAAkB,EAClB,YAAyD;QARrD,iBAAY,GAAgD,EAAE,CAAC;QAUnE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;IAGD,GAAG,CACC,UAAgD;QAEhD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC;IAWK,OAAO,CACT,MAAsE;;YAEtE,IAAI,YAAY,GAAsC;gBAClD,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;aACjD,CAAC;YAEF,MAAM,oBAAoB,GAAa,EAAE,CAAA;YAEzC,KAAK,MAAM,UAAU,IAAI,YAAY,EAAE,CAAC;gBACpC,QAAQ,IAAI,EAAE,CAAC;oBACX,KAAK,UAAU,YAAY,yBAAQ;wBAC/B,oBAAoB,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC;wBAChE,MAAM;oBACV,KAAK,UAAU,YAAY,6BAAS;wBAChC,oBAAoB,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;wBACjE,MAAM;oBACV;wBACI,MAAM,IAAI,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