@adaas/a-concept 0.0.29 → 0.0.30
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/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-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 +28 -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 +8 -0
- package/dist/src/global/A-Component/A-Component.meta.js +27 -1
- package/dist/src/global/A-Component/A-Component.meta.js.map +1 -1
- package/dist/src/global/A-Component/A-Component.types.d.ts +19 -34
- 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 +23 -7
- 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 +6 -35
- 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 +4 -5
- 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 +176 -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 +83 -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/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-Extend.decorator.ts +10 -0
- package/src/decorators/A-Feature/A-Feature.decorator.types.ts +36 -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 +42 -1
- package/src/global/A-Component/A-Component.types.ts +20 -40
- 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 +28 -7
- package/src/global/A-Context/A-Context.class.ts +9 -49
- package/src/global/A-Entity/A-Entity.class.ts +8 -6
- package/src/global/A-Entity/A-Entity.types.ts +4 -5
- 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 +225 -0
- package/src/global/A-Stage/A-Stage.types.ts +106 -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
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A_TYPES__A_InjectDecorator_Meta } from "@adaas/a-concept/decorators/A-Inject/A-Inject.decorator.types";
|
|
2
|
+
import { A_TYPES__ConceptAbstraction, A_TYPES__ConceptAbstractionMeta, A_TYPES__ConceptStage } from "../A-Concept/A_Concept.types";
|
|
2
3
|
import { A_Fragment } from "../A-Fragment/A-Fragment.class";
|
|
4
|
+
import { A_Meta } from "../A-Meta/A-Meta.class";
|
|
3
5
|
import { A_TYPES__ScopeConstructor } from "../A-Scope/A-Scope.types";
|
|
6
|
+
import { A_TYPES__A_ExtendDecorator_BehaviorConfig } from "@adaas/a-concept/decorators/A-Feature/A-Feature.decorator.types";
|
|
4
7
|
|
|
5
8
|
|
|
6
9
|
|
|
@@ -18,19 +21,37 @@ export type A_TYPES__ContainerCallParams<T extends string> = {
|
|
|
18
21
|
|
|
19
22
|
export type A_TYPES__ContainerMeta = {
|
|
20
23
|
[A_TYPES__ContainerMetaKey.FEATURES]: Map<string, A_TYPES__ContainerMeta_FeatureItem>
|
|
21
|
-
[A_TYPES__ContainerMetaKey.
|
|
24
|
+
[A_TYPES__ContainerMetaKey.ABSTRACTIONS]: A_Meta<{
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Where Key the regexp for what to apply the extension
|
|
28
|
+
* A set of container names or a wildcard, or a regexp
|
|
29
|
+
*
|
|
30
|
+
*
|
|
31
|
+
* Where value is the extension instructions
|
|
32
|
+
*/
|
|
33
|
+
[Key: string]: A_TYPES__ConceptAbstraction[]
|
|
34
|
+
}>,
|
|
35
|
+
[A_TYPES__ContainerMetaKey.INJECTIONS]: A_Meta<{
|
|
36
|
+
/**
|
|
37
|
+
* Where Key is the name of the injection
|
|
38
|
+
*
|
|
39
|
+
* Where value is the list of injections
|
|
40
|
+
*/
|
|
41
|
+
[Key: string]: A_TYPES__A_InjectDecorator_Meta
|
|
42
|
+
}>
|
|
43
|
+
|
|
22
44
|
}
|
|
23
45
|
|
|
24
46
|
|
|
25
47
|
export enum A_TYPES__ContainerMetaKey {
|
|
26
48
|
FEATURES = 'a-container-features',
|
|
27
|
-
|
|
49
|
+
INJECTIONS = 'a-container-injections',
|
|
50
|
+
ABSTRACTIONS = 'a-container-abstractions',
|
|
28
51
|
}
|
|
29
52
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
handler: string,
|
|
33
|
-
}
|
|
53
|
+
|
|
54
|
+
|
|
34
55
|
|
|
35
56
|
|
|
36
57
|
export type A_TYPES__ContainerMeta_FeatureItem = {
|
|
@@ -12,7 +12,8 @@ import { A_Concept } from "../A-Concept/A_Concept.class";
|
|
|
12
12
|
import { A_TYPES__EntityBaseMethod } from "../A-Entity/A-Entity.types";
|
|
13
13
|
import { A_Entity } from "../A-Entity/A-Entity.class";
|
|
14
14
|
import { A_EntityMeta } from "../A-Entity/A-Entity.meta";
|
|
15
|
-
import { A_TYPES__FeatureConstructor
|
|
15
|
+
import { A_TYPES__FeatureConstructor } from "../A-Feature/A-Feature.types";
|
|
16
|
+
import { A_TYPES__A_StageStep } from "../A-Stage/A-Stage.types";
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
/**
|
|
@@ -61,8 +62,6 @@ export class A_Context {
|
|
|
61
62
|
/**
|
|
62
63
|
* A set of allocated scopes per every element in the program.
|
|
63
64
|
*/
|
|
64
|
-
// protected scopes: WeakMap<A_Container<any> | A_Feature | A_Component | any, A_Scope> = new WeakMap();
|
|
65
|
-
|
|
66
65
|
protected conceptsMeta: Map<typeof A_Concept.constructor, A_Meta<any>> = new Map();
|
|
67
66
|
protected containersMeta: Map<typeof A_Container.constructor, A_ContainerMeta> = new Map();
|
|
68
67
|
protected componentsMeta: Map<typeof A_Component, A_ComponentMeta> = new Map();
|
|
@@ -369,8 +368,6 @@ export class A_Context {
|
|
|
369
368
|
param2: string | T[number],
|
|
370
369
|
param3?: Partial<A_TYPES__ScopeConstructor>
|
|
371
370
|
): A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps', 'fragments', 'name', 'components']> {
|
|
372
|
-
|
|
373
|
-
|
|
374
371
|
const instance = this.getInstance();
|
|
375
372
|
|
|
376
373
|
const component = param1;
|
|
@@ -407,7 +404,7 @@ export class A_Context {
|
|
|
407
404
|
* While Scope we use just to store the scope where the component registered.
|
|
408
405
|
*
|
|
409
406
|
*/
|
|
410
|
-
const steps:
|
|
407
|
+
const steps: A_TYPES__A_StageStep[] = [];
|
|
411
408
|
// const feature: string = new ASEID({
|
|
412
409
|
// id: `${param2}-${Math.random()}`,
|
|
413
410
|
// entity: 'a-feature',
|
|
@@ -427,12 +424,10 @@ export class A_Context {
|
|
|
427
424
|
// Get all extensions for the feature
|
|
428
425
|
meta
|
|
429
426
|
.extensions(feature)
|
|
430
|
-
.forEach((
|
|
427
|
+
.forEach((declaration) => {
|
|
431
428
|
steps.push({
|
|
432
429
|
component: constructor,
|
|
433
|
-
|
|
434
|
-
handler,
|
|
435
|
-
args
|
|
430
|
+
...declaration
|
|
436
431
|
});
|
|
437
432
|
});
|
|
438
433
|
});
|
|
@@ -513,7 +508,6 @@ export class A_Context {
|
|
|
513
508
|
scope: A_Scope,
|
|
514
509
|
param1: A_Fragment | A_Container<any> | A_Entity | A_Component
|
|
515
510
|
) {
|
|
516
|
-
|
|
517
511
|
const instance = this.getInstance();
|
|
518
512
|
|
|
519
513
|
if (!instance._root)
|
|
@@ -532,49 +526,15 @@ export class A_Context {
|
|
|
532
526
|
instance.registry.set(param1, scope);
|
|
533
527
|
break;
|
|
534
528
|
|
|
535
|
-
case param1 instanceof A_Fragment:
|
|
529
|
+
case param1 instanceof A_Fragment && !instance.registry.has(param1):
|
|
536
530
|
instance.registry.set(param1, scope);
|
|
537
531
|
break;
|
|
538
532
|
|
|
539
533
|
default:
|
|
540
|
-
instance.registry.
|
|
534
|
+
if (!instance.registry.has(param1))
|
|
535
|
+
instance.registry.set(param1, scope);
|
|
541
536
|
|
|
537
|
+
break;
|
|
542
538
|
}
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
// if (param1 instanceof A_Fragment) {
|
|
546
|
-
|
|
547
|
-
// const instance = this.getInstance();
|
|
548
|
-
|
|
549
|
-
// let fragment: A_Fragment;
|
|
550
|
-
// let name: string;
|
|
551
|
-
|
|
552
|
-
// if (typeof param2 === 'string') {
|
|
553
|
-
// name = param2;
|
|
554
|
-
// fragment = param1;
|
|
555
|
-
// } else {
|
|
556
|
-
// fragment = param1 as A_Fragment;
|
|
557
|
-
// name = fragment.name;
|
|
558
|
-
// }
|
|
559
|
-
|
|
560
|
-
// /**
|
|
561
|
-
// * If the namespace is not provided, then use the root namespace.
|
|
562
|
-
// * If the root namespace is not provided, then use the default namespace.
|
|
563
|
-
// */
|
|
564
|
-
// if (!name)
|
|
565
|
-
// name = this.root
|
|
566
|
-
// || process.env.ADAAS_NAMESPACE
|
|
567
|
-
// || process.env.A_NAMESPACE
|
|
568
|
-
// || process.env.ADAAS_APP_NAMESPACE
|
|
569
|
-
// || 'a-concept'
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
// if (!this.root)
|
|
573
|
-
// instance._root = name;
|
|
574
|
-
|
|
575
|
-
// // instance.namedFragments.set(namespace, Namespace);
|
|
576
|
-
|
|
577
|
-
// return name;
|
|
578
|
-
|
|
579
539
|
}
|
|
580
540
|
}
|
|
@@ -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,14 @@
|
|
|
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_ExtendDecorator_Meta } from "@adaas/a-concept/decorators/A-Feature/A-Feature.decorator.types";
|
|
5
|
+
import { A_Entity } from "./A-Entity.class";
|
|
4
6
|
|
|
5
7
|
|
|
6
8
|
export type A_TYPES__EntityCallParams<T extends string> = {
|
|
7
9
|
name: T,
|
|
8
10
|
fragments: Array<A_Fragment>,
|
|
11
|
+
entities: Array<A_Entity<any, any, any>>,
|
|
9
12
|
components: Array<{ new(...args: any[]): any }>
|
|
10
13
|
}
|
|
11
14
|
|
|
@@ -51,7 +54,7 @@ export type A_TYPES__EntityMeta = {
|
|
|
51
54
|
*
|
|
52
55
|
* Where value is the extension instructions
|
|
53
56
|
*/
|
|
54
|
-
[Key: string]:
|
|
57
|
+
[Key: string]: A_TYPES__A_ExtendDecorator_Meta[]
|
|
55
58
|
|
|
56
59
|
}>, case
|
|
57
60
|
|
|
@@ -65,9 +68,5 @@ export enum A_TYPES__EntityMetaKey {
|
|
|
65
68
|
}
|
|
66
69
|
|
|
67
70
|
|
|
68
|
-
export type A_TYPES__EntityMeta_ExtensionItem = {
|
|
69
|
-
name: string,
|
|
70
|
-
handler: string,
|
|
71
|
-
}
|
|
72
71
|
|
|
73
72
|
|
|
@@ -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
|
+
// }
|