@adaas/a-concept 0.0.5 → 0.0.7
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/dist/examples/simple/components/A.component.d.ts +4 -2
- package/dist/examples/simple/components/A.component.js +7 -4
- package/dist/examples/simple/components/A.component.js.map +1 -1
- package/dist/examples/simple/components/B.component.d.ts +6 -2
- package/dist/examples/simple/components/B.component.js +18 -7
- package/dist/examples/simple/components/B.component.js.map +1 -1
- package/dist/examples/simple/concept.js +59 -32
- package/dist/examples/simple/concept.js.map +1 -1
- package/dist/examples/simple/containers/Main.container.d.ts +1 -2
- package/dist/examples/simple/containers/Main.container.js +18 -5
- package/dist/examples/simple/containers/Main.container.js.map +1 -1
- package/dist/examples/simple-http-server/components/http-error-handler.component.d.ts +2 -1
- package/dist/examples/simple-http-server/components/http-error-handler.component.js +3 -1
- package/dist/examples/simple-http-server/components/http-error-handler.component.js.map +1 -1
- package/dist/examples/simple-http-server/components/http-request-handler.component.d.ts +2 -1
- package/dist/examples/simple-http-server/components/http-request-handler.component.js +2 -1
- package/dist/examples/simple-http-server/components/http-request-handler.component.js.map +1 -1
- package/dist/examples/simple-http-server/containers/http-server.container.d.ts +1 -2
- package/dist/index.d.ts +5 -1
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/src/base/A-Config/A-Config.container.d.ts +1 -3
- package/dist/src/base/A-Config/A-Config.container.js +6 -22
- package/dist/src/base/A-Config/A-Config.container.js.map +1 -1
- package/dist/src/base/A-Config/A-Config.context.d.ts +1 -0
- package/dist/src/base/A-Config/A-Config.context.js +20 -2
- package/dist/src/base/A-Config/A-Config.context.js.map +1 -1
- package/dist/src/base/A-Config/A-Config.types.d.ts +2 -2
- package/dist/src/base/A-Config/components/ConfigReader.component.d.ts +2 -1
- package/dist/src/base/A-Config/components/ConfigReader.component.js +3 -1
- package/dist/src/base/A-Config/components/ConfigReader.component.js.map +1 -1
- package/dist/src/base/A-Errors/A-Errors.component.d.ts +2 -1
- package/dist/src/base/A-Errors/A-Errors.component.js +3 -1
- package/dist/src/base/A-Errors/A-Errors.component.js.map +1 -1
- package/dist/src/base/A-Logger/A-Logger.component.d.ts +4 -2
- package/dist/src/base/A-Logger/A-Logger.component.js +11 -3
- package/dist/src/base/A-Logger/A-Logger.component.js.map +1 -1
- package/dist/src/decorators/A-Feature/A-Feature-Define.decorator.js.map +1 -1
- package/dist/src/decorators/A-Feature/A-Feature-Extend.decorator.js +9 -9
- package/dist/src/decorators/A-Feature/A-Feature-Extend.decorator.js.map +1 -1
- package/dist/src/decorators/A-Inject/A-Inject.decorator.d.ts +0 -2
- package/dist/src/decorators/A-Inject/A-Inject.decorator.js +4 -2
- package/dist/src/decorators/A-Inject/A-Inject.decorator.js.map +1 -1
- package/dist/src/global/A-Component/A-Component.class.d.ts +28 -1
- package/dist/src/global/A-Component/A-Component.class.js +22 -0
- package/dist/src/global/A-Component/A-Component.class.js.map +1 -1
- package/dist/src/global/A-Component/A-Component.meta.d.ts +8 -1
- package/dist/src/global/A-Component/A-Component.meta.js +26 -0
- package/dist/src/global/A-Component/A-Component.meta.js.map +1 -1
- package/dist/src/global/A-Component/A-Component.types.d.ts +43 -6
- package/dist/src/global/A-Component/A-Component.types.js +5 -0
- package/dist/src/global/A-Component/A-Component.types.js.map +1 -1
- package/dist/src/global/A-Concept/A_Concept.class.d.ts +7 -7
- package/dist/src/global/A-Concept/A_Concept.class.js +1 -2
- package/dist/src/global/A-Concept/A_Concept.class.js.map +1 -1
- package/dist/src/global/A-Container/A-Container.class.d.ts +5 -4
- package/dist/src/global/A-Container/A-Container.class.js +13 -24
- package/dist/src/global/A-Container/A-Container.class.js.map +1 -1
- package/dist/src/global/A-Container/A-Container.meta.d.ts +0 -3
- package/dist/src/global/A-Container/A-Container.meta.js +0 -46
- package/dist/src/global/A-Container/A-Container.meta.js.map +1 -1
- package/dist/src/global/A-Context/A-Context.class.d.ts +35 -5
- package/dist/src/global/A-Context/A-Context.class.js +135 -53
- package/dist/src/global/A-Context/A-Context.class.js.map +1 -1
- package/dist/src/global/A-Context/A-Context.types.d.ts +0 -12
- package/dist/src/global/A-Context/A-Context.types.js +0 -1
- package/dist/src/global/A-Entity/A-Entity.class.d.ts +28 -4
- package/dist/src/global/A-Entity/A-Entity.class.js +23 -3
- package/dist/src/global/A-Entity/A-Entity.class.js.map +1 -1
- package/dist/src/global/A-Entity/A-Entity.meta.d.ts +4 -0
- package/dist/src/global/A-Entity/A-Entity.meta.js +8 -0
- package/dist/src/global/A-Entity/A-Entity.meta.js.map +1 -0
- package/dist/src/global/A-Entity/A-Entity.types.d.ts +43 -0
- package/dist/src/global/A-Entity/A-Entity.types.js +13 -0
- package/dist/src/global/A-Entity/A-Entity.types.js.map +1 -1
- package/dist/src/global/A-Feature/A-Feature.class.d.ts +11 -1
- package/dist/src/global/A-Feature/A-Feature.class.js +48 -12
- package/dist/src/global/A-Feature/A-Feature.class.js.map +1 -1
- package/dist/src/global/A-Feature/A-Feature.types.d.ts +5 -4
- package/dist/src/global/A-Feature/A-Feature.types.js.map +1 -1
- package/dist/src/global/A-Fragment/A-Fragment.class.js +1 -2
- package/dist/src/global/A-Fragment/A-Fragment.class.js.map +1 -1
- package/dist/src/global/A-Meta/A-Meta.class.d.ts +75 -1
- package/dist/src/global/A-Meta/A-Meta.class.js +100 -10
- package/dist/src/global/A-Meta/A-Meta.class.js.map +1 -1
- package/dist/src/global/A-Scope/A-Scope.class.d.ts +15 -6
- package/dist/src/global/A-Scope/A-Scope.class.js +53 -17
- package/dist/src/global/A-Scope/A-Scope.class.js.map +1 -1
- package/examples/simple/components/A.component.ts +6 -3
- package/examples/simple/components/B.component.ts +19 -6
- package/examples/simple/concept.ts +65 -33
- package/examples/simple/containers/Main.container.ts +28 -7
- package/examples/simple-http-server/components/http-error-handler.component.ts +5 -2
- package/examples/simple-http-server/components/http-request-handler.component.ts +3 -1
- package/index.ts +6 -1
- package/package.json +1 -1
- package/src/base/A-Config/A-Config.container.ts +5 -8
- package/src/base/A-Config/A-Config.context.ts +10 -2
- package/src/base/A-Config/A-Config.types.ts +2 -2
- package/src/base/A-Config/components/ConfigReader.component.ts +5 -2
- package/src/base/A-Errors/A-Errors.component.ts +3 -2
- package/src/base/A-Logger/A-Logger.component.ts +21 -3
- package/src/decorators/A-Feature/A-Feature-Define.decorator.ts +0 -1
- package/src/decorators/A-Feature/A-Feature-Extend.decorator.ts +15 -10
- package/src/decorators/A-Inject/A-Inject.decorator.ts +13 -11
- package/src/global/A-Component/A-Component.class.ts +56 -1
- package/src/global/A-Component/A-Component.meta.ts +40 -1
- package/src/global/A-Component/A-Component.types.ts +51 -19
- package/src/global/A-Concept/A_Concept.class.ts +2 -2
- package/src/global/A-Container/A-Container.class.ts +22 -34
- package/src/global/A-Container/A-Container.meta.ts +0 -64
- package/src/global/A-Context/A-Context.class.ts +240 -79
- package/src/global/A-Context/A-Context.types.ts +0 -15
- package/src/global/A-Entity/A-Entity.class.ts +65 -8
- package/src/global/A-Entity/A-Entity.meta.ts +9 -0
- package/src/global/A-Entity/A-Entity.types.ts +58 -0
- package/src/global/A-Feature/A-Feature.class.ts +62 -20
- package/src/global/A-Feature/A-Feature.types.ts +8 -2
- package/src/global/A-Fragment/A-Fragment.class.ts +1 -5
- package/src/global/A-Meta/A-Meta.class.ts +114 -22
- package/src/global/A-Scope/A-Scope.class.ts +93 -33
|
@@ -5,6 +5,9 @@ import {
|
|
|
5
5
|
} from "./A-Feature.decorator.types";
|
|
6
6
|
import { A_TYPES__ComponentMetaKey } from "@adaas/a-concept/global/A-Component/A-Component.types";
|
|
7
7
|
import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
|
|
8
|
+
import { A_Container } from "@adaas/a-concept/global/A-Container/A-Container.class";
|
|
9
|
+
import { A_Entity } from "@adaas/a-concept/global/A-Entity/A-Entity.class";
|
|
10
|
+
import { A_Meta } from "@adaas/a-concept/global/A-Meta/A-Meta.class";
|
|
8
11
|
|
|
9
12
|
|
|
10
13
|
|
|
@@ -31,27 +34,29 @@ export function A_Feature_Extend(
|
|
|
31
34
|
descriptor: A_TYPES__A_ExtendDecoratorDescriptor
|
|
32
35
|
) {
|
|
33
36
|
|
|
37
|
+
const extensionName = config.name || propertyKey
|
|
38
|
+
|
|
34
39
|
// Get the existed metadata or create a new one
|
|
35
40
|
const existedMeta = A_Context
|
|
36
41
|
.meta(target)
|
|
37
42
|
.get(A_TYPES__ComponentMetaKey.EXTENSIONS)
|
|
38
|
-
|| new
|
|
43
|
+
|| new A_Meta();
|
|
39
44
|
|
|
40
|
-
|
|
41
|
-
existedMeta.
|
|
42
|
-
|
|
45
|
+
|
|
46
|
+
const existedMetaValue = existedMeta.get(extensionName) || [];
|
|
47
|
+
|
|
48
|
+
// Add the new method to the metadata
|
|
49
|
+
existedMetaValue.push({
|
|
50
|
+
name: extensionName,
|
|
43
51
|
handler: propertyKey,
|
|
44
|
-
container: config.container
|
|
45
|
-
? typeof config.container === 'string'
|
|
46
|
-
? config.container
|
|
47
|
-
: config.container.name
|
|
48
|
-
: '*',
|
|
49
52
|
});
|
|
50
53
|
|
|
54
|
+
// Set the metadata of the method to define a custom Feature with name
|
|
55
|
+
existedMeta.set(extensionName, existedMetaValue);
|
|
56
|
+
|
|
51
57
|
// Update the metadata of the container with the new Feature definition
|
|
52
58
|
A_Context
|
|
53
59
|
.meta(target)
|
|
54
60
|
.set(A_TYPES__ComponentMetaKey.EXTENSIONS, existedMeta);
|
|
55
|
-
|
|
56
61
|
};
|
|
57
62
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class";
|
|
2
|
-
import {
|
|
3
|
-
import { A_TYPES__A_InjectDecoratorReturn, A_TYPES__A_InjectDecoratorStorageInstruction } from "./A-Inject.decorator.types";
|
|
2
|
+
import { A_TYPES__A_InjectDecoratorReturn } from "./A-Inject.decorator.types";
|
|
4
3
|
import { A_Fragment } from "@adaas/a-concept/global/A-Fragment/A-Fragment.class";
|
|
5
4
|
import { A_Scope } from "@adaas/a-concept/global/A-Scope/A-Scope.class";
|
|
6
5
|
import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
|
|
7
6
|
import { A_TYPES__ComponentMetaKey } from "@adaas/a-concept/global/A-Component/A-Component.types";
|
|
7
|
+
import { A_Meta } from "@adaas/a-concept/global/A-Meta/A-Meta.class";
|
|
8
|
+
import { A_Feature } from "@adaas/a-concept/global/A-Feature/A-Feature.class";
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
|
|
@@ -33,9 +34,9 @@ export function A_Inject(
|
|
|
33
34
|
): A_TYPES__A_InjectDecoratorReturn
|
|
34
35
|
|
|
35
36
|
// Allows to inject just one container
|
|
36
|
-
export function A_Inject(
|
|
37
|
-
|
|
38
|
-
): A_TYPES__A_InjectDecoratorReturn
|
|
37
|
+
// export function A_Inject(
|
|
38
|
+
// container: typeof A_Container
|
|
39
|
+
// ): A_TYPES__A_InjectDecoratorReturn
|
|
39
40
|
|
|
40
41
|
// Allows to inject just one Context Fragment
|
|
41
42
|
export function A_Inject(
|
|
@@ -50,10 +51,9 @@ export function A_Inject<
|
|
|
50
51
|
): A_TYPES__A_InjectDecoratorReturn
|
|
51
52
|
|
|
52
53
|
// ====================== BASE FUNCTION ======================
|
|
53
|
-
export function A_Inject
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
param1: T | typeof A_Fragment | typeof A_Component | typeof A_Container | typeof A_Fragment,
|
|
54
|
+
export function A_Inject(
|
|
55
|
+
param1: typeof A_Fragment | typeof A_Component | typeof A_Scope | typeof A_Feature,
|
|
56
|
+
|
|
57
57
|
): A_TYPES__A_InjectDecoratorReturn {
|
|
58
58
|
return function (
|
|
59
59
|
target: A_Component,
|
|
@@ -61,13 +61,15 @@ export function A_Inject<
|
|
|
61
61
|
parameterIndex: number
|
|
62
62
|
) {
|
|
63
63
|
|
|
64
|
-
const method = methodName ? methodName : 'constructor';
|
|
64
|
+
const method = methodName ? String(methodName) : 'constructor';
|
|
65
65
|
|
|
66
|
+
console.log('target: ', target);
|
|
66
67
|
|
|
67
68
|
const existedMeta = A_Context
|
|
68
69
|
.meta(target)
|
|
69
70
|
.get(A_TYPES__ComponentMetaKey.INJECTIONS)
|
|
70
|
-
|| new
|
|
71
|
+
|| new A_Meta();
|
|
72
|
+
|
|
71
73
|
|
|
72
74
|
const paramsArray = existedMeta.get(method) || [];
|
|
73
75
|
|
|
@@ -1,5 +1,60 @@
|
|
|
1
|
+
import { A_TYPES__Required } from "@adaas/a-utils";
|
|
2
|
+
import { A_Context } from "../A-Context/A-Context.class";
|
|
3
|
+
import { A_TYPES__ComponentCallParams } from "./A-Component.types";
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* This element only contains the specific code
|
|
3
7
|
*
|
|
4
8
|
*/
|
|
5
|
-
export class A_Component
|
|
9
|
+
export class A_Component<
|
|
10
|
+
_FeatureNames extends Array<string> = any,
|
|
11
|
+
> {
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Call a feature of the component
|
|
16
|
+
*
|
|
17
|
+
* @param lifecycleMethod
|
|
18
|
+
* @param args
|
|
19
|
+
*/
|
|
20
|
+
async call(
|
|
21
|
+
/**
|
|
22
|
+
* A-Feature method name to be called
|
|
23
|
+
*/
|
|
24
|
+
feature: _FeatureNames[number],
|
|
25
|
+
): Promise<any>
|
|
26
|
+
async call(
|
|
27
|
+
/**
|
|
28
|
+
* A-Feature name to be called
|
|
29
|
+
*/
|
|
30
|
+
params: A_TYPES__Required<Partial<A_TYPES__ComponentCallParams<_FeatureNames[number]>>, ['name']>,
|
|
31
|
+
): Promise<any>
|
|
32
|
+
|
|
33
|
+
async call(
|
|
34
|
+
/**
|
|
35
|
+
* A-Feature method name to be called
|
|
36
|
+
*/
|
|
37
|
+
feature: string,
|
|
38
|
+
/**
|
|
39
|
+
* Parameters to provide additional data to the feature
|
|
40
|
+
*/
|
|
41
|
+
params: Partial<A_TYPES__ComponentCallParams<_FeatureNames[number]>>,
|
|
42
|
+
): Promise<any>
|
|
43
|
+
|
|
44
|
+
async call(
|
|
45
|
+
param1: _FeatureNames[number] | A_TYPES__Required<Partial<A_TYPES__ComponentCallParams<_FeatureNames[number]>>, ['name']>,
|
|
46
|
+
param2?: Partial<A_TYPES__ComponentCallParams<_FeatureNames[number]>>
|
|
47
|
+
): Promise<any> {
|
|
48
|
+
|
|
49
|
+
const feature: string = typeof param1 === 'string'
|
|
50
|
+
? param1
|
|
51
|
+
: param1.name;
|
|
52
|
+
const params: Partial<A_TYPES__ComponentCallParams<_FeatureNames[number]>> = typeof param1 === 'string'
|
|
53
|
+
? param2 || {}
|
|
54
|
+
: param1;
|
|
55
|
+
|
|
56
|
+
const newFeature = A_Context.feature(this, feature, params);
|
|
57
|
+
|
|
58
|
+
return await newFeature.process();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -1,9 +1,48 @@
|
|
|
1
1
|
import { A_Meta } from "../A-Meta/A-Meta.class";
|
|
2
|
-
import { A_TYPES__ComponentMeta } from "./A-Component.types";
|
|
2
|
+
import { A_TYPES__ComponentMeta, A_TYPES__ComponentMetaExtension, A_TYPES__ComponentMetaKey } from "./A-Component.types";
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
export class A_ComponentMeta extends A_Meta<A_TYPES__ComponentMeta> {
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Allows to get all the extensions for a given feature
|
|
12
|
+
*
|
|
13
|
+
* @param feature
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
extensions(
|
|
17
|
+
feature: string
|
|
18
|
+
): A_TYPES__ComponentMetaExtension[] {
|
|
19
|
+
const steps: A_TYPES__ComponentMetaExtension[] = [];
|
|
20
|
+
|
|
21
|
+
const extensions = this.get(A_TYPES__ComponentMetaKey.EXTENSIONS);
|
|
22
|
+
const injections = this.get(A_TYPES__ComponentMetaKey.INJECTIONS);
|
|
23
|
+
|
|
24
|
+
// const constructor = A_Context.component(this);
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
extensions
|
|
28
|
+
// returns all extensions that match the feature
|
|
29
|
+
?.find(feature)
|
|
30
|
+
.forEach(([handler, extensions]) => {
|
|
31
|
+
extensions.forEach(extension => {
|
|
32
|
+
|
|
33
|
+
const args = injections?.get(extension.handler) || [];
|
|
34
|
+
|
|
35
|
+
steps.push({
|
|
36
|
+
// component: constructor,
|
|
37
|
+
handler: extension.handler,
|
|
38
|
+
args
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
return steps;
|
|
46
|
+
}
|
|
47
|
+
|
|
9
48
|
}
|
|
@@ -1,15 +1,42 @@
|
|
|
1
|
+
import { A_Feature } from "../A-Feature/A-Feature.class"
|
|
2
|
+
import { A_Fragment } from "../A-Fragment/A-Fragment.class"
|
|
3
|
+
import { A_Meta } from "../A-Meta/A-Meta.class"
|
|
4
|
+
import { A_Scope } from "../A-Scope/A-Scope.class"
|
|
5
|
+
import { A_Component } from "./A-Component.class"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export type A_TYPES__ComponentCallParams<T extends string> = {
|
|
9
|
+
name: T,
|
|
10
|
+
fragments: Array<A_Fragment>,
|
|
11
|
+
components: Array<{ new(...args: any[]): any }>
|
|
12
|
+
}
|
|
1
13
|
|
|
2
14
|
|
|
3
15
|
export type A_TYPES__ComponentMeta = {
|
|
4
|
-
[A_TYPES__ComponentMetaKey.EXTENSIONS]:
|
|
16
|
+
[A_TYPES__ComponentMetaKey.EXTENSIONS]: A_Meta<{
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Where Key the regexp for what to apply the extension
|
|
20
|
+
* A set of container names or a wildcard, or a regexp
|
|
21
|
+
*
|
|
22
|
+
*
|
|
23
|
+
* Where value is the extension instructions
|
|
24
|
+
*/
|
|
25
|
+
[Key: string]: A_TYPES__ComponentMeta_ExtensionItem[]
|
|
26
|
+
}>,
|
|
27
|
+
|
|
28
|
+
|
|
5
29
|
[A_TYPES__ComponentMetaKey.FEATURES]: any[],
|
|
6
|
-
[A_TYPES__ComponentMetaKey.INJECTIONS]: Map<
|
|
7
|
-
// Where key is method name
|
|
8
|
-
Symbol | string,
|
|
9
|
-
// And value is Injection instructions
|
|
10
|
-
A_TYPES__ComponentMeta_InjectionParams
|
|
11
|
-
>
|
|
12
30
|
|
|
31
|
+
|
|
32
|
+
[A_TYPES__ComponentMetaKey.INJECTIONS]: A_Meta<{
|
|
33
|
+
/**
|
|
34
|
+
* Where Key is the name of the injection
|
|
35
|
+
*
|
|
36
|
+
* Where value is the list of injections
|
|
37
|
+
*/
|
|
38
|
+
[Key: string]: Array<A_TYPES__ComponentMeta_InjectionParam>
|
|
39
|
+
}>
|
|
13
40
|
}
|
|
14
41
|
|
|
15
42
|
export enum A_TYPES__ComponentMetaKey {
|
|
@@ -18,23 +45,28 @@ export enum A_TYPES__ComponentMetaKey {
|
|
|
18
45
|
INJECTIONS = 'a-component-injections',
|
|
19
46
|
}
|
|
20
47
|
|
|
48
|
+
export type A_TYPES__ComponentMetaExtension = {
|
|
49
|
+
handler: string,
|
|
50
|
+
args: A_TYPES__ComponentMeta_InjectionParam[]
|
|
51
|
+
}
|
|
52
|
+
|
|
21
53
|
|
|
22
54
|
export type A_TYPES__ComponentMeta_ExtensionItem = {
|
|
23
55
|
name: string,
|
|
24
|
-
container: string,
|
|
25
56
|
handler: string,
|
|
26
57
|
}
|
|
27
58
|
|
|
28
59
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// |
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
60
|
+
|
|
61
|
+
export type A_TYPES__ComponentMeta_InjectionParam =
|
|
62
|
+
{ new(...args: any[]): A_Fragment }
|
|
63
|
+
| { new(...args: any[]): A_Component }
|
|
64
|
+
// | { new(...args: any[]): any }
|
|
65
|
+
| { new(...args: any[]): A_Scope }
|
|
66
|
+
| { new(...args: any[]): A_Feature };
|
|
67
|
+
// typeof A_Fragment
|
|
68
|
+
// | typeof A_Component
|
|
69
|
+
// // | { new(...args: any[]): any }
|
|
70
|
+
// | typeof A_Scope
|
|
71
|
+
// | typeof A_Feature;
|
|
40
72
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { A_TYPES__ConceptStage, A_TYPES__ConceptStageParams, A_TYPES__IConceptConstructor } from "./A_Concept.types";
|
|
2
2
|
import { A_Context } from "../A-Context/A-Context.class";
|
|
3
3
|
import { A_Container } from "../A-Container/A-Container.class";
|
|
4
|
-
import { A_Logger } from "@adaas/a-concept/base/A-Logger/A-Logger.component";
|
|
4
|
+
// import { A_Logger } from "@adaas/a-concept/base/A-Logger/A-Logger.component";
|
|
5
5
|
import { A_Fragment } from "../A-Fragment/A-Fragment.class";
|
|
6
6
|
import { A_TYPES__ContainerMetaKey } from "../A-Container/A-Container.types";
|
|
7
7
|
import { A_Stage } from "@adaas/a-concept/decorators/A-Stage/A-Stage.decorator";
|
|
@@ -102,7 +102,7 @@ export class A_Concept<
|
|
|
102
102
|
fragments: props.fragments || [],
|
|
103
103
|
// containers: props.containers
|
|
104
104
|
components: [
|
|
105
|
-
A_Logger,
|
|
105
|
+
// A_Logger,
|
|
106
106
|
]
|
|
107
107
|
});
|
|
108
108
|
|
|
@@ -2,6 +2,7 @@ import { A_TYPES__ContainerCallParams, A_TYPES__ContainerConstructor } from "./A
|
|
|
2
2
|
import { A_TYPES__Required } from "@adaas/a-utils";
|
|
3
3
|
import { A_Feature } from "../A-Feature/A-Feature.class";
|
|
4
4
|
import { A_Context } from "../A-Context/A-Context.class";
|
|
5
|
+
import { A_Scope } from "../A-Scope/A-Scope.class";
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
|
|
@@ -36,6 +37,10 @@ export class A_Container<
|
|
|
36
37
|
return this.config.name || this.constructor.name;
|
|
37
38
|
}
|
|
38
39
|
|
|
40
|
+
get Scope(): A_Scope {
|
|
41
|
+
return A_Context.scope(this);
|
|
42
|
+
}
|
|
43
|
+
|
|
39
44
|
|
|
40
45
|
constructor(
|
|
41
46
|
/**
|
|
@@ -48,10 +53,7 @@ export class A_Container<
|
|
|
48
53
|
const components = config.components || [];
|
|
49
54
|
const fragments = config.fragments || [];
|
|
50
55
|
|
|
51
|
-
A_Context.allocate(this,
|
|
52
|
-
components,
|
|
53
|
-
fragments
|
|
54
|
-
});
|
|
56
|
+
A_Context.allocate(this, config);
|
|
55
57
|
|
|
56
58
|
/**
|
|
57
59
|
* Run Async Initialization
|
|
@@ -100,20 +102,20 @@ export class A_Container<
|
|
|
100
102
|
* @param lifecycleMethod
|
|
101
103
|
* @param args
|
|
102
104
|
*/
|
|
103
|
-
call(
|
|
105
|
+
async call(
|
|
104
106
|
/**
|
|
105
107
|
* A-Feature method name to be called
|
|
106
108
|
*/
|
|
107
109
|
feature: _FeatureNames[number],
|
|
108
|
-
):
|
|
109
|
-
call(
|
|
110
|
+
): Promise<any>
|
|
111
|
+
async call(
|
|
110
112
|
/**
|
|
111
113
|
* A-Feature name to be called
|
|
112
114
|
*/
|
|
113
115
|
params: A_TYPES__Required<Partial<A_TYPES__ContainerCallParams<_FeatureNames[number]>>, ['name']>,
|
|
114
|
-
):
|
|
116
|
+
): Promise<any>
|
|
115
117
|
|
|
116
|
-
call(
|
|
118
|
+
async call(
|
|
117
119
|
/**
|
|
118
120
|
* A-Feature method name to be called
|
|
119
121
|
*/
|
|
@@ -122,37 +124,23 @@ export class A_Container<
|
|
|
122
124
|
* Parameters to provide additional data to the feature
|
|
123
125
|
*/
|
|
124
126
|
params: Partial<A_TYPES__ContainerCallParams<_FeatureNames[number]>>,
|
|
125
|
-
):
|
|
127
|
+
): Promise<any>
|
|
126
128
|
|
|
127
|
-
call(
|
|
129
|
+
async call(
|
|
128
130
|
param1: _FeatureNames[number] | A_TYPES__Required<Partial<A_TYPES__ContainerCallParams<_FeatureNames[number]>>, ['name']>,
|
|
129
131
|
param2?: Partial<A_TYPES__ContainerCallParams<_FeatureNames[number]>>
|
|
130
|
-
):
|
|
131
|
-
|
|
132
|
-
let feature: string;
|
|
133
|
-
let params: Partial<A_TYPES__ContainerCallParams<_FeatureNames[number]>>;
|
|
134
|
-
|
|
135
|
-
if (typeof param1 === 'string') {
|
|
136
|
-
feature = param1;
|
|
137
|
-
params = param2 || {};
|
|
138
|
-
} else {
|
|
139
|
-
feature = param1.name;
|
|
140
|
-
params = param1;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const meta = A_Context.meta(this);
|
|
132
|
+
): Promise<any> {
|
|
144
133
|
|
|
145
|
-
const
|
|
134
|
+
const feature: string = typeof param1 === 'string'
|
|
135
|
+
? param1
|
|
136
|
+
: param1.name;
|
|
137
|
+
const params: Partial<A_TYPES__ContainerCallParams<_FeatureNames[number]>> = typeof param1 === 'string'
|
|
138
|
+
? param2 || {}
|
|
139
|
+
: param1;
|
|
146
140
|
|
|
147
|
-
const newFeature =
|
|
148
|
-
name: `${this.constructor.name}.${feature}`,
|
|
149
|
-
fragments: param2?.fragments || [],
|
|
150
|
-
components: param2?.components || [],
|
|
151
|
-
steps,
|
|
152
|
-
parent: A_Context.scope(this)
|
|
153
|
-
});
|
|
141
|
+
const newFeature = A_Context.feature(this, feature, params);
|
|
154
142
|
|
|
155
|
-
return newFeature;
|
|
143
|
+
return await newFeature.process();
|
|
156
144
|
}
|
|
157
145
|
|
|
158
146
|
|
|
@@ -13,68 +13,4 @@ import {
|
|
|
13
13
|
export class A_ContainerMeta extends A_Meta<A_TYPES__ContainerMeta> {
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
feature<T extends string>(
|
|
17
|
-
container: A_Container<any>,
|
|
18
|
-
name: T,
|
|
19
|
-
// params:
|
|
20
|
-
) {
|
|
21
|
-
const scope = A_Context.scope(container);
|
|
22
|
-
|
|
23
|
-
// First lets validate that there'are registered method with the same name
|
|
24
|
-
const featureMeta = this.get(A_TYPES__ContainerMetaKey.FEATURES);
|
|
25
|
-
|
|
26
|
-
if (!featureMeta) {
|
|
27
|
-
throw new Error(`Container ${container.constructor.name} has no metadata defined`);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const instruction = featureMeta.get(name);
|
|
31
|
-
|
|
32
|
-
if (!instruction)
|
|
33
|
-
throw new Error(`Method ${name} is not defined in ${this.constructor.name}`);
|
|
34
|
-
|
|
35
|
-
// const scope = new A_Scope({
|
|
36
|
-
// name: `${this.constructor.name}.${feature}`,
|
|
37
|
-
// fragments: param2?.fragments || [],
|
|
38
|
-
// components: param2?.components || []
|
|
39
|
-
// }, {
|
|
40
|
-
// parent: this.scope
|
|
41
|
-
// });
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// Now we need to resolve the method from all registered components
|
|
45
|
-
return scope
|
|
46
|
-
.components
|
|
47
|
-
.reduce((
|
|
48
|
-
acc, component
|
|
49
|
-
) => {
|
|
50
|
-
const componentMeta = A_Context.meta(component);
|
|
51
|
-
|
|
52
|
-
const extensions = componentMeta.get(A_TYPES__ComponentMetaKey.EXTENSIONS) || [];
|
|
53
|
-
const injections = componentMeta.get(A_TYPES__ComponentMetaKey.INJECTIONS);
|
|
54
|
-
|
|
55
|
-
const out: A_TYPES__FeatureStep[] = [];
|
|
56
|
-
|
|
57
|
-
extensions.forEach((extension, handler) => {
|
|
58
|
-
if (
|
|
59
|
-
extension.name === name
|
|
60
|
-
&&
|
|
61
|
-
(extension.container === container.constructor.name || extension.container === '*')
|
|
62
|
-
) {
|
|
63
|
-
const args = injections?.get(handler) || [];
|
|
64
|
-
|
|
65
|
-
out.push({
|
|
66
|
-
component,
|
|
67
|
-
handler,
|
|
68
|
-
args
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
return [
|
|
74
|
-
...acc,
|
|
75
|
-
...out
|
|
76
|
-
];
|
|
77
|
-
|
|
78
|
-
}, [] as A_TYPES__FeatureStep[])
|
|
79
|
-
}
|
|
80
16
|
}
|