@adaas/a-concept 0.1.12 → 0.1.13

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.
@@ -46,11 +46,11 @@ config = {}) {
46
46
  metaKey = A_Component_constants_1.A_TYPES__ComponentMetaKey.ABSTRACTIONS;
47
47
  break;
48
48
  }
49
+ const setName = `CONCEPT_ABSTRACTION::${name}`;
49
50
  // Get the existed metadata or create a new one
50
51
  const existedMeta = meta.get(metaKey) || new A_Meta_class_1.A_Meta();
51
52
  // Set the metadata of the method to define a custom Stage with name
52
- const existedMetaValue = existedMeta.get(name) || [];
53
- const setName = `CONCEPT_ABSTRACTION::${name}`;
53
+ const existedMetaValue = existedMeta.get(setName) || [];
54
54
  // Add the new method to the metadata
55
55
  existedMetaValue.push({
56
56
  name: setName,
@@ -1 +1 @@
1
- {"version":3,"file":"A-Abstraction-Extend.decorator.js","sourceRoot":"","sources":["../../../../src/global/A-Abstraction/A-Abstraction-Extend.decorator.ts"],"names":[],"mappings":";;AA2BA,oDA4EC;AAlGD,uFAA8E;AAI9E,8EAAqE;AAErE,qGAAsG;AACtG,qGAAsG;AAEtG,+DAA2D;AAC3D,sFAA4E;AAG5E;;;;;;;;GAQG;AACH,SAAgB,oBAAoB;AAChC;;GAEG;AACH,IAAkC;AAClC;;;GAGG;AACH,SAAuD,EAAE;IAEzD,OAAO,UACH,MAAiC,EACjC,WAAmB,EACnB,UAAmD;;QAEnD,qBAAqB;QACrB,MAAM,aAAa,GAAG,CAAA,MAAC,MAAc,aAAd,MAAM,uBAAN,MAAM,CAAU,WAAW,0CAAE,IAAI,KAAI,MAAM,CAAC,MAAM,CAAC,IAAI,kBAAkB,CAAC;QAEjG,IAAI,CAAC,IAAI;YACL,MAAM,IAAI,wCAAkB,CACxB,wCAAkB,CAAC,yBAAyB,EAC5C,gEAAgE,aAAa,IAAI,CACpF,CAAC;QAEN,kEAAkE;QAClE,IAAI,CAAC,kCAAY,CAAC,oCAAoC,CA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C,MAAM,CAAC;aACZ,GAAG,CACA,OAAO,EACP,WAAW,CACd,CAAC;IACV,CAAC,CAAC;AACN,CAAC"}
1
+ {"version":3,"file":"A-Abstraction-Extend.decorator.js","sourceRoot":"","sources":["../../../../src/global/A-Abstraction/A-Abstraction-Extend.decorator.ts"],"names":[],"mappings":";;AA2BA,oDA2EC;AAjGD,uFAA8E;AAI9E,8EAAqE;AAErE,qGAAsG;AACtG,qGAAsG;AAEtG,+DAA2D;AAC3D,sFAA4E;AAG5E;;;;;;;;GAQG;AACH,SAAgB,oBAAoB;AAChC;;GAEG;AACH,IAAkC;AAClC;;;GAGG;AACH,SAAuD,EAAE;IAEzD,OAAO,UACH,MAAiC,EACjC,WAAmB,EACnB,UAAmD;;QAEnD,qBAAqB;QACrB,MAAM,aAAa,GAAG,CAAA,MAAC,MAAc,aAAd,MAAM,uBAAN,MAAM,CAAU,WAAW,0CAAE,IAAI,KAAI,MAAM,CAAC,MAAM,CAAC,IAAI,kBAAkB,CAAC;QAEjG,IAAI,CAAC,IAAI;YACL,MAAM,IAAI,wCAAkB,CACxB,wCAAkB,CAAC,yBAAyB,EAC5C,gEAAgE,aAAa,IAAI,CACpF,CAAC;QAEN,kEAAkE;QAClE,IAAI,CAAC,kCAAY,CAAC,oCAAoC,CAAC,MAAM,CAAC,EAAE,CAAC;YAC7D,MAAM,IAAI,wCAAkB,CACxB,wCAAkB,CAAC,yBAAyB,EAC5C,iCAAiC,IAAI,UAAU,aAAa,gEAAgE,CAC/H,CAAC;QACN,CAAC;QAED,IAAI,OAAO,CAAC;QACZ,MAAM,IAAI,GAAsC,2BAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAEvE,QAAQ,IAAI,EAAE,CAAC;YACX,KAAK,kCAAY,CAAC,sBAAsB,CAAC,MAAM,CAAC,IAAI,kCAAY,CAAC,mBAAmB,CAAC,MAAM,CAAC;gBACxF,OAAO,GAAG,iDAAyB,CAAC,YAAY,CAAA;gBAChD,MAAM;YACV,KAAK,kCAAY,CAAC,sBAAsB,CAAC,MAAM,CAAC,IAAI,kCAAY,CAAC,mBAAmB,CAAC,MAAM,CAAC;gBACxF,OAAO,GAAG,iDAAyB,CAAC,YAAY,CAAA;gBAChD,MAAM;QACd,CAAC;QACD,MAAM,OAAO,GAAG,wBAAwB,IAAI,EAAE,CAAC;QAE/C,+CAA+C;QAC/C,MAAM,WAAW,GAEZ,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,qBAAM,EAAE,CAAC;QAEvC,oEAAoE;QACpE,MAAM,gBAAgB,GAAG,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAExD,qCAAqC;QACrC,gBAAgB,CAAC,IAAI,CAAC;YAClB,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,WAAW;YACpB,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,EAAE;YAC3B,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,EAAE;YACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,MAAM;SACtC,CAAC,CAAC;QAEH,sEAAsE;QACtE,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;QAG3C,sEAAsE;QACtE,2BAAS;aACJ,IAAI,CAAC,MAAM,CAAC;aACZ,GAAG,CACA,OAAO,EACP,WAAW,CACd,CAAC;IACV,CAAC,CAAC;AACN,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaas/a-concept",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
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",
@@ -69,6 +69,7 @@ export function A_Abstraction_Extend(
69
69
  metaKey = A_TYPES__ComponentMetaKey.ABSTRACTIONS
70
70
  break;
71
71
  }
72
+ const setName = `CONCEPT_ABSTRACTION::${name}`;
72
73
 
73
74
  // Get the existed metadata or create a new one
74
75
  const existedMeta: A_Meta<{
@@ -76,9 +77,7 @@ export function A_Abstraction_Extend(
76
77
  }> = meta.get(metaKey) || new A_Meta();
77
78
 
78
79
  // Set the metadata of the method to define a custom Stage with name
79
- const existedMetaValue = existedMeta.get(name) || [];
80
-
81
- const setName = `CONCEPT_ABSTRACTION::${name}`;
80
+ const existedMetaValue = existedMeta.get(setName) || [];
82
81
 
83
82
  // Add the new method to the metadata
84
83
  existedMetaValue.push({
@@ -3,7 +3,6 @@ import './test.setup'
3
3
  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
- import { A_ScopeError } from '@adaas/a-concept/global/A-Scope/A-Scope.error';
7
6
 
8
7
  jest.retryTimes(0);
9
8
 
@@ -150,5 +149,110 @@ describe('A-Abstraction Tests', () => {
150
149
  expect(containerA._test).toBe(5);
151
150
  expect(containerB._test).toBe(1);
152
151
  })
153
-
152
+ it('Should execute abstraction in a proper order', async () => {
153
+ A_Context.reset();
154
+
155
+ const order: string[] = [];
156
+
157
+ class MyContainerA extends A_Container {
158
+
159
+ @A_Concept.Load()
160
+ async step1() {
161
+ order.push('step1');
162
+ }
163
+
164
+ @A_Concept.Load()
165
+ async step2() {
166
+ order.push('step2');
167
+ }
168
+ }
169
+ class MyContainerB extends A_Container {
170
+
171
+ @A_Concept.Load()
172
+ async step3() {
173
+ order.push('step3');
174
+ }
175
+
176
+ @A_Concept.Load()
177
+ async step4() {
178
+ order.push('step4');
179
+ }
180
+ }
181
+
182
+
183
+ const containerA = new MyContainerA({ name: 'ContainerA' });
184
+ const containerB = new MyContainerB({ name: 'ContainerB' });
185
+
186
+ const concept = new A_Concept({
187
+ name: 'TestConcept',
188
+ containers: [
189
+ containerA,
190
+ containerB
191
+ ]
192
+ });
193
+
194
+ await concept.load();
195
+
196
+ expect(order).toEqual(['step1', 'step2', 'step3', 'step4']);
197
+ })
198
+ it('Should execute abstraction in order with dependencies', async () => {
199
+ A_Context.reset();
200
+
201
+ const order: string[] = [];
202
+
203
+ class MyContainerA extends A_Container {
204
+
205
+ @A_Concept.Load()
206
+ async step1() {
207
+ order.push('step1');
208
+ }
209
+
210
+ @A_Concept.Load({
211
+ after: ['MyComponentA.step3']
212
+ })
213
+ async step2() {
214
+ order.push('step2');
215
+ }
216
+ }
217
+
218
+ class MyComponentA extends A_Component {
219
+
220
+ @A_Concept.Load()
221
+ async step3() {
222
+ order.push('step3');
223
+ }
224
+ }
225
+
226
+
227
+ class MyContainerB extends A_Container {
228
+
229
+ @A_Concept.Load()
230
+ async step4() {
231
+ order.push('step4');
232
+ }
233
+
234
+ @A_Concept.Load({
235
+ before: ['MyContainerB.step4']
236
+ })
237
+ async step5() {
238
+ order.push('step5');
239
+ }
240
+ }
241
+
242
+
243
+ const containerA = new MyContainerA({ name: 'ContainerA', components: [MyComponentA] });
244
+ const containerB = new MyContainerB({ name: 'ContainerB' });
245
+
246
+ const concept = new A_Concept({
247
+ name: 'TestConcept',
248
+ containers: [
249
+ containerA,
250
+ containerB
251
+ ]
252
+ });
253
+
254
+ await concept.load();
255
+
256
+ expect(order).toEqual(['step1', 'step3', 'step2', 'step5', 'step4']);
257
+ })
154
258
  });