@adaas/a-concept 0.1.18 → 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.
Files changed (52) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.js +5 -2
  3. package/dist/index.js.map +1 -1
  4. package/dist/src/global/A-Abstraction/A-Abstraction-Extend.decorator.js +11 -4
  5. package/dist/src/global/A-Abstraction/A-Abstraction-Extend.decorator.js.map +1 -1
  6. package/dist/src/global/A-Component/A-Component.meta.js +2 -1
  7. package/dist/src/global/A-Component/A-Component.meta.js.map +1 -1
  8. package/dist/src/global/A-Component/A-Component.types.d.ts +2 -11
  9. package/dist/src/global/A-Concept/A-Concept.types.d.ts +4 -21
  10. package/dist/src/global/A-Container/A-Container.meta.js +4 -2
  11. package/dist/src/global/A-Container/A-Container.meta.js.map +1 -1
  12. package/dist/src/global/A-Container/A-Container.types.d.ts +2 -11
  13. package/dist/src/global/A-Feature/A-Feature-Define.decorator.js +1 -1
  14. package/dist/src/global/A-Feature/A-Feature-Define.decorator.js.map +1 -1
  15. package/dist/src/global/A-Feature/A-Feature-Extend.decorator.js +14 -5
  16. package/dist/src/global/A-Feature/A-Feature-Extend.decorator.js.map +1 -1
  17. package/dist/src/global/A-Feature/A-Feature.class.d.ts +2 -1
  18. package/dist/src/global/A-Feature/A-Feature.class.js +7 -3
  19. package/dist/src/global/A-Feature/A-Feature.class.js.map +1 -1
  20. package/dist/src/global/A-Feature/A-Feature.types.d.ts +69 -27
  21. package/dist/src/global/A-Stage/A-Stage.class.d.ts +37 -28
  22. package/dist/src/global/A-Stage/A-Stage.class.js +62 -98
  23. package/dist/src/global/A-Stage/A-Stage.class.js.map +1 -1
  24. package/dist/src/global/A-Stage/A-Stage.types.d.ts +30 -3
  25. package/dist/src/global/A-Stage/A-Stage.types.js.map +1 -1
  26. package/dist/src/global/A-StepManager/A-StepManager.class.d.ts +20 -0
  27. package/dist/src/{helpers/A_StepsManager.class.js → global/A-StepManager/A-StepManager.class.js} +38 -64
  28. package/dist/src/global/A-StepManager/A-StepManager.class.js.map +1 -0
  29. package/dist/src/global/A-StepManager/A-StepManager.error.d.ts +4 -0
  30. package/dist/src/global/A-StepManager/A-StepManager.error.js +9 -0
  31. package/dist/src/global/A-StepManager/A-StepManager.error.js.map +1 -0
  32. package/index.ts +2 -1
  33. package/package.json +3 -3
  34. package/src/global/A-Abstraction/A-Abstraction-Extend.decorator.ts +18 -6
  35. package/src/global/A-Component/A-Component.meta.ts +2 -1
  36. package/src/global/A-Component/A-Component.types.ts +2 -11
  37. package/src/global/A-Concept/A-Concept.types.ts +4 -21
  38. package/src/global/A-Container/A-Container.meta.ts +4 -2
  39. package/src/global/A-Container/A-Container.types.ts +2 -11
  40. package/src/global/A-Feature/A-Feature-Define.decorator.ts +1 -0
  41. package/src/global/A-Feature/A-Feature-Extend.decorator.ts +21 -7
  42. package/src/global/A-Feature/A-Feature.class.ts +8 -1
  43. package/src/global/A-Feature/A-Feature.types.ts +80 -33
  44. package/src/global/A-Stage/A-Stage.class.ts +71 -143
  45. package/src/global/A-Stage/A-Stage.types.ts +34 -3
  46. package/src/{helpers/A_StepsManager.class.ts → global/A-StepManager/A-StepManager.class.ts} +53 -87
  47. package/src/global/A-StepManager/A-StepManager.error.ts +10 -0
  48. package/tests/A-Abstraction.test.ts +273 -255
  49. package/tests/A-Feature.test.ts +270 -271
  50. package/tests/A-StepManager.test.ts +346 -0
  51. package/dist/src/helpers/A_StepsManager.class.d.ts +0 -35
  52. package/dist/src/helpers/A_StepsManager.class.js.map +0 -1
@@ -4,198 +4,201 @@ import { A_Concept } from '@adaas/a-concept/global/A-Concept/A-Concept.class';
4
4
  import { A_Container } from '@adaas/a-concept/global/A-Container/A-Container.class';
