@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
@@ -1,53 +1,67 @@
1
- import { A_TYPES__A_Stage_JSON, A_TYPES__A_Stage_Status, A_TYPES__A_StageStep, A_TYPES__A_StageStepProcessingExtraParams } from "./A-Stage.types";
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
- private readonly _steps;
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
- * A_Stage is a set of A_Functions within A_Feature that should be run in a specific order.
13
- * Each stage may contain one or more functions.
14
- * [!] That always run in parallel (in NodeJS asynchronously), independently of each other.
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(feature: A_Feature, steps?: A_TYPES__A_StageStep[]);
19
- status: A_TYPES__A_Stage_Status;
34
+ constructor(
20
35
  /**
21
- * Promise that will be resolved when the stage is Processed
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
- * Resolves the arguments of the step
32
- *
33
- * @param step
34
- * @returns
48
+ * Returns the current status of the stage
35
49
  */
36
- 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[])[]>;
50
+ get status(): A_TYPES__A_Stage_Status;
37
51
  /**
38
- * Adds a step to the stage
52
+ * Resolves the arguments of the step
39
53
  *
40
54
  * @param step
41
55
  * @returns
42
56
  */
43
- add(step: A_TYPES__A_StageStep): this;
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 getStepInstance(scope: A_Scope, step: A_TYPES__A_StageStep): A_TYPES__ScopeResolvableComponents;
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(): A_TYPES__A_Stage_JSON;
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 set of A_Functions within A_Feature that should be run in a specific order.
20
- * Each stage may contain one or more functions.
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(feature, steps = []) {
26
- this.status = A_Stage_types_1.A_TYPES__A_Stage_Status.INITIALIZED;
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._steps = steps;
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
- get before() {
34
- return this._steps.reduce((acc, step) => ([
35
- ...acc,
36
- ...step.before
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
- getStepInstance(scope, step) {
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
- const instance = yield this.getStepInstance(scope, step);
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
- return yield instance[step.handler](...callArgs);
131
+ // 3) Call handler
132
+ return yield component[step.handler](...callArgs);
141
133
  });
142
134
  }
143
135
  skip() {
144
- this.status = A_Stage_types_1.A_TYPES__A_Stage_Status.SKIPPED;
136
+ this._status = A_Stage_types_1.A_TYPES__A_Stage_Status.SKIPPED;
145
137
  }
146
- process(
147
138
  /**
148
- * Scope to be used to resolve the steps dependencies
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
- param1,
143
+ process(
151
144
  /**
152
- * Extra parameters to control the steps processing
145
+ * Scope to be used to resolve the steps dependencies
153
146
  */
154
- param2) {
147
+ scope) {
155
148
  return __awaiter(this, void 0, void 0, function* () {
156
- const scope = A_TypeGuards_helper_1.A_TypeGuards.isScopeInstance(param1)
157
- ? param1
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
- const params = A_TypeGuards_helper_1.A_TypeGuards.isScopeInstance(param1)
160
- ? param2
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.status = A_Stage_types_1.A_TYPES__A_Stage_Status.PROCESSING;
166
- if ((params === null || params === void 0 ? void 0 : params.steps) && params.steps.length) {
167
- params.steps.forEach(step => this.add(step));
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
- this.failed(error);
196
- return reject(error);
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.processed;
178
+ return this._processed;
200
179
  });
201
180
  }
202
181
  // ==========================================
203
182
  // ============ Status methods =============
204
183
  // ==========================================
205
184
  completed() {
206
- this.status = A_Stage_types_1.A_TYPES__A_Stage_Status.COMPLETED;
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.status = A_Stage_types_1.A_TYPES__A_Stage_Status.FAILED;
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":";;;;;;;;;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AC;wBAED,IAAI,CAAC,SAAS,EAAE,CAAC;wBAEjB,OAAO,OAAO,EAAE,CAAC;oBACrB,CAAC;oBAAC,OAAO,KAAK,EAAE,CAAC;wBACb,MAAM,YAAY,GAAG,IAAI,uBAAO,CAAC,KAAY,CAAC,CAAC;wBAE/C,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;wBAG1B,IAAI,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC;4BAChC,OAAO,OAAO,EAAE,CAAC;wBACrB,CAAC;6BAAM,CAAC;4BACJ,OAAO,MAAM,CAAC,YAAY,CAAC,CAAC;wBAChC,CAAC;oBACL,CAAC;gBACL,CAAC,CAAA,CAAC,CAAC;YAEX,OAAO,IAAI,CAAC,UAAU,CAAC;QAC3B,CAAC;KAAA;IAGD,6CAA6C;IAC7C,4CAA4C;IAC5C,6CAA6C;IAEnC,SAAS;QACf,IAAI,CAAC,OAAO,GAAG,uCAAuB,CAAC,SAAS,CAAC;IACrD,CAAC;IAES,MAAM,CACZ,KAA4B;QAE5B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QAEpB,IAAI,CAAC,OAAO,GAAG,uCAAuB,CAAC,MAAM,CAAC;IAClD,CAAC;IAID,6CAA6C;IAC7C,6CAA6C;IAC7C,6CAA6C;IAC7C;;;OAGG;IACH,MAAM;QACF,OAAO;YACH,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM,EAAE,IAAI,CAAC,MAAM;SACtB,CAAA;IACL,CAAC;IAED;;;;OAIG;IACH,QAAQ;QACJ,OAAO,WAAW,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAC,WAAW,CAAC,QAAQ,IAAI,IAAI,CAAC,WAAW,CAAC,OAAO,GAAG,CAAC;IACtG,CAAC;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
- } & A_TYPES__FeatureExtendDecoratorBehaviorConfig;
56
- export type A_TYPES__A_Stage_JSON = {
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":";;;AAMA,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"}
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
+ }
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.A_TmpStage = exports.A_StepsManager = void 0;
4
- const A_Error_class_1 = require("../global/A-Error/A_Error.class");
5
- const A_Stage_class_1 = require("../global/A-Stage/A-Stage.class");
3
+ exports.A_StepsManager = void 0;
4
+ const A_Stage_class_1 = require("../A-Stage/A-Stage.class");
5
+ const A_StepManager_error_1 = require("./A-StepManager.error");
6
6
  class A_StepsManager {
7
7
  constructor(entities) {
8
+ this._isBuilt = false;
8
9
  this.entities = this.prepareSteps(entities);
9
10
  this.graph = new Map();
10
11
  this.visited = new Set();
@@ -13,13 +14,16 @@ class A_StepsManager {
13
14
  }
14
15
  prepareSteps(entities) {
15
16
  return entities.map(step => {
16
- return Object.assign(Object.assign({}, step), { behavior: step.behavior || 'sync', before: step.before || [], after: step.after || [] });
17
+ return Object.assign(Object.assign({}, step), { behavior: step.behavior || 'sync', before: step.before || [], after: step.after || [], throwOnError: false });
17
18
  });
18
19
  }
19
20
  ID(step) {
20
21
  return `${typeof step.component === 'string' ? step.component : step.component.name}.${step.handler}`;
21
22
  }
22
23
  buildGraph() {
24
+ if (this._isBuilt)
25
+ return;
26
+ this._isBuilt = true;
23
27
  // Initialize graph nodes
24
28
  this.entities.forEach(entity => this.graph.set(this.ID(entity), new Set()));
25
29
  // Add directed edges based on 'before' and 'after'
@@ -30,7 +34,7 @@ class A_StepsManager {
30
34
  // If entity should execute before targets, then targets depend on entity
31
35
  // So we add edges: target -> entity (target depends on entity)
32
36
  before.forEach(dep => {
33
- const targets = this.matchEntities(dep);
37
+ const targets = this.matchEntities(entityId, dep);
34
38
  targets.forEach(target => {
35
39
  if (!this.graph.has(target))
36
40
  this.graph.set(target, new Set());
@@ -41,7 +45,7 @@ class A_StepsManager {
41
45
  // If entity should execute after sources, then entity depends on sources
42
46
  // So we add edges: entity -> source (entity depends on source)
43
47
  after.forEach(dep => {
44
- const sources = this.matchEntities(dep);
48
+ const sources = this.matchEntities(entityId, dep);
45
49
  sources.forEach(source => {
46
50
  if (!this.graph.has(entityId))
47
51
  this.graph.set(entityId, new Set());
@@ -51,87 +55,57 @@ class A_StepsManager {
51
55
  });
52
56
  }
53
57
  // Match entities by name or regex
54
- matchEntities(pattern) {
55
- const regex = new RegExp(`^${pattern}$`);
58
+ matchEntities(entityId, pattern) {
59
+ const regex = new RegExp(pattern);
56
60
  return this.entities
57
- .filter(entity => regex.test(this.ID(entity)))
61
+ .filter(entity => regex.test(this.ID(entity)) && this.ID(entity) !== entityId)
58
62
  .map(entity => this.ID(entity));
59
63
  }
60
64
  // Topological sort with cycle detection
61
65
  visit(node) {
62
- if (this.tempMark.has(node))
63
- throw new A_Error_class_1.A_Error("Circular dependency detected");
66
+ if (this.tempMark.has(node)) {
67
+ return;
68
+ // TODO: maybe we have to keep this error but only for partial cases
69
+ throw new A_StepManager_error_1.A_StepManagerError(A_StepManager_error_1.A_StepManagerError.CircularDependencyError, `Circular dependency detected involving step: ${node}. Make sure that your 'before' and 'after' dependencies do not create cycles.`);
70
+ }
64
71
  if (!this.visited.has(node)) {
65
72
  this.tempMark.add(node);
66
73
  (this.graph.get(node) || []).forEach(neighbor => this.visit(neighbor));
67
74
  this.tempMark.delete(node);
68
75
  this.visited.add(node);
69
76
  this.sortedEntities.push(node);
77
+ // // Visit neighbors in stable order (preserving original order)
78
+ // const neighbors = Array.from(this.graph.get(node) || []);
79
+ // // neighbors.sort((a, b) => {
80
+ // // const orderA = this.originalOrder.get(a) || 0;
81
+ // // const orderB = this.originalOrder.get(b) || 0;
82
+ // // return orderA - orderB;
83
+ // // });
84
+ // neighbors.forEach(neighbor => this.visit(neighbor));
85
+ // this.tempMark.delete(node);
86
+ // this.visited.add(node);
87
+ // this.sortedEntities.push(node);
70
88
  }
71
89
  }
72
- // Sort the entities based on dependencies
73
- toStages(feature) {
90
+ toSortedArray() {
74
91
  this.buildGraph();
75
92
  // Start topological sort
76
93
  this.entities.forEach(entity => {
77
94
  if (!this.visited.has(this.ID(entity)))
78
95
  this.visit(this.ID(entity));
79
96
  });
80
- const stages = [];
97
+ return this.sortedEntities;
98
+ }
99
+ // Sort the entities based on dependencies
100
+ toStages(feature) {
101
+ const sortedNames = this.toSortedArray();
81
102
  // Map sorted names back to entity objects
82
- this.sortedEntities
103
+ return sortedNames
83
104
  .map(id => {
84
105
  const step = this.entities.find(entity => this.ID(entity) === id);
85
- let stage = stages.find(stage => {
86
- return stage.after.every(after => step.after.includes(after))
87
- && step.before.every(before => stage.after.includes(before));
88
- });
89
- if (!stage) {
90
- stage = new A_TmpStage();
91
- stages.push(stage);
92
- }
93
- stage.add(step);
106
+ return new A_Stage_class_1.A_Stage(feature, step);
94
107
  });
95
- return stages.map(stage => new A_Stage_class_1.A_Stage(feature, stage.steps));
96
108
  }
97
109
  }
98
110
  exports.A_StepsManager = A_StepsManager;
99
- class A_TmpStage {
100
- constructor(_steps = []) {
101
- this.name = 'A_TmpStage';
102
- this._steps = _steps;
103
- }
104
- get before() {
105
- return this._steps.reduce((acc, step) => ([
106
- ...acc,
107
- ...step.before
108
- ]), []);
109
- }
110
- get after() {
111
- return this._steps.reduce((acc, step) => ([
112
- ...acc,
113
- ...step.after
114
- ]), []);
115
- }
116
- get steps() {
117
- return this._steps;
118
- }
119
- get asyncSteps() {
120
- return this._steps.filter(step => step.behavior === 'async');
121
- }
122
- get syncSteps() {
123
- return this._steps.filter(step => step.behavior === 'sync');
124
- }
125
- /**
126
- * Adds a step to the stage
127
- *
128
- * @param step
129
- * @returns
130
- */
131
- add(step) {
132
- this._steps.push(step);
133
- return this;
134
- }
135
- }
136
- exports.A_TmpStage = A_TmpStage;
137
- //# sourceMappingURL=A_StepsManager.class.js.map
111
+ //# sourceMappingURL=A-StepManager.class.js.map
@@ -0,0 +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,CAA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C,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;AApJD,wCAoJC"}
@@ -0,0 +1,4 @@
1
+ import { A_Error } from "../A-Error/A_Error.class";
2
+ export declare class A_StepManagerError extends A_Error {
3
+ static readonly CircularDependencyError = "A-StepManager Circular Dependency Error";
4
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.A_StepManagerError = void 0;
4
+ const A_Error_class_1 = require("../A-Error/A_Error.class");
5
+ class A_StepManagerError extends A_Error_class_1.A_Error {
6
+ }
7
+ exports.A_StepManagerError = A_StepManagerError;
8
+ A_StepManagerError.CircularDependencyError = 'A-StepManager Circular Dependency Error';
9
+ //# sourceMappingURL=A-StepManager.error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"A-StepManager.error.js","sourceRoot":"","sources":["../../../../src/global/A-StepManager/A-StepManager.error.ts"],"names":[],"mappings":";;;AAAA,4DAAmD;AAInD,MAAa,kBAAmB,SAAQ,uBAAO;;AAA/C,gDAKC;AAFmB,0CAAuB,GAAG,yCAAyC,CAAC"}