@adaas/a-concept 0.1.17 → 0.1.19
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/index.d.ts +2 -0
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/src/global/A-Abstraction/A-Abstraction-Extend.decorator.js +22 -7
- package/dist/src/global/A-Abstraction/A-Abstraction-Extend.decorator.js.map +1 -1
- package/dist/src/global/A-Component/A-Component.meta.js +2 -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 +2 -11
- package/dist/src/global/A-Concept/A-Concept.types.d.ts +4 -21
- package/dist/src/global/A-Container/A-Container.meta.js +4 -2
- package/dist/src/global/A-Container/A-Container.meta.js.map +1 -1
- package/dist/src/global/A-Container/A-Container.types.d.ts +2 -11
- package/dist/src/global/A-Context/A-Context.class.d.ts +8 -0
- package/dist/src/global/A-Context/A-Context.class.js +30 -2
- package/dist/src/global/A-Context/A-Context.class.js.map +1 -1
- package/dist/src/global/A-Feature/A-Feature-Define.decorator.js +1 -1
- package/dist/src/global/A-Feature/A-Feature-Define.decorator.js.map +1 -1
- package/dist/src/global/A-Feature/A-Feature-Extend.decorator.js +27 -8
- package/dist/src/global/A-Feature/A-Feature-Extend.decorator.js.map +1 -1
- package/dist/src/global/A-Feature/A-Feature.class.d.ts +2 -1
- package/dist/src/global/A-Feature/A-Feature.class.js +7 -3
- package/dist/src/global/A-Feature/A-Feature.class.js.map +1 -1
- package/dist/src/global/A-Feature/A-Feature.types.d.ts +69 -27
- package/dist/src/global/A-Stage/A-Stage.class.d.ts +37 -28
- package/dist/src/global/A-Stage/A-Stage.class.js +62 -98
- package/dist/src/global/A-Stage/A-Stage.class.js.map +1 -1
- package/dist/src/global/A-Stage/A-Stage.types.d.ts +30 -3
- package/dist/src/global/A-Stage/A-Stage.types.js.map +1 -1
- package/dist/src/global/A-StepManager/A-StepManager.class.d.ts +20 -0
- package/dist/src/{helpers/A_StepsManager.class.js → global/A-StepManager/A-StepManager.class.js} +38 -64
- package/dist/src/global/A-StepManager/A-StepManager.class.js.map +1 -0
- package/dist/src/global/A-StepManager/A-StepManager.error.d.ts +4 -0
- package/dist/src/global/A-StepManager/A-StepManager.error.js +9 -0
- package/dist/src/global/A-StepManager/A-StepManager.error.js.map +1 -0
- package/index.ts +2 -1
- package/package.json +3 -3
- package/src/global/A-Abstraction/A-Abstraction-Extend.decorator.ts +27 -7
- package/src/global/A-Component/A-Component.meta.ts +2 -1
- package/src/global/A-Component/A-Component.types.ts +2 -11
- package/src/global/A-Concept/A-Concept.types.ts +4 -21
- package/src/global/A-Container/A-Container.meta.ts +4 -2
- package/src/global/A-Container/A-Container.types.ts +2 -11
- package/src/global/A-Context/A-Context.class.ts +40 -3
- package/src/global/A-Feature/A-Feature-Define.decorator.ts +1 -0
- package/src/global/A-Feature/A-Feature-Extend.decorator.ts +34 -8
- package/src/global/A-Feature/A-Feature.class.ts +8 -1
- package/src/global/A-Feature/A-Feature.types.ts +80 -33
- package/src/global/A-Stage/A-Stage.class.ts +71 -143
- package/src/global/A-Stage/A-Stage.types.ts +34 -3
- package/src/{helpers/A_StepsManager.class.ts → global/A-StepManager/A-StepManager.class.ts} +53 -87
- package/src/global/A-StepManager/A-StepManager.error.ts +10 -0
- package/tests/A-Abstraction.test.ts +274 -190
- package/tests/A-Feature.test.ts +84 -1
- package/tests/A-StepManager.test.ts +346 -0
- package/dist/src/helpers/A_StepsManager.class.d.ts +0 -35
- package/dist/src/helpers/A_StepsManager.class.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A_TYPES__A_StageStep } from "../A-Stage/A-Stage.types";
|
|
1
|
+
import { A_TYPES__A_StageStep, A_TYPES_StageExecutionBehavior } from "../A-Stage/A-Stage.types";
|
|
2
2
|
import { A_Entity } from "../A-Entity/A-Entity.class";
|
|
3
3
|
import { A_Container } from "../A-Container/A-Container.class";
|
|
4
4
|
import { A_Component } from "../A-Component/A-Component.class";
|
|
@@ -168,23 +168,10 @@ export type A_TYPES__FeatureExtendDecoratorDescriptor = TypedPropertyDescriptor<
|
|
|
168
168
|
* [!] Can be applied only on A-Components
|
|
169
169
|
*/
|
|
170
170
|
export type A_TYPES__FeatureExtendDecoratorTarget = A_Component;
|
|
171
|
-
/**
|
|
172
|
-
* Meta type for A_Extend decorator
|
|
173
|
-
*/
|
|
174
|
-
export type A_TYPES__FeatureExtendDecoratorMeta = {
|
|
175
|
-
/**
|
|
176
|
-
* Original Feature Extension name
|
|
177
|
-
*
|
|
178
|
-
* [!] could be string or regex
|
|
179
|
-
*/
|
|
180
|
-
name: string;
|
|
181
|
-
/**
|
|
182
|
-
* Actual method name in the class
|
|
183
|
-
*/
|
|
184
|
-
handler: string;
|
|
185
|
-
} & A_TYPES__FeatureExtendDecoratorBehaviorConfig;
|
|
186
171
|
/**
|
|
187
172
|
* Configuration type for A_Extend decorator
|
|
173
|
+
*
|
|
174
|
+
* This is an INPUT parameter provided by the user
|
|
188
175
|
*/
|
|
189
176
|
export type A_TYPES__FeatureExtendDecoratorConfig = {
|
|
190
177
|
/**
|
|
@@ -215,7 +202,52 @@ export type A_TYPES__FeatureExtendDecoratorConfig = {
|
|
|
215
202
|
* ```
|
|
216
203
|
*/
|
|
217
204
|
scope: Array<A_TYPES__FeatureExtendDecoratorScopeItem> | Partial<A_TYPES__FeatureExtendDecoratorScopeConfig>;
|
|
218
|
-
|
|
205
|
+
/**
|
|
206
|
+
* The behavior of the method.
|
|
207
|
+
* In case its async it will be executed independently from the main thread.
|
|
208
|
+
*
|
|
209
|
+
* [!] However, in case of sync, it will be executed in the main thread.in the order of the declaration.
|
|
210
|
+
*
|
|
211
|
+
*/
|
|
212
|
+
behavior: A_TYPES_StageExecutionBehavior;
|
|
213
|
+
/**
|
|
214
|
+
* Allows to define the order of the execution of the method.
|
|
215
|
+
*
|
|
216
|
+
* [!] It applies for the following structure :'Component.methodName'
|
|
217
|
+
* [!] In case the method has circular dependencies it will Throw an error.
|
|
218
|
+
*
|
|
219
|
+
* Example:
|
|
220
|
+
* ```ts
|
|
221
|
+
* @A_Feature.Extend({
|
|
222
|
+
* name: 'load',
|
|
223
|
+
* before: ['Component1.methodName', /Component2\..+/]
|
|
224
|
+
* })
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
before: Array<string | RegExp>;
|
|
228
|
+
/**
|
|
229
|
+
* Allows to define the order of the execution of the method.
|
|
230
|
+
*
|
|
231
|
+
* [!] It applies for the following structure :'Component.methodName'
|
|
232
|
+
* [!] In case the method has circular dependencies it will Throw an error.
|
|
233
|
+
*
|
|
234
|
+
* Example:
|
|
235
|
+
* ```ts
|
|
236
|
+
* @A_Feature.Extend({
|
|
237
|
+
* name: 'load',
|
|
238
|
+
* before: ['Component1.methodName', /Component2\..+/]
|
|
239
|
+
* })
|
|
240
|
+
* ```
|
|
241
|
+
*
|
|
242
|
+
*/
|
|
243
|
+
after: Array<string | RegExp>;
|
|
244
|
+
/**
|
|
245
|
+
* Indicates whether to throw an error if the step fails.
|
|
246
|
+
*
|
|
247
|
+
* [!] By default is true
|
|
248
|
+
*/
|
|
249
|
+
throwOnError: boolean;
|
|
250
|
+
};
|
|
219
251
|
/**
|
|
220
252
|
* Scope item that can be used in A_Extend decorator configuration
|
|
221
253
|
*/
|
|
@@ -232,17 +264,21 @@ export type A_TYPES__FeatureExtendDecoratorScopeConfig = {
|
|
|
232
264
|
/**
|
|
233
265
|
* A single item that can be used in scope configuration
|
|
234
266
|
*/
|
|
235
|
-
export type A_TYPES__FeatureExtendDecoratorScopeItem =
|
|
236
|
-
new (...args: any[]): A_Container;
|
|
237
|
-
} | {
|
|
238
|
-
new (...args: any[]): A_Entity;
|
|
239
|
-
} | {
|
|
240
|
-
new (...args: any[]): A_Component;
|
|
241
|
-
};
|
|
267
|
+
export type A_TYPES__FeatureExtendDecoratorScopeItem = A_TYPES__Container_Constructor | A_TYPES__Entity_Constructor | A_TYPES__Component_Constructor;
|
|
242
268
|
/**
|
|
243
|
-
*
|
|
269
|
+
* Meta type for A_Extend decorator
|
|
244
270
|
*/
|
|
245
|
-
export type
|
|
271
|
+
export type A_TYPES__FeatureExtendDecoratorMeta = {
|
|
272
|
+
/**
|
|
273
|
+
* Original Feature Extension name
|
|
274
|
+
*
|
|
275
|
+
* [!] could be string or regex
|
|
276
|
+
*/
|
|
277
|
+
name: string;
|
|
278
|
+
/**
|
|
279
|
+
* Actual method name in the class
|
|
280
|
+
*/
|
|
281
|
+
handler: string;
|
|
246
282
|
/**
|
|
247
283
|
* The behavior of the method.
|
|
248
284
|
* In case its async it will be executed independently from the main thread.
|
|
@@ -250,7 +286,7 @@ export type A_TYPES__FeatureExtendDecoratorBehaviorConfig = {
|
|
|
250
286
|
* [!] However, in case of sync, it will be executed in the main thread.in the order of the declaration.
|
|
251
287
|
*
|
|
252
288
|
*/
|
|
253
|
-
behavior:
|
|
289
|
+
behavior: A_TYPES_StageExecutionBehavior;
|
|
254
290
|
/**
|
|
255
291
|
* Allows to define the order of the execution of the method.
|
|
256
292
|
*
|
|
@@ -265,4 +301,10 @@ export type A_TYPES__FeatureExtendDecoratorBehaviorConfig = {
|
|
|
265
301
|
*
|
|
266
302
|
*/
|
|
267
303
|
after: string[];
|
|
304
|
+
/**
|
|
305
|
+
* Indicates whether to throw an error if the step fails.
|
|
306
|
+
*
|
|
307
|
+
* [!] By default is true
|
|
308
|
+
*/
|
|
309
|
+
throwOnError: boolean;
|
|
268
310
|
};
|
|
@@ -1,53 +1,67 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A_TYPES__A_Stage_Status, A_TYPES__A_StageStep, A_TYPES__Stage_Serialized } from "./A-Stage.types";
|
|
2
2
|
import { A_Feature } from "../A-Feature/A-Feature.class";
|
|
3
3
|
import { A_Scope } from "../A-Scope/A-Scope.class";
|
|
4
4
|
import { A_Error } from "../A-Error/A_Error.class";
|
|
5
5
|
import { A_TYPES__ScopeResolvableComponents } from "../A-Scope/A-Scope.types";
|
|
6
6
|
import { A_TYPES__Component_Constructor } from "../A-Component/A-Component.types";
|
|
7
7
|
export declare class A_Stage {
|
|
8
|
+
/**
|
|
9
|
+
* The feature that owns this stage
|
|
10
|
+
*/
|
|
8
11
|
private readonly _feature;
|
|
9
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Initial Instructions to process the stage
|
|
14
|
+
*/
|
|
15
|
+
private readonly _definition;
|
|
16
|
+
/**
|
|
17
|
+
* Possible errors during stage processing
|
|
18
|
+
*/
|
|
10
19
|
private _error?;
|
|
11
20
|
/**
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
|
|
21
|
+
* Indicates the current status of the stage
|
|
22
|
+
*/
|
|
23
|
+
private _status;
|
|
24
|
+
/**
|
|
25
|
+
* Promise that will be resolved when the stage is Processed
|
|
26
|
+
*/
|
|
27
|
+
private _processed;
|
|
28
|
+
/**
|
|
29
|
+
* A_Stage is a callable A_Function within A_Feature that should be run with specific parameters.
|
|
30
|
+
* [!] Depending on the Stage Definition type sync/async function can be executed correspondingly.
|
|
15
31
|
*
|
|
16
32
|
* A-Stage is a common object that uses to simplify logic and re-use of A-Feature internals for better composition.
|
|
17
33
|
*/
|
|
18
|
-
constructor(
|
|
19
|
-
status: A_TYPES__A_Stage_Status;
|
|
34
|
+
constructor(
|
|
20
35
|
/**
|
|
21
|
-
*
|
|
36
|
+
* The feature that owns this stage
|
|
37
|
+
*/
|
|
38
|
+
feature: A_Feature,
|
|
39
|
+
/**
|
|
40
|
+
* The step definitions of the stage
|
|
41
|
+
*/
|
|
42
|
+
step: A_TYPES__A_StageStep);
|
|
43
|
+
/**
|
|
44
|
+
* Returns the name of the stage
|
|
22
45
|
*/
|
|
23
|
-
processed: Promise<void> | undefined;
|
|
24
46
|
get name(): string;
|
|
25
|
-
get before(): string[];
|
|
26
|
-
get after(): string[];
|
|
27
|
-
get steps(): A_TYPES__A_StageStep[];
|
|
28
|
-
get asyncSteps(): A_TYPES__A_StageStep[];
|
|
29
|
-
get syncSteps(): A_TYPES__A_StageStep[];
|
|
30
47
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* @param step
|
|
34
|
-
* @returns
|
|
48
|
+
* Returns the current status of the stage
|
|
35
49
|
*/
|
|
36
|
-
|
|
50
|
+
get status(): A_TYPES__A_Stage_Status;
|
|
37
51
|
/**
|
|
38
|
-
*
|
|
52
|
+
* Resolves the arguments of the step
|
|
39
53
|
*
|
|
40
54
|
* @param step
|
|
41
55
|
* @returns
|
|
42
56
|
*/
|
|
43
|
-
|
|
57
|
+
protected getStepArgs(scope: A_Scope, step: A_TYPES__A_StageStep): Promise<(import("../A-Component/A-Component.class").A_Component | import("../A-Container/A-Container.class").A_Container | import("../A-Entity/A-Entity.class").A_Entity<any, import("../A-Entity/A-Entity.types").A_TYPES__Entity_Serialized> | A_Scope<A_TYPES__Component_Constructor[], import("../A-Error/A_Error.types").A_TYPES__Error_Constructor[], import("../A-Entity/A-Entity.types").A_TYPES__Entity_Constructor[], import("../A-Fragment/A-Fragment.class").A_Fragment<any>[]> | import("../A-Fragment/A-Fragment.class").A_Fragment<any> | A_Feature<import("../A-Feature/A-Feature.types").A_TYPES__FeatureAvailableComponents> | A_TYPES__ScopeResolvableComponents[])[]>;
|
|
44
58
|
/**
|
|
45
59
|
* Resolves the component of the step
|
|
46
60
|
*
|
|
47
61
|
* @param step
|
|
48
62
|
* @returns
|
|
49
63
|
*/
|
|
50
|
-
protected
|
|
64
|
+
protected getStepComponent(scope: A_Scope, step: A_TYPES__A_StageStep): A_TYPES__ScopeResolvableComponents;
|
|
51
65
|
/**
|
|
52
66
|
* Calls the handler of the step
|
|
53
67
|
*
|
|
@@ -66,18 +80,13 @@ export declare class A_Stage {
|
|
|
66
80
|
* Scope to be used to resolve the steps dependencies
|
|
67
81
|
*/
|
|
68
82
|
scope?: A_Scope): Promise<void>;
|
|
69
|
-
process(
|
|
70
|
-
/**
|
|
71
|
-
* Extra parameters to control the steps processing
|
|
72
|
-
*/
|
|
73
|
-
params?: Partial<A_TYPES__A_StageStepProcessingExtraParams>): Promise<void>;
|
|
74
83
|
protected completed(): void;
|
|
75
84
|
protected failed(error: Error | A_Error | any): void;
|
|
76
85
|
/**
|
|
77
86
|
* Serializes the stage to JSON
|
|
78
87
|
*
|
|
79
88
|
*/
|
|
80
|
-
toJSON():
|
|
89
|
+
toJSON(): A_TYPES__Stage_Serialized;
|
|
81
90
|
/**
|
|
82
91
|
* Returns a string representation of the stage
|
|
83
92
|
*
|
|
@@ -13,43 +13,42 @@ exports.A_Stage = void 0;
|
|
|
13
13
|
const A_Stage_types_1 = require("./A-Stage.types");
|
|
14
14
|
const A_Context_class_1 = require("../A-Context/A-Context.class");
|
|
15
15
|
const A_Stage_error_1 = require("./A-Stage.error");
|
|
16
|
+
const A_Error_class_1 = require("../A-Error/A_Error.class");
|
|
16
17
|
const A_TypeGuards_helper_1 = require("../../helpers/A_TypeGuards.helper");
|
|
17
18
|
class A_Stage {
|
|
18
19
|
/**
|
|
19
|
-
* A_Stage is a
|
|
20
|
-
*
|
|
21
|
-
* [!] That always run in parallel (in NodeJS asynchronously), independently of each other.
|
|
20
|
+
* A_Stage is a callable A_Function within A_Feature that should be run with specific parameters.
|
|
21
|
+
* [!] Depending on the Stage Definition type sync/async function can be executed correspondingly.
|
|
22
22
|
*
|
|
23
23
|
* A-Stage is a common object that uses to simplify logic and re-use of A-Feature internals for better composition.
|
|
24
24
|
*/
|
|
25
|
-
constructor(
|
|
26
|
-
|
|
25
|
+
constructor(
|
|
26
|
+
/**
|
|
27
|
+
* The feature that owns this stage
|
|
28
|
+
*/
|
|
29
|
+
feature,
|
|
30
|
+
/**
|
|
31
|
+
* The step definitions of the stage
|
|
32
|
+
*/
|
|
33
|
+
step) {
|
|
34
|
+
/**
|
|
35
|
+
* Indicates the current status of the stage
|
|
36
|
+
*/
|
|
37
|
+
this._status = A_Stage_types_1.A_TYPES__A_Stage_Status.INITIALIZED;
|
|
27
38
|
this._feature = feature;
|
|
28
|
-
this.
|
|
39
|
+
this._definition = step;
|
|
29
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Returns the name of the stage
|
|
43
|
+
*/
|
|
30
44
|
get name() {
|
|
31
45
|
return this.toString();
|
|
32
46
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
get after() {
|
|
40
|
-
return this._steps.reduce((acc, step) => ([
|
|
41
|
-
...acc,
|
|
42
|
-
...step.after
|
|
43
|
-
]), []);
|
|
44
|
-
}
|
|
45
|
-
get steps() {
|
|
46
|
-
return this._steps;
|
|
47
|
-
}
|
|
48
|
-
get asyncSteps() {
|
|
49
|
-
return this._steps.filter(step => step.behavior === 'async');
|
|
50
|
-
}
|
|
51
|
-
get syncSteps() {
|
|
52
|
-
return this._steps.filter(step => step.behavior === 'sync');
|
|
47
|
+
/**
|
|
48
|
+
* Returns the current status of the stage
|
|
49
|
+
*/
|
|
50
|
+
get status() {
|
|
51
|
+
return this._status;
|
|
53
52
|
}
|
|
54
53
|
/**
|
|
55
54
|
* Resolves the arguments of the step
|
|
@@ -91,23 +90,13 @@ class A_Stage {
|
|
|
91
90
|
})));
|
|
92
91
|
});
|
|
93
92
|
}
|
|
94
|
-
/**
|
|
95
|
-
* Adds a step to the stage
|
|
96
|
-
*
|
|
97
|
-
* @param step
|
|
98
|
-
* @returns
|
|
99
|
-
*/
|
|
100
|
-
add(step) {
|
|
101
|
-
this._steps.push(step);
|
|
102
|
-
return this;
|
|
103
|
-
}
|
|
104
93
|
/**
|
|
105
94
|
* Resolves the component of the step
|
|
106
95
|
*
|
|
107
96
|
* @param step
|
|
108
97
|
* @returns
|
|
109
98
|
*/
|
|
110
|
-
|
|
99
|
+
getStepComponent(scope, step) {
|
|
111
100
|
const { component, handler } = step;
|
|
112
101
|
let instance;
|
|
113
102
|
switch (true) {
|
|
@@ -135,79 +124,69 @@ class A_Stage {
|
|
|
135
124
|
*/
|
|
136
125
|
callStepHandler(step, scope) {
|
|
137
126
|
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
-
|
|
127
|
+
// 1) Resolve component
|
|
128
|
+
const component = yield this.getStepComponent(scope, step);
|
|
129
|
+
// 2) Resolve arguments
|
|
139
130
|
const callArgs = yield this.getStepArgs(scope, step);
|
|
140
|
-
|
|
131
|
+
// 3) Call handler
|
|
132
|
+
return yield component[step.handler](...callArgs);
|
|
141
133
|
});
|
|
142
134
|
}
|
|
143
135
|
skip() {
|
|
144
|
-
this.
|
|
136
|
+
this._status = A_Stage_types_1.A_TYPES__A_Stage_Status.SKIPPED;
|
|
145
137
|
}
|
|
146
|
-
process(
|
|
147
138
|
/**
|
|
148
|
-
*
|
|
139
|
+
* This method processes the stage by executing all the steps
|
|
140
|
+
*
|
|
141
|
+
* @param scope - Scope to be used to resolve the steps dependencies
|
|
149
142
|
*/
|
|
150
|
-
|
|
143
|
+
process(
|
|
151
144
|
/**
|
|
152
|
-
*
|
|
145
|
+
* Scope to be used to resolve the steps dependencies
|
|
153
146
|
*/
|
|
154
|
-
|
|
147
|
+
scope) {
|
|
155
148
|
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
-
const
|
|
157
|
-
?
|
|
149
|
+
const targetScope = A_TypeGuards_helper_1.A_TypeGuards.isScopeInstance(scope)
|
|
150
|
+
? scope
|
|
158
151
|
: A_Context_class_1.A_Context.scope(this._feature);
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
: param1;
|
|
162
|
-
if (!this.processed)
|
|
163
|
-
this.processed = new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
152
|
+
if (!this._processed)
|
|
153
|
+
this._processed = new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
164
154
|
try {
|
|
165
|
-
this.
|
|
166
|
-
if (
|
|
167
|
-
|
|
155
|
+
this._status = A_Stage_types_1.A_TYPES__A_Stage_Status.PROCESSING;
|
|
156
|
+
if (this._definition.behavior === 'sync') {
|
|
157
|
+
// in case we have to wait for the result
|
|
158
|
+
yield this.callStepHandler(this._definition, targetScope);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
// in case we don't have to wait for the result
|
|
162
|
+
this.callStepHandler(this._definition, targetScope);
|
|
168
163
|
}
|
|
169
|
-
const syncSteps = this.syncSteps.filter((params === null || params === void 0 ? void 0 : params.filter) || (() => true));
|
|
170
|
-
const asyncSteps = this.asyncSteps.filter((params === null || params === void 0 ? void 0 : params.filter) || (() => true));
|
|
171
|
-
// Run sync _steps
|
|
172
|
-
yield Promise
|
|
173
|
-
.all([
|
|
174
|
-
// Run async _steps that are independent of each other
|
|
175
|
-
...asyncSteps.map(step => this.callStepHandler(step, scope)),
|
|
176
|
-
// Run sync _steps that are dependent on each other
|
|
177
|
-
new Promise((r, j) => __awaiter(this, void 0, void 0, function* () {
|
|
178
|
-
try {
|
|
179
|
-
for (const step of syncSteps) {
|
|
180
|
-
// console.log(' - -> Processing stage step:', step.handler, ' with Regexp: ', step.name);
|
|
181
|
-
yield this.callStepHandler(step, scope);
|
|
182
|
-
// console.log(' - -> Finished processing stage step:', step.handler);
|
|
183
|
-
}
|
|
184
|
-
return r();
|
|
185
|
-
}
|
|
186
|
-
catch (error) {
|
|
187
|
-
return j(error);
|
|
188
|
-
}
|
|
189
|
-
}))
|
|
190
|
-
]);
|
|
191
164
|
this.completed();
|
|
192
165
|
return resolve();
|
|
193
166
|
}
|
|
194
167
|
catch (error) {
|
|
195
|
-
|
|
196
|
-
|
|
168
|
+
const wrappedError = new A_Error_class_1.A_Error(error);
|
|
169
|
+
this.failed(wrappedError);
|
|
170
|
+
if (this._definition.throwOnError) {
|
|
171
|
+
return resolve();
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
return reject(wrappedError);
|
|
175
|
+
}
|
|
197
176
|
}
|
|
198
177
|
}));
|
|
199
|
-
return this.
|
|
178
|
+
return this._processed;
|
|
200
179
|
});
|
|
201
180
|
}
|
|
202
181
|
// ==========================================
|
|
203
182
|
// ============ Status methods =============
|
|
204
183
|
// ==========================================
|
|
205
184
|
completed() {
|
|
206
|
-
this.
|
|
185
|
+
this._status = A_Stage_types_1.A_TYPES__A_Stage_Status.COMPLETED;
|
|
207
186
|
}
|
|
208
187
|
failed(error) {
|
|
209
188
|
this._error = error;
|
|
210
|
-
this.
|
|
189
|
+
this._status = A_Stage_types_1.A_TYPES__A_Stage_Status.FAILED;
|
|
211
190
|
}
|
|
212
191
|
// ==========================================
|
|
213
192
|
// ============ Serialization ===============
|
|
@@ -228,22 +207,7 @@ class A_Stage {
|
|
|
228
207
|
* @returns
|
|
229
208
|
*/
|
|
230
209
|
toString() {
|
|
231
|
-
return
|
|
232
|
-
this._feature.name,
|
|
233
|
-
'::a-stage:',
|
|
234
|
-
'[sync:',
|
|
235
|
-
this
|
|
236
|
-
.syncSteps
|
|
237
|
-
.map(s => typeof s.component === 'string' ? s.component : s.component.name + '.' + s.handler)
|
|
238
|
-
.join(' -> '),
|
|
239
|
-
']',
|
|
240
|
-
'[async:',
|
|
241
|
-
this
|
|
242
|
-
.asyncSteps
|
|
243
|
-
.map(s => typeof s.component === 'string' ? s.component : s.component.name + '.' + s.handler)
|
|
244
|
-
.join(' -> '),
|
|
245
|
-
']'
|
|
246
|
-
].join('');
|
|
210
|
+
return `A-Stage(${this._feature.name}::${this._definition.behavior}@${this._definition.handler})`;
|
|
247
211
|
}
|
|
248
212
|
}
|
|
249
213
|
exports.A_Stage = A_Stage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"A-Stage.class.js","sourceRoot":"","sources":["../../../../src/global/A-Stage/A-Stage.class.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"A-Stage.class.js","sourceRoot":"","sources":["../../../../src/global/A-Stage/A-Stage.class.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAIyB;AACzB,kEAAyD;AAGzD,mDAA+C;AAC/C,4DAAmD;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CACJ;AA3QD,0BA2QC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { A_Container } from "../A-Container/A-Container.class";
|
|
2
2
|
import { A_TYPES__Component_Constructor } from "../A-Component/A-Component.types";
|
|
3
|
-
import { A_TYPES__FeatureExtendDecoratorBehaviorConfig } from "../A-Feature/A-Feature.types";
|
|
4
3
|
export declare enum A_TYPES__A_Stage_Status {
|
|
5
4
|
/**
|
|
6
5
|
* The stage is currently being processed
|
|
@@ -36,6 +35,7 @@ export declare enum A_TYPES__A_Stage_Status {
|
|
|
36
35
|
*/
|
|
37
36
|
ABORTED = "ABORTED"
|
|
38
37
|
}
|
|
38
|
+
export type A_TYPES_StageExecutionBehavior = 'async' | 'sync';
|
|
39
39
|
export type A_TYPES__A_StageStep = {
|
|
40
40
|
/**
|
|
41
41
|
* The component to be called
|
|
@@ -52,8 +52,35 @@ export type A_TYPES__A_StageStep = {
|
|
|
52
52
|
*
|
|
53
53
|
*/
|
|
54
54
|
name: string;
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
/**
|
|
56
|
+
* In case its async it will be executed independently from the main thread.
|
|
57
|
+
*
|
|
58
|
+
* [!] However, in case of sync, it will be executed in the main thread.in the order of the declaration.
|
|
59
|
+
*
|
|
60
|
+
*/
|
|
61
|
+
behavior: A_TYPES_StageExecutionBehavior;
|
|
62
|
+
/**
|
|
63
|
+
* Allows to define the order of the execution of the method.
|
|
64
|
+
*
|
|
65
|
+
* [!] In case the method has circular dependencies it will Throw an error.
|
|
66
|
+
*
|
|
67
|
+
*/
|
|
68
|
+
before: string[];
|
|
69
|
+
/**
|
|
70
|
+
* Allows to define the order of the execution of the method.
|
|
71
|
+
*
|
|
72
|
+
* [!] In case the method has circular dependencies it will Throw an error.
|
|
73
|
+
*
|
|
74
|
+
*/
|
|
75
|
+
after: string[];
|
|
76
|
+
/**
|
|
77
|
+
* Indicates whether to throw an error if the step fails.
|
|
78
|
+
*
|
|
79
|
+
* [!] By default is true
|
|
80
|
+
*/
|
|
81
|
+
throwOnError: boolean;
|
|
82
|
+
};
|
|
83
|
+
export type A_TYPES__Stage_Serialized = {
|
|
57
84
|
/**
|
|
58
85
|
* The name of the stage
|
|
59
86
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"A-Stage.types.js","sourceRoot":"","sources":["../../../../src/global/A-Stage/A-Stage.types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"A-Stage.types.js","sourceRoot":"","sources":["../../../../src/global/A-Stage/A-Stage.types.ts"],"names":[],"mappings":";;;AAKA,IAAY,uBAqCX;AArCD,WAAY,uBAAuB;IAC/B;;OAEG;IACH,oDAAyB,CAAA;IACzB;;OAEG;IACH,kDAAuB,CAAA;IACvB;;OAEG;IACH,4CAAiB,CAAA;IACjB;;OAEG;IACH,8CAAmB,CAAA;IACnB;;OAEG;IACH,qBAAqB;IACrB;;OAEG;IACH,uBAAuB;IACvB;;OAEG;IACH,uBAAuB;IACvB;;OAEG;IACH,sDAA2B,CAAA;IAC3B;;OAEG;IACH,8CAAmB,CAAA;AACvB,CAAC,EArCW,uBAAuB,uCAAvB,uBAAuB,QAqClC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { A_Feature } from "../A-Feature/A-Feature.class";
|
|
2
|
+
import { A_TYPES__FeatureDefineDecoratorTemplateItem } from "../A-Feature/A-Feature.types";
|
|
3
|
+
import { A_Stage } from "../A-Stage/A-Stage.class";
|
|
4
|
+
import { A_TYPES__A_StageStep } from "../A-Stage/A-Stage.types";
|
|
5
|
+
export declare class A_StepsManager {
|
|
6
|
+
entities: A_TYPES__A_StageStep[];
|
|
7
|
+
graph: Map<string, Set<string>>;
|
|
8
|
+
visited: Set<string>;
|
|
9
|
+
tempMark: Set<string>;
|
|
10
|
+
sortedEntities: string[];
|
|
11
|
+
private _isBuilt;
|
|
12
|
+
constructor(entities: Array<A_TYPES__FeatureDefineDecoratorTemplateItem>);
|
|
13
|
+
private prepareSteps;
|
|
14
|
+
private ID;
|
|
15
|
+
private buildGraph;
|
|
16
|
+
private matchEntities;
|
|
17
|
+
private visit;
|
|
18
|
+
toSortedArray(): Array<string>;
|
|
19
|
+
toStages(feature: A_Feature): Array<A_Stage>;
|
|
20
|
+
}
|