5
5
  import { A_Context } from '@adaas/a-concept/global/A-Context/A-Context.class';
6
6
  import { A_Scope } from '@adaas/a-concept/global/A-Scope/A-Scope.class';
7
+ import { A_TYPES__ConceptAbstractions } from '@adaas/a-concept/global/A-Concept/A-Concept.constants';
8
+ import { A_Inject } from '@adaas/a-concept/global/A-Inject/A-Inject.decorator';
9
+ import { A_Feature } from '@adaas/a-concept/global/A-Feature/A-Feature.class';
7
10
 
8
11
  jest.retryTimes(0);
9
12
 
10
13
  describe('A-Abstraction Tests', () => {
11
- it('It should be possible to extend abstraction on A-Component level', async () => {
12
- class MyComponent extends A_Component {
13
- private _test: number = 0
14
+ // it('It should be possible to extend abstraction on A-Component level', async () => {
15
+ // class MyComponent extends A_Component {
16
+ // private _test: number = 0
17
+
18
+ // @A_Concept.Load()
19
+ // myMethod() {
20
+ // this._test++;
21
+ // }
22
+ // }
23
+ // });
24
+
25
+ // it('It should be possible to extend abstraction on A-Container level', async () => {
26
+ // class MyContainer extends A_Container {
27
+ // private _test: number = 0
28
+
29
+ // @A_Concept.Load()
30
+ // myMethod() {
31
+ // this._test++;
32
+ // }
33
+ // }
34
+ // });
35
+
36
+
37
+ // it('It should be possible to proceed Concept Abstraction', async () => {
38
+ // class MyComponent extends A_Component {
39
+ // _test2: number = 0
40
+
41
+ // @A_Concept.Load()
42
+ // myMethod() {
43
+ // this._test2++;
44
+ // }
45
+ // }
46
+
47
+ // class MyContainer extends A_Container {
48
+ // _test: number = 0
49
+
50
+ // @A_Concept.Load()
51
+ // myMethod() {
52
+ // this._test++;
53
+ // }
54
+ // }
55
+
56
+ // const myContainer = new MyContainer({
57
+ // name: 'MyContainer',
58
+ // components: [MyComponent]
59
+ // });
60
+
61
+ // const testConcept = new A_Concept({
62
+ // name: 'TestConcept',
63
+ // containers: [myContainer]
64
+ // });
65
+
66
+ // await testConcept.load();
67
+
68
+
69
+ // const resolvedComponent = myContainer.scope.resolve(MyComponent);
70
+
71
+ // expect(resolvedComponent).toBeInstanceOf(MyComponent);
72
+ // expect(myContainer._test).toBe(1);
73
+ // expect(resolvedComponent._test2).toBe(1);
74
+
75
+ // });
76
+ // it('Should allow to extend abstraction with multiple containers', async () => {
77
+ // A_Context.reset();
78
+
79
+ // class MyContainerA extends A_Container {
80
+ // _test: number = 0
81
+
82
+ // @A_Concept.Load()
83
+ // myMethod() {
84
+ // this._test++;
85
+ // }
86
+ // }
87
+ // class MyContainerB extends A_Container {
88
+ // _test: number = 0
89
+
90
+ // @A_Concept.Load()
91
+ // myMethod() {
92
+ // this._test++;
93
+ // }
94
+ // }
95
+
96
+ // const containerA = new MyContainerA({ name: 'ContainerA' });
97
+ // const containerB = new MyContainerB({ name: 'ContainerB' });
98
+
99
+ // const concept = new A_Concept({
100
+ // name: 'TestConcept',
101
+ // containers: [
102
+ // containerA,
103
+ // containerB
104
+ // ]
105
+ // });
106
+
107
+ // await concept.load();
108
+
109
+ // expect(containerA.scope.resolve(MyContainerA)).toBeInstanceOf(MyContainerA);
110
+ // expect(containerB.scope.resolve(MyContainerB)).toBeInstanceOf(MyContainerB);
111
+
112
+ // expect(containerA._test).toBe(1);
113
+ // expect(containerB._test).toBe(1);
114
+
115
+ // })
116
+ // it('Should allow to define an async abstraction extension', async () => {
117
+ // A_Context.reset();
118
+
119
+ // class MyContainerA extends A_Container {
120
+ // _test: number = 0
121
+
122
+ // @A_Concept.Load()
123
+ // async myMethod() {
124
+ // this._test = 5;
125
+ // }
126
+ // }
127
+ // class MyContainerB extends A_Container {
128
+ // _test: number = 0
129
+
130
+ // @A_Concept.Load()
131
+ // myMethod() {
132
+ // this._test++;
133
+ // }
134
+ // }
14
135
 
15
- @A_Concept.Load()
16
- myMethod() {
17
- this._test++;
18
- }
19
- }
20
- });
21
-
22
- it('It should be possible to extend abstraction on A-Container level', async () => {
23
- class MyContainer extends A_Container {
24
- private _test: number = 0
25
-
26
- @A_Concept.Load()
27
- myMethod() {
28
- this._test++;
29
- }
30
- }
31
- });
32
-
33
-
34
- it('It should be possible to proceed Concept Abstraction', async () => {
35
- class MyComponent extends A_Component {
36
- _test2: number = 0
37
-
38
- @A_Concept.Load()
39
- myMethod() {
40
- this._test2++;
41
- }
42
- }
43
-
44
- class MyContainer extends A_Container {
45
- _test: number = 0
46
-
47
- @A_Concept.Load()
48
- myMethod() {
49
- this._test++;
50
- }
51
- }
52
-
53
- const myContainer = new MyContainer({
54
- name: 'MyContainer',
55
- components: [MyComponent]
56
- });
57
-
58
- const testConcept = new A_Concept({
59
- name: 'TestConcept',
60
- containers: [myContainer]
61
- });
62
-
63
- await testConcept.load();
64
-
65
-
66
- const resolvedComponent = myContainer.scope.resolve(MyComponent);
67
-
68
- expect(resolvedComponent).toBeInstanceOf(MyComponent);
69
- expect(myContainer._test).toBe(1);
70
- expect(resolvedComponent._test2).toBe(1);
71
-
72
- });
73
- it('Should allow to extend abstraction with multiple containers', async () => {
74
- A_Context.reset();
75
-
76
- class MyContainerA extends A_Container {
77
- _test: number = 0
78
-
79
- @A_Concept.Load()
80
- myMethod() {
81
- this._test++;
82
- }
83
- }
84
- class MyContainerB extends A_Container {
85
- _test: number = 0
86
-
87
- @A_Concept.Load()
88
- myMethod() {
89
- this._test++;
90
- }
91
- }
92
-
93
- const containerA = new MyContainerA({ name: 'ContainerA' });
94
- const containerB = new MyContainerB({ name: 'ContainerB' });
95
-
96
- const concept = new A_Concept({
97
- name: 'TestConcept',
98
- containers: [
99
- containerA,
100
- containerB
101
- ]
102
- });
103
-
104
- await concept.load();
105
-
106
- expect(containerA.scope.resolve(MyContainerA)).toBeInstanceOf(MyContainerA);
107
- expect(containerB.scope.resolve(MyContainerB)).toBeInstanceOf(MyContainerB);
108
-
109
- expect(containerA._test).toBe(1);
110
- expect(containerB._test).toBe(1);
111
-
112
- })
113
- it('Should allow to define an async abstraction extension', async () => {
114
- A_Context.reset();
115
-
116
- class MyContainerA extends A_Container {
117
- _test: number = 0
118
-
119
- @A_Concept.Load()
120
- async myMethod() {
121
- this._test = 5;
122
- }
123
- }
124
- class MyContainerB extends A_Container {
125
- _test: number = 0
126
-
127
- @A_Concept.Load()
128
- myMethod() {
129
- this._test++;
130
- }
131
- }
132
-
133
-
134
- const containerA = new MyContainerA({ name: 'ContainerA' });
135
- const containerB = new MyContainerB({ name: 'ContainerB' });
136
-
137
- const concept = new A_Concept({
138
- name: 'TestConcept',
139
- containers: [
140
- containerA,
141
- containerB
142
- ]
143
- });
144
-
145
- await concept.load();
146
-
147
- expect(containerA.scope.resolve(MyContainerA)).toBeInstanceOf(MyContainerA);
148
- expect(containerB.scope.resolve(MyContainerB)).toBeInstanceOf(MyContainerB);
149
-
150
- expect(containerA._test).toBe(5);
151
- expect(containerB._test).toBe(1);
152
- })
153
- it('Should execute abstraction in a proper order', async () => {
154
- A_Context.reset();
155
-
156
- const order: string[] = [];
157
-
158
- class MyContainerA extends A_Container {
159
-
160
- @A_Concept.Load()
161
- async step1() {
162
- order.push('step1');
163
- }
164
-
165
- @A_Concept.Load()
166
- async step2() {
167
- order.push('step2');
168
- }
169
- }
170
- class MyContainerB extends A_Container {
171
-
172
- @A_Concept.Load()
173
- async step3() {
174
- order.push('step3');
175
- }
176
-
177
- @A_Concept.Load()
178
- async step4() {
179
- order.push('step4');
180
- }
181
- }
182
136
 
137
+ // const containerA = new MyContainerA({ name: 'ContainerA' });
138
+ // const containerB = new MyContainerB({ name: 'ContainerB' });
139
+
140
+ // const concept = new A_Concept({
141
+ // name: 'TestConcept',
142
+ // containers: [
143
+ // containerA,
144
+ // containerB
145
+ // ]
146
+ // });
147
+
148
+ // await concept.load();
149
+
150
+ // expect(containerA.scope.resolve(MyContainerA)).toBeInstanceOf(MyContainerA);
151
+ // expect(containerB.scope.resolve(MyContainerB)).toBeInstanceOf(MyContainerB);
152
+
153
+ // expect(containerA._test).toBe(5);
154
+ // expect(containerB._test).toBe(1);
155
+ // })
156
+ // it('Should execute abstraction in a proper order', async () => {
157
+ // A_Context.reset();
158
+
159
+ // const order: string[] = [];
160
+
161
+ // class MyContainerA extends A_Container {
162
+
163
+ // @A_Concept.Load()
164
+ // async step1() {
165
+ // order.push('step1');
166
+ // }
183
167
 
184
- const containerA = new MyContainerA({ name: 'ContainerA' });
185
- const containerB = new MyContainerB({ name: 'ContainerB' });
186
-
187
- const concept = new A_Concept({
188
- name: 'TestConcept',
189
- containers: [
190
- containerA,
191
- containerB
192
- ]
193
- });
194
-
195
- await concept.load();
196
-
197
- expect(order).toEqual(['step1', 'step2', 'step3', 'step4']);
198
- })
168
+ // @A_Concept.Load()
169
+ // async step2() {
170
+ // order.push('step2');
171
+ // }
172
+ // }
173
+ // class MyContainerB extends A_Container {
174
+
175
+ // @A_Concept.Load()
176
+ // async step3() {
177
+ // order.push('step3');
178
+ // }
179
+
180
+ // @A_Concept.Load()
181
+ // async step4() {
182
+ // order.push('step4');
183
+ // }
184
+ // }
185
+
186
+
187
+ // const containerA = new MyContainerA({ name: 'ContainerA' });
188
+ // const containerB = new MyContainerB({ name: 'ContainerB' });
189
+
190
+ // const concept = new A_Concept({
191
+ // name: 'TestConcept',
192
+ // containers: [
193
+ // containerA,
194
+ // containerB
195
+ // ]
196
+ // });
197
+
198
+ // await concept.load();
199
+
200
+ // expect(order).toEqual(['step1', 'step2', 'step3', 'step4']);
201
+ // })
199
202
  it('Should execute abstraction in order with dependencies', async () => {
200
203
  A_Context.reset();
201
204
 
@@ -204,14 +207,20 @@ describe('A-Abstraction Tests', () => {
204
207
  class MyContainerA extends A_Container {
205
208
 
206
209
  @A_Concept.Load()
207
- async step1() {
210
+ async step1(
211
+ @A_Inject(A_Feature) feature: A_Feature,
212
+ ) {
213
+ // console.log(`Executing step1 in stage: ${feature.stage?.name}`);
208
214
  order.push('step1');
209
215
  }
210
216
 
211
217
  @A_Concept.Load({
212
218
  after: ['MyComponentA.step3']
213
219
  })
214
- async step2() {
220
+ async step2(
221
+ @A_Inject(A_Feature) feature: A_Feature,
222
+ ) {
223
+ // console.log(`Executing step2 in stage: ${feature.stage?.name}`);
215
224
  order.push('step2');
216
225
  }
217
226
  }
@@ -219,7 +228,10 @@ describe('A-Abstraction Tests', () => {
219
228
  class MyComponentA extends A_Component {
220
229
 
221
230
  @A_Concept.Load()
222
- async step3() {
231
+ async step3(
232
+ @A_Inject(A_Feature) feature: A_Feature,
233
+ ) {
234
+ // console.log(`Executing step3 in stage: ${feature.stage?.name}`);
223
235
  order.push('step3');
224
236
  }
225
237
  }
@@ -228,14 +240,20 @@ describe('A-Abstraction Tests', () => {
228
240
  class MyContainerB extends A_Container {
229
241
 
230
242
  @A_Concept.Load()
231
- async step4() {
243
+ async step4(
244
+ @A_Inject(A_Feature) feature: A_Feature,
245
+ ) {
246
+ // console.log(`Executing step4 in stage: ${feature.stage?.name}`);
232
247
  order.push('step4');
233
248
  }
234
249
 
235
250
  @A_Concept.Load({
236
251
  before: ['MyContainerB.step4']
237
252
  })
238
- async step5() {
253
+ async step5(
254
+ @A_Inject(A_Feature) feature: A_Feature,
255
+ ) {
256
+ // console.log(`Executing step5 in stage: ${feature.stage?.name}`);
239
257
  order.push('step5');
240
258
  }
241
259
  }
@@ -256,69 +274,69 @@ describe('A-Abstraction Tests', () => {
256
274
 
257
275
  expect(order).toEqual(['step1', 'step3', 'step2', 'step5', 'step4']);
258
276
  })
259
- it('Should inherit abstraction extensions', async () => {
260
- const executionOrder: string[] = [];
261
-
262
- // 1) create a base component with some abstraction
263
- class My_Component extends A_Component {
264
-
265
- @A_Concept.Load()
266
- async feature1() {
267
- executionOrder.push('stepOne');
268
- }
269
- }
270
-
271
-
272
- class My_Child_Component extends My_Component { }
273
-
274
- const concept = new A_Concept({
275
- name: 'TestConcept',
276
- containers: [
277
- new A_Container({
278
- name: 'TestContainer',
279
- components: [My_Child_Component],
280
- })
281
- ]
282
- });
283
-
284
- await concept.load();
285
-
286
- expect(executionOrder).toEqual(['stepOne']);
287
- });
288
- it('Should allow to override abstraction extensions', async () => {
289
- const executionOrder: string[] = [];
290
-
291
- // 1) create a base component with some abstraction
292
- class My_Component extends A_Component {
293
-
294
- @A_Concept.Load()
295
- async feature1() {
296
- executionOrder.push('stepOne');
297
- }
298
- }
299
-
300
-
301
- class My_Child_Component extends My_Component {
302
- @A_Concept.Load()
303
- async feature1() {
304
- // do nothing
305
- executionOrder.push('stepTwo');
306
-
307
- }
308
- }
309
-
310
- const concept = new A_Concept({
311
- name: 'TestConcept',
312
- containers: [
313
- new A_Container({
314
- name: 'TestContainer',
315
- components: [My_Child_Component],
316
- })
317
- ]
318
- });
319
-
320
- await concept.load();
321
-
322
- expect(executionOrder).toEqual(['stepTwo']);
323
- });
277
+ // it('Should inherit abstraction extensions', async () => {
278
+ // const executionOrder: string[] = [];
279
+
280
+ // // 1) create a base component with some abstraction
281
+ // class My_Component extends A_Component {
282
+
283
+ // @A_Concept.Load()
284
+ // async feature1() {
285
+ // executionOrder.push('stepOne');
286
+ // }
287
+ // }
288
+
289
+
290
+ // class My_Child_Component extends My_Component { }
291
+
292
+ // const concept = new A_Concept({
293
+ // name: 'TestConcept',
294
+ // containers: [
295
+ // new A_Container({
296
+ // name: 'TestContainer',
297
+ // components: [My_Child_Component],
298
+ // })
299
+ // ]
300
+ // });
301
+
302
+ // await concept.load();
303
+
304
+ // expect(executionOrder).toEqual(['stepOne']);
305
+ // });
306
+ // it('Should allow to override abstraction extensions', async () => {
307
+ // const executionOrder: string[] = [];
308
+
309
+ // // 1) create a base component with some abstraction
310
+ // class My_Component extends A_Component {
311
+
312
+ // @A_Concept.Load()
313
+ // async feature1() {
314
+ // executionOrder.push('stepOne');
315
+ // }
316
+ // }
317
+
318
+
319
+ // class My_Child_Component extends My_Component {
320
+ // @A_Concept.Load()
321
+ // async feature1() {
322
+ // // do nothing
323
+ // executionOrder.push('stepTwo');
324
+
325
+ // }
326
+ // }
327
+
328
+ // const concept = new A_Concept({
329
+ // name: 'TestConcept',
330
+ // containers: [
331
+ // new A_Container({
332
+ // name: 'TestContainer',
333
+ // components: [My_Child_Component],
334
+ // })
335
+ // ]
336
+ // });
337
+
338
+ // await concept.load();
339
+
340
+ // expect(executionOrder).toEqual(['stepTwo']);
341
+ // });
324
342
  });