@adaas/a-concept 0.0.29 → 0.0.31
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/fe-be/channels/Test.channel.d.ts +6 -0
- package/dist/examples/fe-be/channels/Test.channel.js +14 -0
- package/dist/examples/fe-be/channels/Test.channel.js.map +1 -0
- package/dist/examples/fe-be/components/BE-Controller.component.d.ts +4 -0
- package/dist/examples/fe-be/components/BE-Controller.component.js +24 -0
- package/dist/examples/fe-be/components/BE-Controller.component.js.map +1 -0
- package/dist/examples/fe-be/components/FE.component.d.ts +4 -0
- package/dist/examples/fe-be/components/FE.component.js +31 -0
- package/dist/examples/fe-be/components/FE.component.js.map +1 -0
- package/dist/examples/fe-be/components/UserActions.component.d.ts +5 -0
- package/dist/examples/fe-be/components/UserActions.component.js +25 -0
- package/dist/examples/fe-be/components/UserActions.component.js.map +1 -0
- package/dist/examples/fe-be/concept.d.ts +0 -0
- package/dist/examples/fe-be/concept.js +2 -0
- package/dist/examples/fe-be/concept.js.map +1 -0
- package/dist/examples/fe-be/containers/ServerApp.container.d.ts +3 -0
- package/dist/examples/fe-be/containers/ServerApp.container.js +8 -0
- package/dist/examples/fe-be/containers/ServerApp.container.js.map +1 -0
- package/dist/examples/fe-be/containers/WebApp.container.d.ts +3 -0
- package/dist/examples/fe-be/containers/WebApp.container.js +8 -0
- package/dist/examples/fe-be/containers/WebApp.container.js.map +1 -0
- package/dist/examples/multi-container/channels/Direct.channel.d.ts +9 -0
- package/dist/examples/multi-container/channels/Direct.channel.js +32 -0
- package/dist/examples/multi-container/channels/Direct.channel.js.map +1 -0
- package/dist/examples/multi-container/concept.d.ts +0 -0
- package/dist/examples/multi-container/concept.js +2 -0
- package/dist/examples/multi-container/concept.js.map +1 -0
- package/dist/examples/multi-container/containers/Command.container.d.ts +11 -0
- package/dist/examples/multi-container/containers/Command.container.js +51 -0
- package/dist/examples/multi-container/containers/Command.container.js.map +1 -0
- package/dist/examples/multi-container/containers/Schedule.container.d.ts +15 -0
- package/dist/examples/multi-container/containers/Schedule.container.js +67 -0
- package/dist/examples/multi-container/containers/Schedule.container.js.map +1 -0
- package/dist/examples/simple/components/A.component.js.map +1 -1
- package/dist/examples/simple/containers/Main.container.js +7 -3
- package/dist/examples/simple/containers/Main.container.js.map +1 -1
- package/dist/examples/simple/entities/EntityA.entity.d.ts +8 -0
- package/dist/examples/simple/entities/EntityA.entity.js +22 -0
- package/dist/examples/simple/entities/EntityA.entity.js.map +1 -0
- package/dist/examples/simple-http-server/contexts/http-request.context.d.ts +0 -1
- package/dist/examples/simple-http-server/contexts/http-request.context.js +6 -8
- package/dist/examples/simple-http-server/contexts/http-request.context.js.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.js +16 -7
- package/dist/index.js.map +1 -1
- package/dist/src/base/A-Errors/A-Error.entity.d.ts +3 -0
- package/dist/src/base/A-Errors/A-Error.entity.js +8 -0
- package/dist/src/base/A-Errors/A-Error.entity.js.map +1 -0
- package/dist/src/base/A-Errors/A-Errors.context.js +1 -1
- package/dist/src/base/A-Errors/A-Errors.context.js.map +1 -1
- package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.d.ts +14 -0
- package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.js +53 -0
- package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.js.map +1 -0
- package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.types.d.ts +2 -0
- package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.types.js +3 -0
- package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.types.js.map +1 -0
- package/dist/src/decorators/A-Connect/A-Connect.decorator.d.ts +19 -0
- package/dist/src/decorators/A-Connect/A-Connect.decorator.js +31 -0
- package/dist/src/decorators/A-Connect/A-Connect.decorator.js.map +1 -0
- package/dist/src/decorators/A-Connect/A-Connect.decorator.types.d.ts +1 -0
- package/dist/src/decorators/A-Connect/A-Connect.decorator.types.js +3 -0
- package/dist/src/decorators/A-Connect/A-Connect.decorator.types.js.map +1 -0
- package/dist/src/decorators/A-Entity/A-Entity-List.decorator.d.ts +1 -0
- package/dist/src/decorators/A-Entity/A-Entity-List.decorator.js +8 -0
- package/dist/src/decorators/A-Entity/A-Entity-List.decorator.js.map +1 -0
- package/dist/src/decorators/A-Entity/A-Entity.decorator.types.d.ts +14 -0
- package/dist/src/decorators/A-Entity/A-Entity.decorator.types.js +3 -0
- package/dist/src/decorators/A-Entity/A-Entity.decorator.types.js.map +1 -0
- package/dist/src/decorators/A-Feature/A-Feature-Define.decorator.js +7 -5
- 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 -0
- package/dist/src/decorators/A-Feature/A-Feature-Extend.decorator.js.map +1 -1
- package/dist/src/decorators/A-Feature/A-Feature.decorator.types.d.ts +36 -0
- package/dist/src/decorators/A-Inject/A-Inject.decorator.d.ts +2 -3
- package/dist/src/decorators/A-Inject/A-Inject.decorator.js.map +1 -1
- package/dist/src/decorators/A-Inject/A-Inject.decorator.types.d.ts +44 -0
- package/dist/src/global/A-Channel/A-Channel.class.d.ts +8 -10
- package/dist/src/global/A-Channel/A-Channel.class.js +12 -26
- package/dist/src/global/A-Channel/A-Channel.class.js.map +1 -1
- package/dist/src/global/A-Channel/A-Channel.types.d.ts +32 -0
- package/dist/src/global/A-Component/A-Component.class.d.ts +2 -1
- package/dist/src/global/A-Component/A-Component.class.js +1 -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 +16 -0
- package/dist/src/global/A-Component/A-Component.meta.js +37 -3
- package/dist/src/global/A-Component/A-Component.meta.js.map +1 -1
- package/dist/src/global/A-Component/A-Component.types.d.ts +26 -38
- package/dist/src/global/A-Component/A-Component.types.js +1 -7
- 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 +30 -30
- package/dist/src/global/A-Concept/A_Concept.class.js.map +1 -1
- package/dist/src/global/A-Concept/A_Concept.types.d.ts +42 -2
- package/dist/src/global/A-Concept/A_Concept.types.js.map +1 -1
- package/dist/src/global/A-Container/A-Container.class.d.ts +1 -8
- package/dist/src/global/A-Container/A-Container.class.js +1 -31
- package/dist/src/global/A-Container/A-Container.class.js.map +1 -1
- package/dist/src/global/A-Container/A-Container.meta.d.ts +8 -0
- package/dist/src/global/A-Container/A-Container.meta.js +29 -0
- package/dist/src/global/A-Container/A-Container.meta.js.map +1 -1
- package/dist/src/global/A-Container/A-Container.types.d.ts +32 -8
- package/dist/src/global/A-Container/A-Container.types.js +2 -1
- package/dist/src/global/A-Container/A-Container.types.js.map +1 -1
- package/dist/src/global/A-Context/A-Context.class.js +29 -36
- package/dist/src/global/A-Context/A-Context.class.js.map +1 -1
- package/dist/src/global/A-Entity/A-Entity.class.d.ts +1 -2
- package/dist/src/global/A-Entity/A-Entity.class.js +6 -7
- package/dist/src/global/A-Entity/A-Entity.class.js.map +1 -1
- package/dist/src/global/A-Entity/A-Entity.types.d.ts +12 -6
- package/dist/src/global/A-Entity/A-Entity.types.js.map +1 -1
- package/dist/src/global/A-Feature/A-Feature.class.d.ts +30 -6
- package/dist/src/global/A-Feature/A-Feature.class.js +49 -40
- package/dist/src/global/A-Feature/A-Feature.class.js.map +1 -1
- package/dist/src/global/A-Feature/A-Feature.types.d.ts +2 -24
- package/dist/src/global/A-Feature/A-Feature.types.js +21 -0
- package/dist/src/global/A-Feature/A-Feature.types.js.map +1 -1
- package/dist/src/global/A-Fragment/A-Fragment.class.d.ts +8 -0
- package/dist/src/global/A-Fragment/A-Fragment.class.js +10 -0
- package/dist/src/global/A-Fragment/A-Fragment.class.js.map +1 -1
- package/dist/src/global/A-Scope/A-Scope.class.d.ts +7 -5
- package/dist/src/global/A-Scope/A-Scope.class.js +33 -10
- package/dist/src/global/A-Scope/A-Scope.class.js.map +1 -1
- package/dist/src/global/A-Scope/A-Scope.types.d.ts +2 -1
- package/dist/src/global/A-Stage/A-Stage.class.d.ts +69 -0
- package/dist/src/global/A-Stage/A-Stage.class.js +181 -0
- package/dist/src/global/A-Stage/A-Stage.class.js.map +1 -0
- package/dist/src/global/A-Stage/A-Stage.types.d.ts +78 -0
- package/dist/src/global/A-Stage/A-Stage.types.js +59 -0
- package/dist/src/global/A-Stage/A-Stage.types.js.map +1 -0
- package/dist/src/helpers/StepsManager.class.d.ts +15 -0
- package/dist/src/helpers/StepsManager.class.js +85 -0
- package/dist/src/helpers/StepsManager.class.js.map +1 -0
- package/examples/fe-be/channels/Test.channel.ts +24 -0
- package/examples/fe-be/components/BE-Controller.component.ts +20 -0
- package/examples/fe-be/components/FE.component.ts +13 -0
- package/examples/fe-be/concept.ts +0 -0
- package/examples/fe-be/containers/ServerApp.container.ts +8 -0
- package/examples/fe-be/containers/WebApp.container.ts +13 -0
- package/examples/multi-container/channels/Direct.channel.ts +39 -0
- package/examples/multi-container/concept.ts +0 -0
- package/examples/multi-container/containers/Command.container.ts +41 -0
- package/examples/multi-container/containers/Schedule.container.ts +57 -0
- package/examples/simple/components/A.component.ts +2 -1
- package/examples/simple/containers/Main.container.ts +11 -3
- package/examples/simple/entities/EntityA.entity.ts +16 -0
- package/examples/simple-http-server/contexts/http-request.context.ts +6 -6
- package/index.ts +12 -3
- package/package.json +1 -1
- package/src/base/A-Errors/A-Error.entity.ts +10 -0
- package/src/base/A-Errors/A-Errors.context.ts +2 -2
- package/src/decorators/A-Abstraction/A-Abstraction.decorator.ts +82 -0
- package/src/decorators/{A-Stage/A-Stage.decorator.types.ts → A-Abstraction/A-Abstraction.decorator.types.ts} +1 -3
- package/src/decorators/A-Connect/A-Connect.decorator.ts +71 -0
- package/src/decorators/A-Connect/A-Connect.decorator.types.ts +6 -0
- package/src/decorators/A-Entity/A-Entity-List.decorator.ts +12 -0
- package/src/decorators/A-Entity/A-Entity.decorator.types.ts +18 -0
- package/src/decorators/A-Feature/A-Feature-Define.decorator.ts +16 -9
- package/src/decorators/A-Feature/A-Feature-Extend.decorator.ts +10 -2
- package/src/decorators/A-Feature/A-Feature.decorator.types.ts +46 -0
- package/src/decorators/A-Inject/A-Inject.decorator.ts +7 -7
- package/src/decorators/A-Inject/A-Inject.decorator.types.ts +47 -1
- package/src/global/A-Channel/A-Channel.class.ts +25 -28
- package/src/global/A-Channel/A-Channel.types.ts +53 -0
- package/src/global/A-Component/A-Component.class.ts +10 -2
- package/src/global/A-Component/A-Component.meta.ts +59 -6
- package/src/global/A-Component/A-Component.types.ts +28 -45
- package/src/global/A-Concept/A_Concept.class.ts +52 -31
- package/src/global/A-Concept/A_Concept.types.ts +48 -3
- package/src/global/A-Container/A-Container.class.ts +3 -39
- package/src/global/A-Container/A-Container.meta.ts +41 -4
- package/src/global/A-Container/A-Container.types.ts +36 -8
- package/src/global/A-Context/A-Context.class.ts +37 -50
- package/src/global/A-Entity/A-Entity.class.ts +8 -6
- package/src/global/A-Entity/A-Entity.types.ts +13 -6
- package/src/global/A-Feature/A-Feature.class.ts +73 -61
- package/src/global/A-Feature/A-Feature.types.ts +24 -23
- package/src/global/A-Fragment/A-Fragment.class.ts +15 -0
- package/src/global/A-Scope/A-Scope.class.ts +58 -25
- package/src/global/A-Scope/A-Scope.types.ts +2 -1
- package/src/global/A-Stage/A-Stage.class.ts +234 -0
- package/src/global/A-Stage/A-Stage.types.ts +101 -0
- package/src/helpers/StepsManager.class.ts +104 -0
- package/tests/channel.ts +213 -0
- package/tests/log.ts +88 -40
- package/src/decorators/A-Stage/A-Stage.decorator.ts +0 -84
|
@@ -28,7 +28,6 @@ export class A_Entity<
|
|
|
28
28
|
_SerializedType extends A_TYPES__Entity_JSON = A_TYPES__Entity_JSON,
|
|
29
29
|
_FeatureNames extends Array<string | A_TYPES__EntityBaseMethod> = A_TYPES__EntityBaseMethods
|
|
30
30
|
>
|
|
31
|
-
extends A_Fragment
|
|
32
31
|
implements A_TYPES__IEntity {
|
|
33
32
|
|
|
34
33
|
aseid!: ASEID;
|
|
@@ -57,8 +56,8 @@ export class A_Entity<
|
|
|
57
56
|
newEntity: _ConstructorType
|
|
58
57
|
)
|
|
59
58
|
constructor(props: string | ASEID | _SerializedType | _ConstructorType) {
|
|
60
|
-
super();
|
|
61
59
|
|
|
60
|
+
|
|
62
61
|
switch (true) {
|
|
63
62
|
case (typeof props === 'string' && ASEID.isASEID(props)):
|
|
64
63
|
this.aseid = new ASEID(props);
|
|
@@ -175,6 +174,9 @@ export class A_Entity<
|
|
|
175
174
|
? param2 || {}
|
|
176
175
|
: param1;
|
|
177
176
|
|
|
177
|
+
|
|
178
|
+
console.log('WTF???? ', A_Context.scope(this))
|
|
179
|
+
|
|
178
180
|
const newFeature = A_Context.feature(A_Context.scope(this), this, feature, params);
|
|
179
181
|
|
|
180
182
|
return await newFeature.process();
|
|
@@ -188,7 +190,7 @@ export class A_Entity<
|
|
|
188
190
|
|
|
189
191
|
async load() {
|
|
190
192
|
await this.call(A_TYPES__EntityBaseMethod.DESTROY, {
|
|
191
|
-
|
|
193
|
+
entities: [
|
|
192
194
|
this
|
|
193
195
|
]
|
|
194
196
|
});
|
|
@@ -198,9 +200,9 @@ export class A_Entity<
|
|
|
198
200
|
|
|
199
201
|
async destroy() {
|
|
200
202
|
await this.call(A_TYPES__EntityBaseMethod.DESTROY, {
|
|
201
|
-
|
|
203
|
+
entities: [
|
|
202
204
|
this
|
|
203
|
-
]
|
|
205
|
+
],
|
|
204
206
|
});
|
|
205
207
|
}
|
|
206
208
|
|
|
@@ -208,7 +210,7 @@ export class A_Entity<
|
|
|
208
210
|
|
|
209
211
|
async save() {
|
|
210
212
|
await this.call(A_TYPES__EntityBaseMethod.SAVE, {
|
|
211
|
-
|
|
213
|
+
entities: [
|
|
212
214
|
this
|
|
213
215
|
]
|
|
214
216
|
});
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { ASEID } from "@adaas/a-utils";
|
|
2
2
|
import { A_Meta } from "../A-Meta/A-Meta.class";
|
|
3
3
|
import { A_Fragment } from "../A-Fragment/A-Fragment.class";
|
|
4
|
+
import { A_TYPES__A_DefineDecorator_Meta, A_TYPES__A_ExtendDecorator_Meta } from "@adaas/a-concept/decorators/A-Feature/A-Feature.decorator.types";
|
|
5
|
+
import { A_Entity } from "./A-Entity.class";
|
|
6
|
+
import { A_TYPES__ContainerMeta_FeatureItem } from "../A-Container/A-Container.types";
|
|
4
7
|
|
|
5
8
|
|
|
6
9
|
export type A_TYPES__EntityCallParams<T extends string> = {
|
|
7
10
|
name: T,
|
|
8
11
|
fragments: Array<A_Fragment>,
|
|
12
|
+
entities: Array<A_Entity<any, any, any>>,
|
|
9
13
|
components: Array<{ new(...args: any[]): any }>
|
|
10
14
|
}
|
|
11
15
|
|
|
@@ -51,12 +55,19 @@ export type A_TYPES__EntityMeta = {
|
|
|
51
55
|
*
|
|
52
56
|
* Where value is the extension instructions
|
|
53
57
|
*/
|
|
54
|
-
[Key: string]:
|
|
58
|
+
[Key: string]: A_TYPES__A_ExtendDecorator_Meta[]
|
|
55
59
|
|
|
56
60
|
}>, case
|
|
57
61
|
|
|
58
62
|
|
|
59
|
-
[A_TYPES__EntityMetaKey.FEATURES]:
|
|
63
|
+
[A_TYPES__EntityMetaKey.FEATURES]: A_Meta<{
|
|
64
|
+
/**
|
|
65
|
+
* Where Key is the name of the feature
|
|
66
|
+
*
|
|
67
|
+
* Where value is the list of features
|
|
68
|
+
*/
|
|
69
|
+
[Key: string]: A_TYPES__A_DefineDecorator_Meta
|
|
70
|
+
}>
|
|
60
71
|
}
|
|
61
72
|
|
|
62
73
|
export enum A_TYPES__EntityMetaKey {
|
|
@@ -65,9 +76,5 @@ export enum A_TYPES__EntityMetaKey {
|
|
|
65
76
|
}
|
|
66
77
|
|
|
67
78
|
|
|
68
|
-
export type A_TYPES__EntityMeta_ExtensionItem = {
|
|
69
|
-
name: string,
|
|
70
|
-
handler: string,
|
|
71
|
-
}
|
|
72
79
|
|
|
73
80
|
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { A_Feature_Define } from "@adaas/a-concept/decorators/A-Feature/A-Feature-Define.decorator";
|
|
2
2
|
import { A_Feature_Extend } from "@adaas/a-concept/decorators/A-Feature/A-Feature-Extend.decorator";
|
|
3
|
-
import { A_TYPES__FeatureConstructor,
|
|
4
|
-
import {
|
|
3
|
+
import { A_TYPES__FeatureConstructor, A_TYPES__FeatureState, } from "./A-Feature.types";
|
|
4
|
+
import { A_Error, A_TYPES__Required } from "@adaas/a-utils";
|
|
5
5
|
import { A_Context } from "../A-Context/A-Context.class";
|
|
6
6
|
import { A_TYPES__A_Feature_Extend } from "@adaas/a-concept/decorators/A-Feature/A-Feature.decorator.types";
|
|
7
|
+
import { A_Stage } from "../A-Stage/A-Stage.class";
|
|
8
|
+
import { A_TYPES__A_StageStep } from "../A-Stage/A-Stage.types";
|
|
9
|
+
import { StepsManager } from "@adaas/a-concept/helpers/StepsManager.class";
|
|
7
10
|
|
|
8
11
|
|
|
9
12
|
|
|
@@ -34,23 +37,27 @@ export class A_Feature {
|
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
|
|
37
|
-
|
|
38
|
-
|
|
39
40
|
// protected scope: A_Scope
|
|
40
|
-
protected
|
|
41
|
-
protected _current?:
|
|
41
|
+
protected stages: Array<A_Stage> = [];
|
|
42
|
+
protected _current?: A_Stage;
|
|
42
43
|
protected _index: number = 0;
|
|
44
|
+
protected SM: StepsManager;
|
|
43
45
|
|
|
44
46
|
state: A_TYPES__FeatureState = A_TYPES__FeatureState.INITIALIZED;
|
|
45
47
|
|
|
46
48
|
result?: any
|
|
47
49
|
error?: A_Error
|
|
48
50
|
|
|
51
|
+
|
|
49
52
|
constructor(
|
|
50
53
|
params: A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps']>
|
|
51
54
|
) {
|
|
52
|
-
|
|
53
|
-
this.
|
|
55
|
+
|
|
56
|
+
this.SM = new StepsManager(params.steps);
|
|
57
|
+
|
|
58
|
+
this.stages = this.SM.toStages(this);
|
|
59
|
+
|
|
60
|
+
this._current = this.stages[0];
|
|
54
61
|
|
|
55
62
|
A_Context.allocate(this, params);
|
|
56
63
|
}
|
|
@@ -61,58 +68,69 @@ export class A_Feature {
|
|
|
61
68
|
*
|
|
62
69
|
* @returns
|
|
63
70
|
*/
|
|
64
|
-
[Symbol.iterator](): Iterator<
|
|
71
|
+
[Symbol.iterator](): Iterator<A_Stage, any> {
|
|
65
72
|
return {
|
|
66
73
|
// Custom next method
|
|
67
|
-
next: (): IteratorResult<
|
|
68
|
-
if (this.
|
|
69
|
-
if (
|
|
70
|
-
(this.state as any) === A_TYPES__FeatureState.FAILED
|
|
71
|
-
||
|
|
72
|
-
(this.state as any) === A_TYPES__FeatureState.COMPLETED
|
|
73
|
-
) {
|
|
74
|
-
throw new Error('FEATURE_PROCESSING_INTERRUPTED');
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
this._current = this.steps[this._index];
|
|
78
|
-
|
|
79
|
-
const { component, handler, args } = this._current;
|
|
74
|
+
next: (): IteratorResult<A_Stage, any> => {
|
|
75
|
+
if (!this.isDone()) {
|
|
80
76
|
|
|
81
|
-
|
|
77
|
+
this._current = this.stages[this._index];
|
|
82
78
|
|
|
83
79
|
return {
|
|
84
|
-
value:
|
|
85
|
-
if (instance[handler]) {
|
|
86
|
-
const callArgs = args.map(arg =>
|
|
87
|
-
// In case if the target is a feature step then pass the current feature
|
|
88
|
-
A_CommonHelper.isInheritedFrom(arg.target, A_Feature)
|
|
89
|
-
? this
|
|
90
|
-
: A_Context.scope(this).resolve(arg.target)
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
await instance[handler](...callArgs);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
this._index++;
|
|
97
|
-
},
|
|
80
|
+
value: this._current,
|
|
98
81
|
done: false
|
|
99
82
|
};
|
|
100
83
|
} else {
|
|
84
|
+
|
|
101
85
|
this._current = undefined; // Reset current on end
|
|
102
|
-
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
value: undefined,
|
|
89
|
+
done: true
|
|
90
|
+
};
|
|
103
91
|
}
|
|
104
92
|
}
|
|
105
93
|
};
|
|
106
94
|
}
|
|
107
95
|
|
|
108
|
-
|
|
109
|
-
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Returns the current A-Feature Stage
|
|
99
|
+
*
|
|
100
|
+
*/
|
|
101
|
+
get stage(): A_Stage | undefined {
|
|
110
102
|
return this._current;
|
|
111
103
|
}
|
|
112
104
|
|
|
113
|
-
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* This method checks if the A-Feature is done
|
|
109
|
+
*
|
|
110
|
+
* @returns
|
|
111
|
+
*/
|
|
114
112
|
isDone(): boolean {
|
|
115
|
-
return this.
|
|
113
|
+
return !this.stage
|
|
114
|
+
|| this._index >= this.stages.length
|
|
115
|
+
|| this.state === A_TYPES__FeatureState.COMPLETED
|
|
116
|
+
|| this.state === A_TYPES__FeatureState.FAILED;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* This method moves the feature to the next stage
|
|
123
|
+
*
|
|
124
|
+
* @param stage
|
|
125
|
+
*/
|
|
126
|
+
next(stage) {
|
|
127
|
+
const stageIndex = this.stages.indexOf(stage);
|
|
128
|
+
|
|
129
|
+
this._index = stageIndex + 1;
|
|
130
|
+
|
|
131
|
+
if (this._index >= this.stages.length) {
|
|
132
|
+
this.completed();
|
|
133
|
+
}
|
|
116
134
|
}
|
|
117
135
|
|
|
118
136
|
|
|
@@ -120,14 +138,15 @@ export class A_Feature {
|
|
|
120
138
|
* This method marks the feature as completed and returns the result
|
|
121
139
|
* Uses to interrupt or end the feature processing
|
|
122
140
|
*
|
|
141
|
+
* The result of the feature is a Scope Fragments
|
|
142
|
+
*
|
|
123
143
|
* @param result
|
|
124
144
|
* @returns
|
|
125
145
|
*/
|
|
126
|
-
async completed<T extends any>(
|
|
127
|
-
|
|
128
|
-
|
|
146
|
+
async completed<T extends any>(): Promise<T> {
|
|
147
|
+
|
|
148
|
+
this.result = A_Context.scope(this).toJSON();
|
|
129
149
|
|
|
130
|
-
this.result = result;
|
|
131
150
|
this.state = A_TYPES__FeatureState.COMPLETED;
|
|
132
151
|
|
|
133
152
|
return this.result;
|
|
@@ -146,25 +165,20 @@ export class A_Feature {
|
|
|
146
165
|
this.error = error as A_Error;
|
|
147
166
|
this.state = A_TYPES__FeatureState.FAILED;
|
|
148
167
|
|
|
168
|
+
|
|
149
169
|
await this.errorHandler(error);
|
|
150
170
|
}
|
|
151
171
|
|
|
152
172
|
|
|
153
|
-
|
|
173
|
+
/**
|
|
174
|
+
* This method processes the feature by executing all the stages
|
|
175
|
+
*
|
|
176
|
+
*/
|
|
154
177
|
async process() {
|
|
155
|
-
|
|
156
|
-
this.state = A_TYPES__FeatureState.PROCESSING;
|
|
178
|
+
this.state = A_TYPES__FeatureState.PROCESSING;
|
|
157
179
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
await this.completed();
|
|
163
|
-
|
|
164
|
-
} catch (error) {
|
|
165
|
-
console.log('[!] Feature processing error:', error);
|
|
166
|
-
|
|
167
|
-
await this.failed(error);
|
|
180
|
+
for (const stage of this) {
|
|
181
|
+
await stage.process();
|
|
168
182
|
}
|
|
169
183
|
}
|
|
170
184
|
|
|
@@ -198,6 +212,4 @@ export class A_Feature {
|
|
|
198
212
|
throw error;
|
|
199
213
|
}
|
|
200
214
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
215
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
import { A_TYPES__A_InjectDecorator_Injectable, A_TYPES__A_InjectDecorator_Meta } from "@adaas/a-concept/decorators/A-Inject/A-Inject.decorator.types"
|
|
1
2
|
import { A_Component } from "../A-Component/A-Component.class"
|
|
2
|
-
import { A_TYPES__ComponentMeta_InjectionParam, A_TYPES__ComponentMeta_InjectionParams } from "../A-Component/A-Component.types"
|
|
3
3
|
import { A_TYPES__ScopeConfig, A_TYPES__ScopeConstructor } from "../A-Scope/A-Scope.types"
|
|
4
|
+
import { A_TYPES__A_StageStep } from "../A-Stage/A-Stage.types"
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
export type A_TYPES__FeatureIteratorReturn<T extends any = any> = () => Promise<T>
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
export type A_TYPES__FeatureConstructor = {
|
|
10
|
-
steps:
|
|
11
|
+
steps: A_TYPES__A_StageStep[]
|
|
11
12
|
} & A_TYPES__ScopeConstructor & A_TYPES__ScopeConfig
|
|
12
13
|
|
|
13
14
|
export enum A_TYPES__FeatureState {
|
|
@@ -19,24 +20,24 @@ export enum A_TYPES__FeatureState {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
|
|
22
|
-
export type A_TYPES__FeatureStep = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
23
|
+
// export type A_TYPES__FeatureStep = {
|
|
24
|
+
// /**
|
|
25
|
+
// * The component to be called
|
|
26
|
+
// */
|
|
27
|
+
// component: typeof A_Component,
|
|
28
|
+
// /**
|
|
29
|
+
// * The method to be called on the component
|
|
30
|
+
// */
|
|
31
|
+
// handler: string,
|
|
32
|
+
// /**
|
|
33
|
+
// * Original Feature Extension name
|
|
34
|
+
// *
|
|
35
|
+
// * [!] could be string or regex
|
|
36
|
+
// *
|
|
37
|
+
// */
|
|
38
|
+
// name: string,
|
|
39
|
+
// /**
|
|
40
|
+
// * Arguments to be passed to the method
|
|
41
|
+
// */
|
|
42
|
+
// args: A_TYPES__A_InjectDecorator_Meta
|
|
43
|
+
// }
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { A_CommonHelper } from "@adaas/a-utils";
|
|
1
|
+
import { A_CommonHelper, ASEID } from "@adaas/a-utils";
|
|
2
2
|
import { A_TYPES__ScopeConfig, A_TYPES__ScopeConstructor } from "./A-Scope.types";
|
|
3
3
|
import { A_Fragment } from "../A-Fragment/A-Fragment.class";
|
|
4
4
|
import { A_Context } from "../A-Context/A-Context.class";
|
|
5
5
|
import {
|
|
6
|
-
A_TYPES__ComponentMeta_EntityInjectionInstructions,
|
|
7
|
-
A_TYPES__ComponentMeta_InjectionParam,
|
|
8
6
|
A_TYPES__ComponentMetaKey
|
|
9
7
|
} from "../A-Component/A-Component.types";
|
|
10
8
|
import { A_Component } from "../A-Component/A-Component.class";
|
|
11
9
|
import { A_Entity } from "../A-Entity/A-Entity.class";
|
|
10
|
+
import { A_TYPES__A_InjectDecorator_EntityInjectionInstructions, A_TYPES__A_InjectDecorator_EntityInjectionQuery, A_TYPES__A_InjectDecorator_Injectable } from "@adaas/a-concept/decorators/A-Inject/A-Inject.decorator.types";
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
*
|
|
@@ -72,6 +71,10 @@ export class A_Scope {
|
|
|
72
71
|
// })
|
|
73
72
|
}
|
|
74
73
|
|
|
74
|
+
private initEntities(_entities: Array<A_Entity>) {
|
|
75
|
+
_entities.forEach(this.register.bind(this));
|
|
76
|
+
}
|
|
77
|
+
|
|
75
78
|
|
|
76
79
|
private initFragments(_fragments: Array<A_Fragment>) {
|
|
77
80
|
_fragments.forEach(this.register.bind(this));
|
|
@@ -111,7 +114,7 @@ export class A_Scope {
|
|
|
111
114
|
switch (true) {
|
|
112
115
|
|
|
113
116
|
case A_CommonHelper.isInheritedFrom(entity, A_Component): {
|
|
114
|
-
const found = this.params.components.includes(entity);
|
|
117
|
+
const found = this.params.components.includes(entity as { new(...args: any[]): A_Component });
|
|
115
118
|
|
|
116
119
|
if (!found && !!this.parent)
|
|
117
120
|
return this.parent.has(entity as any);
|
|
@@ -149,20 +152,20 @@ export class A_Scope {
|
|
|
149
152
|
* @param component
|
|
150
153
|
* @returns
|
|
151
154
|
*/
|
|
152
|
-
resolve<T extends
|
|
155
|
+
resolve<T extends A_TYPES__A_InjectDecorator_Injectable>(
|
|
153
156
|
component: T
|
|
154
157
|
): InstanceType<T>
|
|
155
158
|
resolve<T extends { new(...args: any[]): A_Entity }>(
|
|
156
159
|
entity: T,
|
|
157
|
-
instructions: Partial<
|
|
160
|
+
instructions: Partial<A_TYPES__A_InjectDecorator_EntityInjectionInstructions>
|
|
158
161
|
): InstanceType<T>
|
|
159
|
-
resolve<T extends
|
|
162
|
+
resolve<T extends A_TYPES__A_InjectDecorator_Injectable>(
|
|
160
163
|
component: Array<T>
|
|
161
164
|
): Array<InstanceType<T>>
|
|
162
165
|
// base definition
|
|
163
|
-
resolve<T extends
|
|
166
|
+
resolve<T extends A_TYPES__A_InjectDecorator_Injectable>(
|
|
164
167
|
param1: Array<T> | T,
|
|
165
|
-
param2?: string | Partial<
|
|
168
|
+
param2?: string | Partial<A_TYPES__A_InjectDecorator_EntityInjectionInstructions>
|
|
166
169
|
): Array<InstanceType<T>> | InstanceType<T> {
|
|
167
170
|
|
|
168
171
|
switch (true) {
|
|
@@ -182,16 +185,18 @@ export class A_Scope {
|
|
|
182
185
|
|
|
183
186
|
|
|
184
187
|
|
|
188
|
+
|
|
189
|
+
|
|
185
190
|
private resolveOnce<T extends { new(...args: any[]): A_Entity }>(
|
|
186
191
|
entity: T,
|
|
187
|
-
instructions: Partial<
|
|
192
|
+
instructions: Partial<A_TYPES__A_InjectDecorator_EntityInjectionInstructions>
|
|
188
193
|
): InstanceType<T> | undefined
|
|
189
|
-
private resolveOnce<T extends
|
|
194
|
+
private resolveOnce<T extends A_TYPES__A_InjectDecorator_Injectable>(
|
|
190
195
|
component: T
|
|
191
196
|
): InstanceType<T>
|
|
192
|
-
private resolveOnce<T extends { new(...args: any[]): A_Entity } |
|
|
197
|
+
private resolveOnce<T extends { new(...args: any[]): A_Entity } | A_TYPES__A_InjectDecorator_Injectable>(
|
|
193
198
|
component: T,
|
|
194
|
-
instructions?: Partial<
|
|
199
|
+
instructions?: Partial<A_TYPES__A_InjectDecorator_EntityInjectionInstructions>
|
|
195
200
|
): InstanceType<T> {
|
|
196
201
|
switch (true) {
|
|
197
202
|
case A_CommonHelper.isInheritedFrom(component, A_Entity): {
|
|
@@ -218,9 +223,13 @@ export class A_Scope {
|
|
|
218
223
|
|
|
219
224
|
private resolveEntity<T extends { new(...args: any[]): A_Entity }>(
|
|
220
225
|
entity: T,
|
|
221
|
-
instructions?: Partial<
|
|
226
|
+
instructions?: Partial<A_TYPES__A_InjectDecorator_EntityInjectionInstructions>
|
|
222
227
|
): InstanceType<T> | undefined {
|
|
223
228
|
|
|
229
|
+
const query = instructions?.query || {};
|
|
230
|
+
const count = instructions?.pagination?.count || 1;
|
|
231
|
+
|
|
232
|
+
|
|
224
233
|
switch (true) {
|
|
225
234
|
case !instructions: {
|
|
226
235
|
|
|
@@ -233,25 +242,34 @@ export class A_Scope {
|
|
|
233
242
|
return found as InstanceType<T>;
|
|
234
243
|
|
|
235
244
|
case !found && !!this.parent:
|
|
236
|
-
return this.parent.
|
|
245
|
+
return this.parent.resolveEntity(entity, instructions);
|
|
237
246
|
|
|
238
247
|
default:
|
|
239
248
|
throw new Error(`Fragment ${entity.name} not found in the scope ${this.name}`);
|
|
240
249
|
}
|
|
241
250
|
}
|
|
242
251
|
|
|
243
|
-
case !!
|
|
244
|
-
|
|
245
|
-
|
|
252
|
+
case !!query.aseid
|
|
253
|
+
&& typeof query.aseid === 'string'
|
|
254
|
+
&& this._entities.has(query.aseid): {
|
|
255
|
+
return this._entities.get(query.aseid) as InstanceType<T>;
|
|
256
|
+
}
|
|
246
257
|
|
|
247
|
-
case !!
|
|
248
|
-
|
|
249
|
-
|
|
258
|
+
case !!query.aseid
|
|
259
|
+
&& query.aseid instanceof ASEID
|
|
260
|
+
&& this._entities.has(query.aseid.toString()): {
|
|
261
|
+
return this._entities.get(query.aseid.toString()) as InstanceType<T>;
|
|
262
|
+
}
|
|
250
263
|
|
|
251
|
-
|
|
264
|
+
case !!query.id
|
|
265
|
+
&& this._entities.has(query.id): {
|
|
266
|
+
// in this case we have to find the entity by the id
|
|
267
|
+
const entities = Array.from(this._entities.values());
|
|
252
268
|
|
|
253
|
-
|
|
254
|
-
|
|
269
|
+
const found = entities.find(e => e.id === query.id);
|
|
270
|
+
|
|
271
|
+
return found as InstanceType<T>;
|
|
272
|
+
}
|
|
255
273
|
|
|
256
274
|
default:
|
|
257
275
|
throw new Error(`Entity ${entity.constructor.name} not found in the scope ${this.name}`);
|
|
@@ -331,7 +349,7 @@ export class A_Scope {
|
|
|
331
349
|
|
|
332
350
|
const found = this.components.find(el => A_CommonHelper.isInheritedFrom(el, component));
|
|
333
351
|
|
|
334
|
-
return this.resolveComponent(found
|
|
352
|
+
return this.resolveComponent<T>(found as any);
|
|
335
353
|
}
|
|
336
354
|
|
|
337
355
|
// In case when the component is not available in the scope but the parent is available
|
|
@@ -398,4 +416,19 @@ export class A_Scope {
|
|
|
398
416
|
|
|
399
417
|
|
|
400
418
|
}
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
toJSON(): Record<string, any> {
|
|
424
|
+
return this.fragments.reduce((acc, fragment) => {
|
|
425
|
+
|
|
426
|
+
const serialized = fragment.toJSON()
|
|
427
|
+
|
|
428
|
+
return {
|
|
429
|
+
...acc,
|
|
430
|
+
[serialized.name]: serialized
|
|
431
|
+
}
|
|
432
|
+
}, {});
|
|
433
|
+
}
|
|
401
434
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { A_Component } from "../A-Component/A-Component.class"
|
|
1
2
|
import { A_Fragment } from "../A-Fragment/A-Fragment.class"
|
|
2
3
|
import { A_Scope } from "./A-Scope.class"
|
|
3
4
|
|
|
@@ -15,7 +16,7 @@ export type A_TYPES__ScopeConstructor = {
|
|
|
15
16
|
/**
|
|
16
17
|
* A set of Components available in the Scope
|
|
17
18
|
*/
|
|
18
|
-
components: Array<{ new(...args: any[]):
|
|
19
|
+
components: Array<{ new(...args: any[]): A_Component }>
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
/**
|