@adaas/a-concept 0.1.22 → 0.1.24
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/src/global/A-Abstraction/A-Abstraction-Extend.decorator.js +16 -9
- package/dist/src/global/A-Abstraction/A-Abstraction-Extend.decorator.js.map +1 -1
- package/dist/src/global/A-Component/A-Component.meta.js +3 -2
- package/dist/src/global/A-Component/A-Component.meta.js.map +1 -1
- package/dist/src/global/A-Container/A-Container.meta.js +4 -11
- package/dist/src/global/A-Container/A-Container.meta.js.map +1 -1
- package/dist/src/global/A-Entity/A-Entity.class.js +2 -1
- package/dist/src/global/A-Entity/A-Entity.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 +21 -12
- package/dist/src/global/A-Feature/A-Feature-Extend.decorator.js.map +1 -1
- package/dist/src/global/A-Feature/A-Feature.class.js +1 -1
- package/dist/src/global/A-Feature/A-Feature.class.js.map +1 -1
- package/dist/src/global/A-Feature/A-Feature.types.d.ts +30 -6
- package/dist/src/global/A-Feature/A-Feature.types.js.map +1 -1
- package/dist/src/global/A-Stage/A-Stage.class.d.ts +16 -0
- package/dist/src/global/A-Stage/A-Stage.class.js +28 -2
- package/dist/src/global/A-Stage/A-Stage.class.js.map +1 -1
- package/dist/src/global/A-Stage/A-Stage.types.d.ts +6 -2
- package/dist/src/global/A-StepManager/A-StepManager.class.js +11 -10
- package/dist/src/global/A-StepManager/A-StepManager.class.js.map +1 -1
- package/package.json +2 -4
- package/src/global/A-Abstraction/A-Abstraction-Extend.decorator.ts +16 -12
- package/src/global/A-Component/A-Component.meta.ts +3 -2
- package/src/global/A-Container/A-Container.meta.ts +5 -8
- package/src/global/A-Entity/A-Entity.class.ts +2 -1
- package/src/global/A-Feature/A-Feature-Define.decorator.ts +5 -3
- package/src/global/A-Feature/A-Feature-Extend.decorator.ts +21 -16
- package/src/global/A-Feature/A-Feature.class.ts +1 -1
- package/src/global/A-Feature/A-Feature.types.ts +33 -8
- package/src/global/A-Stage/A-Stage.class.ts +29 -4
- package/src/global/A-Stage/A-Stage.types.ts +7 -2
- package/src/global/A-StepManager/A-StepManager.class.ts +19 -13
- package/tests/A-Concept.test.ts +53 -4
- package/tests/A-Feature.test.ts +4 -4
- package/tests/A-StepManager.test.ts +60 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"A-StepManager.class.js","sourceRoot":"","sources":["../../../../src/global/A-StepManager/A-StepManager.class.ts"],"names":[],"mappings":";;;AAEA,4DAAmD;AAEnD,+DAA2D;AAE3D,MAAa,cAAc;IAWvB,YAAY,QAA4D;QAFhE,aAAQ,GAAY,KAAK,CAAC;QAG9B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAE5C,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;IAE7B,CAAC;IAEO,YAAY,CAChB,QAA4D;QAE5D,OAAO,QAAQ,
|
|
1
|
+
{"version":3,"file":"A-StepManager.class.js","sourceRoot":"","sources":["../../../../src/global/A-StepManager/A-StepManager.class.ts"],"names":[],"mappings":";;;AAEA,4DAAmD;AAEnD,+DAA2D;AAE3D,MAAa,cAAc;IAWvB,YAAY,QAA4D;QAFhE,aAAQ,GAAY,KAAK,CAAC;QAG9B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAE5C,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,IAAI,GA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IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAE/B,iEAAiE;YACjE,4DAA4D;YAC5D,gCAAgC;YAChC,wDAAwD;YACxD,wDAAwD;YACxD,iCAAiC;YACjC,SAAS;YAET,uDAAuD;YACvD,8BAA8B;YAC9B,0BAA0B;YAC1B,kCAAkC;QACtC,CAAC;IACL,CAAC;IAGD,aAAa;QACT,IAAI,CAAC,UAAU,EAAE,CAAC;QAElB,yBAAyB;QACzB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YAC3B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;gBAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QACxE,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED,0CAA0C;IAC1C,QAAQ,CAAC,OAAkB;QAGvB,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QAGzC,0CAA0C;QAC1C,OAAO,WAAW;aACb,GAAG,CAAC,EAAE,CAAC,EAAE;YACN,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,CAAE,CAAC;YAGnE,OAAO,IAAI,uBAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;IACX,CAAC;CACJ;AA1JD,wCA0JC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaas/a-concept",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.24",
|
|
4
4
|
"description": "A-Concept is a framework to build new Applications within or outside the ADAAS ecosystem. This framework is designed to be modular structure regardless environment and program goal.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -50,13 +50,11 @@
|
|
|
50
50
|
"url": "https://github.com/ADAAS-org/adaas-adf-auth/issues"
|
|
51
51
|
},
|
|
52
52
|
"homepage": "https://github.com/ADAAS-org/adaas-adf-auth#readme",
|
|
53
|
-
"dependencies": {
|
|
54
|
-
"@types/node": "^20.10.0"
|
|
55
|
-
},
|
|
56
53
|
"devDependencies": {
|
|
57
54
|
"@types/chai": "^4.3.14",
|
|
58
55
|
"@types/jest": "^29.5.12",
|
|
59
56
|
"@types/mocha": "^10.0.6",
|
|
57
|
+
"@types/node": "^24.9.1",
|
|
60
58
|
"chai": "^5.1.0",
|
|
61
59
|
"dotenv": "^16.4.5",
|
|
62
60
|
"jest": "^29.7.0",
|
|
@@ -91,18 +91,22 @@ export function A_Abstraction_Extend(
|
|
|
91
91
|
behavior: config.behavior || 'sync',
|
|
92
92
|
throwOnError: config.throwOnError !== undefined ? config.throwOnError : true,
|
|
93
93
|
|
|
94
|
-
before: (config.before
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
94
|
+
before: A_TypeGuards.isArray(config.before)
|
|
95
|
+
? new RegExp(`^${config.before.join('|').replace(/\./g, '\\.')}$`).source
|
|
96
|
+
: config.before instanceof RegExp
|
|
97
|
+
? config.before.source
|
|
98
|
+
: '',
|
|
99
|
+
after: A_TypeGuards.isArray(config.after)
|
|
100
|
+
? new RegExp(`^${config.after.join('|').replace(/\./g, '\\.')}$`).source
|
|
101
|
+
: config.after instanceof RegExp
|
|
102
|
+
? config.after.source
|
|
103
|
+
: '',
|
|
104
|
+
|
|
105
|
+
override: A_TypeGuards.isArray(config.override)
|
|
106
|
+
? new RegExp(`^${config.override.join('|').replace(/\./g, '\\.')}$`).source
|
|
107
|
+
: config.after instanceof RegExp
|
|
108
|
+
? config.after.source
|
|
109
|
+
: '',
|
|
106
110
|
}
|
|
107
111
|
|
|
108
112
|
if (existedIndex !== -1) {
|
|
@@ -47,9 +47,10 @@ export class A_ComponentMeta extends A_Meta<A_TYPES__ComponentMeta> {
|
|
|
47
47
|
name: extension.name,
|
|
48
48
|
handler: extension.handler,
|
|
49
49
|
behavior: extension.behavior,
|
|
50
|
-
before: extension.before ||
|
|
51
|
-
after: extension.after ||
|
|
50
|
+
before: extension.before || '',
|
|
51
|
+
after: extension.after || '',
|
|
52
52
|
throwOnError: extension.throwOnError || true,
|
|
53
|
+
override:''
|
|
53
54
|
});
|
|
54
55
|
|
|
55
56
|
});
|
|
@@ -64,13 +64,8 @@ export class A_ContainerMeta extends A_Meta<A_TYPES__ContainerMeta> {
|
|
|
64
64
|
const args = injections?.get(extension.handler) || [];
|
|
65
65
|
|
|
66
66
|
steps.push({
|
|
67
|
-
|
|
68
|
-
handler: extension.handler,
|
|
67
|
+
...extension,
|
|
69
68
|
args,
|
|
70
|
-
before: extension.before,
|
|
71
|
-
behavior: extension.behavior,
|
|
72
|
-
after: extension.after,
|
|
73
|
-
throwOnError: extension.throwOnError,
|
|
74
69
|
});
|
|
75
70
|
|
|
76
71
|
});
|
|
@@ -104,9 +99,11 @@ export class A_ContainerMeta extends A_Meta<A_TYPES__ContainerMeta> {
|
|
|
104
99
|
name: extension.name,
|
|
105
100
|
handler: extension.handler,
|
|
106
101
|
behavior: extension.behavior,
|
|
107
|
-
before: extension.before ||
|
|
108
|
-
after: extension.after ||
|
|
102
|
+
before: extension.before || '',
|
|
103
|
+
after: extension.after || '',
|
|
109
104
|
throwOnError: extension.throwOnError || true,
|
|
105
|
+
override: ''
|
|
106
|
+
|
|
110
107
|
});
|
|
111
108
|
|
|
112
109
|
});
|
|
@@ -87,10 +87,12 @@ export function A_Feature_Define(
|
|
|
87
87
|
template: config.template && config.template.length ? config.template.map(
|
|
88
88
|
item => ({
|
|
89
89
|
...item,
|
|
90
|
-
before: item.before ||
|
|
91
|
-
after: item.after ||
|
|
90
|
+
before: item.before || '',
|
|
91
|
+
after: item.after || '',
|
|
92
92
|
behavior: item.behavior || 'sync',
|
|
93
|
-
throwOnError: true
|
|
93
|
+
throwOnError: true,
|
|
94
|
+
override: item.override || ''
|
|
95
|
+
|
|
94
96
|
})
|
|
95
97
|
) : [],
|
|
96
98
|
});
|
|
@@ -74,8 +74,9 @@ export function A_Feature_Extend(
|
|
|
74
74
|
|
|
75
75
|
let targetRegexp: RegExp;
|
|
76
76
|
let behavior: 'sync' | 'async' = 'sync';
|
|
77
|
-
let before: string
|
|
78
|
-
let after: string
|
|
77
|
+
let before: string = '';
|
|
78
|
+
let after: string = '';
|
|
79
|
+
let override: string = '';
|
|
79
80
|
let include: Array<A_TYPES__FeatureExtendDecoratorScopeItem> = [];
|
|
80
81
|
let exclude: Array<A_TYPES__FeatureExtendDecoratorScopeItem> = [];
|
|
81
82
|
let throwOnError: boolean = true;
|
|
@@ -104,19 +105,22 @@ export function A_Feature_Extend(
|
|
|
104
105
|
behavior = param1.behavior || behavior;
|
|
105
106
|
throwOnError = param1.throwOnError !== undefined ? param1.throwOnError : throwOnError;
|
|
106
107
|
|
|
107
|
-
before = param1.before
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
108
|
+
before = A_TypeGuards.isArray(param1.before)
|
|
109
|
+
? new RegExp(`^${param1.before.join('|').replace(/\./g, '\\.')}$`).source
|
|
110
|
+
: param1.before instanceof RegExp
|
|
111
|
+
? param1.before.source
|
|
112
|
+
: ''
|
|
113
|
+
after = A_TypeGuards.isArray(param1.after)
|
|
114
|
+
? new RegExp(`^${param1.after.join('|').replace(/\./g, '\\.')}$`).source
|
|
115
|
+
: param1.after instanceof RegExp
|
|
116
|
+
? param1.after.source
|
|
117
|
+
: ''
|
|
118
|
+
|
|
119
|
+
override = A_TypeGuards.isArray(param1.override)
|
|
120
|
+
? new RegExp(`^${param1.override.join('|').replace(/\./g, '\\.')}$`).source
|
|
121
|
+
: param1.override instanceof RegExp
|
|
122
|
+
? param1.override.source
|
|
123
|
+
: ''
|
|
120
124
|
break;
|
|
121
125
|
|
|
122
126
|
default:
|
|
@@ -161,7 +165,8 @@ export function A_Feature_Extend(
|
|
|
161
165
|
behavior,
|
|
162
166
|
before,
|
|
163
167
|
after,
|
|
164
|
-
throwOnError
|
|
168
|
+
throwOnError,
|
|
169
|
+
override
|
|
165
170
|
}
|
|
166
171
|
|
|
167
172
|
if (existedIndex !== -1) {
|
|
@@ -285,7 +285,7 @@ export class A_Feature<T extends A_TYPES__FeatureAvailableComponents = A_TYPES__
|
|
|
285
285
|
this._name = params.name;
|
|
286
286
|
|
|
287
287
|
// 2) get scope from where feature is called
|
|
288
|
-
const componentScope = A_Context.scope(params.component);
|
|
288
|
+
const componentScope = params.scope ? params.scope : A_Context.scope(params.component);
|
|
289
289
|
|
|
290
290
|
// 3) create caller wrapper for the simple injection of the caller component
|
|
291
291
|
this._caller = new A_Caller<T>(params.component);
|
|
@@ -38,6 +38,13 @@ export type A_TYPES__Feature_InitWithComponent<T extends A_TYPES__FeatureAvailab
|
|
|
38
38
|
* [!] Could be Container, Entity, Component or Command
|
|
39
39
|
*/
|
|
40
40
|
component: T,
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* In case when Entity is not attached to the scope can be used to transparently show dependencies
|
|
44
|
+
*
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
47
|
+
scope?: A_Scope
|
|
41
48
|
}
|
|
42
49
|
/**
|
|
43
50
|
* Feature initialization type using template
|
|
@@ -259,11 +266,16 @@ export type A_TYPES__FeatureExtendDecoratorConfig = {
|
|
|
259
266
|
* ```ts
|
|
260
267
|
* @A_Feature.Extend({
|
|
261
268
|
* name: 'load',
|
|
262
|
-
* before: ['Component1.methodName',
|
|
269
|
+
* before: ['Component1.methodName', 'Component2.methodName2']
|
|
270
|
+
* })
|
|
271
|
+
* // OR
|
|
272
|
+
* @A_Feature.Extend({
|
|
273
|
+
* name: 'load',
|
|
274
|
+
* before: /Component2\..+/
|
|
263
275
|
* })
|
|
264
276
|
* ```
|
|
265
277
|
*/
|
|
266
|
-
before: Array<string | RegExp
|
|
278
|
+
before: Array<string> | RegExp
|
|
267
279
|
|
|
268
280
|
/**
|
|
269
281
|
* Allows to define the order of the execution of the method.
|
|
@@ -275,19 +287,28 @@ export type A_TYPES__FeatureExtendDecoratorConfig = {
|
|
|
275
287
|
* ```ts
|
|
276
288
|
* @A_Feature.Extend({
|
|
277
289
|
* name: 'load',
|
|
278
|
-
*
|
|
290
|
+
* after: ['Component1.methodName', 'Component2.methodName2']
|
|
291
|
+
* })
|
|
292
|
+
* // OR
|
|
293
|
+
* @A_Feature.Extend({
|
|
294
|
+
* name: 'load',
|
|
295
|
+
* after: /Component2\..+/
|
|
279
296
|
* })
|
|
280
297
|
* ```
|
|
281
298
|
*
|
|
282
299
|
*/
|
|
283
|
-
after: Array<string | RegExp
|
|
284
|
-
|
|
300
|
+
after: Array<string> | RegExp
|
|
285
301
|
/**
|
|
286
302
|
* Indicates whether to throw an error if the step fails.
|
|
287
303
|
*
|
|
288
304
|
* [!] By default is true
|
|
289
305
|
*/
|
|
290
306
|
throwOnError: boolean
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Allows to override particular steps in the feature sequence by provided names [Component].[Method] or by regexp
|
|
310
|
+
*/
|
|
311
|
+
override: Array<string> | RegExp
|
|
291
312
|
}
|
|
292
313
|
/**
|
|
293
314
|
* Scope item that can be used in A_Extend decorator configuration
|
|
@@ -342,20 +363,24 @@ export type A_TYPES__FeatureExtendDecoratorMeta = {
|
|
|
342
363
|
* [!] In case the method has circular dependencies it will Throw an error.
|
|
343
364
|
*
|
|
344
365
|
*/
|
|
345
|
-
before: string
|
|
366
|
+
before: string
|
|
346
367
|
/**
|
|
347
368
|
* Allows to define the order of the execution of the method.
|
|
348
369
|
*
|
|
349
370
|
* [!] In case the method has circular dependencies it will Throw an error.
|
|
350
371
|
*
|
|
351
372
|
*/
|
|
352
|
-
after: string
|
|
373
|
+
after: string
|
|
353
374
|
/**
|
|
354
375
|
* Indicates whether to throw an error if the step fails.
|
|
355
376
|
*
|
|
356
377
|
* [!] By default is true
|
|
357
378
|
*/
|
|
358
|
-
throwOnError: boolean
|
|
379
|
+
throwOnError: boolean,
|
|
380
|
+
/**
|
|
381
|
+
* Allows to override particular steps in the feature sequence by provided names [Component].[Method] or by regexp
|
|
382
|
+
*/
|
|
383
|
+
override: string
|
|
359
384
|
}
|
|
360
385
|
|
|
361
386
|
|
|
@@ -28,7 +28,7 @@ export class A_Stage {
|
|
|
28
28
|
/**
|
|
29
29
|
* Possible errors during stage processing
|
|
30
30
|
*/
|
|
31
|
-
private _error?:
|
|
31
|
+
private _error?: A_Error;
|
|
32
32
|
/**
|
|
33
33
|
* Indicates the current status of the stage
|
|
34
34
|
*/
|
|
@@ -66,13 +66,38 @@ export class A_Stage {
|
|
|
66
66
|
get name(): string {
|
|
67
67
|
return this.toString();
|
|
68
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Returns the definition of the stage
|
|
71
|
+
*/
|
|
72
|
+
get definition(): A_TYPES__A_StageStep {
|
|
73
|
+
return this._definition;
|
|
74
|
+
}
|
|
69
75
|
/**
|
|
70
76
|
* Returns the current status of the stage
|
|
71
77
|
*/
|
|
72
78
|
get status(): A_TYPES__A_Stage_Status {
|
|
73
79
|
return this._status;
|
|
74
80
|
}
|
|
75
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Returns the feature that owns this stage
|
|
83
|
+
*/
|
|
84
|
+
get feature(): A_Feature {
|
|
85
|
+
return this._feature;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Returns true if the stage is processed (completed, failed, or skipped)
|
|
89
|
+
*/
|
|
90
|
+
get isProcessed(): boolean {
|
|
91
|
+
return this._status === A_TYPES__A_Stage_Status.COMPLETED
|
|
92
|
+
|| this._status === A_TYPES__A_Stage_Status.FAILED
|
|
93
|
+
|| this._status === A_TYPES__A_Stage_Status.SKIPPED;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Returns the error of the stage
|
|
97
|
+
*/
|
|
98
|
+
get error(): A_Error | undefined {
|
|
99
|
+
return this._error;
|
|
100
|
+
}
|
|
76
101
|
|
|
77
102
|
/**
|
|
78
103
|
* Resolves the arguments of the step
|
|
@@ -205,7 +230,7 @@ export class A_Stage {
|
|
|
205
230
|
|
|
206
231
|
const targetScope = A_TypeGuards.isScopeInstance(scope)
|
|
207
232
|
? scope
|
|
208
|
-
:
|
|
233
|
+
: this._feature.scope;
|
|
209
234
|
|
|
210
235
|
if (!this._processed)
|
|
211
236
|
this._processed = new Promise<void>(
|
|
@@ -253,7 +278,7 @@ export class A_Stage {
|
|
|
253
278
|
protected failed(
|
|
254
279
|
error: Error | A_Error | any
|
|
255
280
|
) {
|
|
256
|
-
this._error = error;
|
|
281
|
+
this._error = new A_Error(error);
|
|
257
282
|
|
|
258
283
|
this._status = A_TYPES__A_Stage_Status.FAILED;
|
|
259
284
|
}
|
|
@@ -76,7 +76,7 @@ export type A_TYPES__A_StageStep = {
|
|
|
76
76
|
* [!] In case the method has circular dependencies it will Throw an error.
|
|
77
77
|
*
|
|
78
78
|
*/
|
|
79
|
-
before: string
|
|
79
|
+
before: string
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
82
|
* Allows to define the order of the execution of the method.
|
|
@@ -84,7 +84,7 @@ export type A_TYPES__A_StageStep = {
|
|
|
84
84
|
* [!] In case the method has circular dependencies it will Throw an error.
|
|
85
85
|
*
|
|
86
86
|
*/
|
|
87
|
-
after: string
|
|
87
|
+
after: string,
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
90
|
* Indicates whether to throw an error if the step fails.
|
|
@@ -92,6 +92,11 @@ export type A_TYPES__A_StageStep = {
|
|
|
92
92
|
* [!] By default is true
|
|
93
93
|
*/
|
|
94
94
|
throwOnError: boolean
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
*
|
|
98
|
+
*/
|
|
99
|
+
override: string
|
|
95
100
|
}
|
|
96
101
|
|
|
97
102
|
|
|
@@ -28,16 +28,16 @@ export class A_StepsManager {
|
|
|
28
28
|
private prepareSteps(
|
|
29
29
|
entities: Array<A_TYPES__FeatureDefineDecoratorTemplateItem>
|
|
30
30
|
): Array<A_TYPES__A_StageStep> {
|
|
31
|
-
return entities
|
|
32
|
-
|
|
31
|
+
return entities
|
|
32
|
+
.map(step => ({
|
|
33
33
|
...step,
|
|
34
34
|
|
|
35
35
|
behavior: step.behavior || 'sync',
|
|
36
|
-
before: step.before ||
|
|
37
|
-
after: step.after ||
|
|
36
|
+
before: step.before || '',
|
|
37
|
+
after: step.after || '',
|
|
38
|
+
override: step.override || '',
|
|
38
39
|
throwOnError: false
|
|
39
|
-
};
|
|
40
|
-
});
|
|
40
|
+
}));
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
private ID(step: A_TYPES__A_StageStep) {
|
|
@@ -47,36 +47,42 @@ export class A_StepsManager {
|
|
|
47
47
|
private buildGraph() {
|
|
48
48
|
if (this._isBuilt) return;
|
|
49
49
|
this._isBuilt = true;
|
|
50
|
+
|
|
51
|
+
// Filter override
|
|
52
|
+
this.entities = this.entities
|
|
53
|
+
.filter((step, i, self) =>
|
|
54
|
+
!self.some(s => s.override ? new RegExp(s.override).test(this.ID(step)) : false)
|
|
55
|
+
);
|
|
56
|
+
|
|
50
57
|
// Initialize graph nodes
|
|
51
58
|
this.entities.forEach(entity => this.graph.set(this.ID(entity), new Set()));
|
|
52
59
|
|
|
53
60
|
// Add directed edges based on 'before' and 'after'
|
|
54
61
|
this.entities.forEach(entity => {
|
|
55
62
|
const entityId = this.ID(entity);
|
|
56
|
-
const { before = [], after = [] } = entity;
|
|
57
63
|
|
|
58
64
|
// Add edges for 'before' dependencies
|
|
59
65
|
// If entity should execute before targets, then targets depend on entity
|
|
60
66
|
// So we add edges: target -> entity (target depends on entity)
|
|
61
|
-
before
|
|
62
|
-
const targets = this.matchEntities(entityId,
|
|
67
|
+
if (entity.before) {
|
|
68
|
+
const targets = this.matchEntities(entityId, entity.before);
|
|
63
69
|
targets.forEach(target => {
|
|
64
70
|
if (!this.graph.has(target)) this.graph.set(target, new Set());
|
|
65
71
|
this.graph.get(target)!.add(entityId); // target depends on entity
|
|
66
72
|
});
|
|
67
|
-
}
|
|
73
|
+
}
|
|
68
74
|
|
|
69
75
|
// Add edges for 'after' dependencies
|
|
70
76
|
// If entity should execute after sources, then entity depends on sources
|
|
71
77
|
// So we add edges: entity -> source (entity depends on source)
|
|
72
|
-
after
|
|
73
|
-
const sources = this.matchEntities(entityId,
|
|
78
|
+
if (entity.after) {
|
|
79
|
+
const sources = this.matchEntities(entityId, entity.after);
|
|
74
80
|
|
|
75
81
|
sources.forEach(source => {
|
|
76
82
|
if (!this.graph.has(entityId)) this.graph.set(entityId, new Set());
|
|
77
83
|
this.graph.get(entityId)!.add(source); // entity depends on source
|
|
78
84
|
});
|
|
79
|
-
}
|
|
85
|
+
}
|
|
80
86
|
});
|
|
81
87
|
}
|
|
82
88
|
|
package/tests/A-Concept.test.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
import { A_Caller } from '@adaas/a-concept/global/A-Caller/A_Caller.class';
|
|
1
2
|
import './test.setup';
|
|
2
3
|
import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class";
|
|
3
4
|
import { A_Concept } from "@adaas/a-concept/global/A-Concept/A-Concept.class";
|
|
4
5
|
import { A_Container } from "@adaas/a-concept/global/A-Container/A-Container.class";
|
|
5
6
|
import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
|
|
6
7
|
import { A_Entity } from "@adaas/a-concept/global/A-Entity/A-Entity.class";
|
|
8
|
+
import { A_TYPES__Entity_Init, A_TYPES__Entity_Serialized } from '@adaas/a-concept/global/A-Entity/A-Entity.types';
|
|
7
9
|
import { A_Fragment } from "@adaas/a-concept/global/A-Fragment/A-Fragment.class";
|
|
10
|
+
import { A_Inject } from '@adaas/a-concept/global/A-Inject/A-Inject.decorator';
|
|
8
11
|
import { A_Scope } from "@adaas/a-concept/global/A-Scope/A-Scope.class";
|
|
12
|
+
import { A_Feature } from '@adaas/a-concept/global/A-Feature/A-Feature.class';
|
|
13
|
+
import { A_TYPES__EntityFeatures } from '@adaas/a-concept/global/A-Entity/A-Entity.constants';
|
|
9
14
|
|
|
10
15
|
|
|
11
16
|
jest.retryTimes(0);
|
|
@@ -105,7 +110,7 @@ describe('A-Concept tests', () => {
|
|
|
105
110
|
expect(concept.scope.resolve(MyContext)).toEqual(sharedContext);
|
|
106
111
|
expect(concept.scope.resolve(MyContext)).toEqual(sharedContext);
|
|
107
112
|
});
|
|
108
|
-
|
|
113
|
+
it('Should allow to register multiple containers', async () => {
|
|
109
114
|
A_Context.reset();
|
|
110
115
|
|
|
111
116
|
class MyContainerA extends A_Container { }
|
|
@@ -123,9 +128,53 @@ describe('A-Concept tests', () => {
|
|
|
123
128
|
});
|
|
124
129
|
|
|
125
130
|
expect(containerA.scope.resolve(MyContainerA)).toBeInstanceOf(MyContainerA);
|
|
126
|
-
expect(containerB.scope.resolve(MyContainerB)).toBeInstanceOf(MyContainerB);
|
|
131
|
+
expect(containerB.scope.resolve(MyContainerB)).toBeInstanceOf(MyContainerB);
|
|
132
|
+
})
|
|
133
|
+
it('Should have different entity behavior depending on the container', async () => {
|
|
134
|
+
A_Context.reset();
|
|
135
|
+
class MyEntityA extends A_Entity { testValue!: string; }
|
|
136
|
+
|
|
137
|
+
class ComponentA extends A_Component {
|
|
138
|
+
@A_Feature.Extend({ name: A_TYPES__EntityFeatures.LOAD })
|
|
139
|
+
async createEntityInstance(
|
|
140
|
+
@A_Inject(A_Caller) caller: MyEntityA
|
|
141
|
+
) {
|
|
142
|
+
caller.testValue = 'ContainerA';
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
class ComponentB extends A_Component {
|
|
147
|
+
@A_Feature.Extend({ name: A_TYPES__EntityFeatures.LOAD })
|
|
148
|
+
async createEntityInstance(
|
|
149
|
+
@A_Inject(A_Caller) caller: MyEntityA
|
|
150
|
+
) {
|
|
151
|
+
caller.testValue = 'ContainerB';
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const containerA = new A_Container({ name: 'ContainerA', components: [ComponentA], entities: [MyEntityA] });
|
|
156
|
+
const containerB = new A_Container({ name: 'ContainerB', components: [ComponentB], entities: [MyEntityA] });
|
|
157
|
+
|
|
158
|
+
const concept = new A_Concept({
|
|
159
|
+
name: 'TestConcept',
|
|
160
|
+
containers: [
|
|
161
|
+
containerA,
|
|
162
|
+
containerB
|
|
163
|
+
]
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
const entityFromContainerA = new MyEntityA();
|
|
167
|
+
const entityFromContainerB = new MyEntityA();
|
|
168
|
+
|
|
169
|
+
// with registration
|
|
170
|
+
containerB.scope.register(entityFromContainerB)
|
|
171
|
+
await entityFromContainerB.load();
|
|
172
|
+
|
|
173
|
+
// without registration
|
|
174
|
+
await entityFromContainerA.load(containerA.scope);
|
|
127
175
|
|
|
128
|
-
|
|
129
|
-
|
|
176
|
+
expect(entityFromContainerA.testValue).toBe('ContainerA');
|
|
177
|
+
expect(entityFromContainerB.testValue).toBe('ContainerB');
|
|
178
|
+
})
|
|
130
179
|
|
|
131
180
|
});
|
package/tests/A-Feature.test.ts
CHANGED
|
@@ -63,8 +63,8 @@ describe('A-Feature tests', () => {
|
|
|
63
63
|
component: MyExtendedComponent,
|
|
64
64
|
handler: 'testHandler',
|
|
65
65
|
behavior: 'sync',
|
|
66
|
-
before:
|
|
67
|
-
after:
|
|
66
|
+
before: '',
|
|
67
|
+
after: ''
|
|
68
68
|
},
|
|
69
69
|
{
|
|
70
70
|
name: 'MyExtendedComponent.testHandler',
|
|
@@ -115,8 +115,8 @@ describe('A-Feature tests', () => {
|
|
|
115
115
|
component: 'MyExtendedComponent2',
|
|
116
116
|
handler: 'testHandler',
|
|
117
117
|
behavior: 'sync',
|
|
118
|
-
before:
|
|
119
|
-
after:
|
|
118
|
+
before: '',
|
|
119
|
+
after: ''
|
|
120
120
|
}]
|
|
121
121
|
})
|
|
122
122
|
async testHandler() { }
|