@adaas/a-concept 0.3.7 → 0.3.8

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.
@@ -1084,7 +1084,7 @@ declare class A_Entity<_ConstructorType extends A_TYPES__Entity_Init = A_TYPES__
1084
1084
  * @param lifecycleMethod
1085
1085
  * @param args
1086
1086
  */
1087
- call(feature: string, scope?: A_Scope): any;
1087
+ call(feature: string, scope?: A_Scope): Promise<any> | void;
1088
1088
  /**
1089
1089
  * The default method that can be called and extended to load entity data.
1090
1090
  */
@@ -2013,6 +2013,7 @@ declare class A_Feature<T extends A_TYPES__FeatureAvailableComponents = A_TYPES_
2013
2013
  * Process stages one by one, ensuring each stage completes before starting the next
2014
2014
  */
2015
2015
  private processStagesSequentially;
2016
+ private createStageError;
2016
2017
  /**
2017
2018
  * This method moves the feature to the next stage
2018
2019
  *
@@ -1084,7 +1084,7 @@ declare class A_Entity<_ConstructorType extends A_TYPES__Entity_Init = A_TYPES__
1084
1084
  * @param lifecycleMethod
1085
1085
  * @param args
1086
1086
  */
1087
- call(feature: string, scope?: A_Scope): any;
1087
+ call(feature: string, scope?: A_Scope): Promise<any> | void;
1088
1088
  /**
1089
1089
  * The default method that can be called and extended to load entity data.
1090
1090
  */
@@ -2013,6 +2013,7 @@ declare class A_Feature<T extends A_TYPES__FeatureAvailableComponents = A_TYPES_
2013
2013
  * Process stages one by one, ensuring each stage completes before starting the next
2014
2014
  */
2015
2015
  private processStagesSequentially;
2016
+ private createStageError;
2016
2017
  /**
2017
2018
  * This method moves the feature to the next stage
2018
2019
  *
@@ -1117,13 +1117,13 @@ var A_Entity = class {
1117
1117
  * @param lifecycleMethod
1118
1118
  * @param args
1119
1119
  */
1120
- async call(feature, scope) {
1120
+ call(feature, scope) {
1121
1121
  const newFeature = new A_Feature({
1122
1122
  name: feature,
1123
1123
  component: this,
1124
1124
  scope
1125
1125
  });
1126
- return await newFeature.process(scope);
1126
+ return newFeature.process(scope);
1127
1127
  }
1128
1128
  // ====================================================================
1129
1129
  // ================== Entity Base Methods =============================
@@ -3324,7 +3324,7 @@ var A_Feature = class _A_Feature {
3324
3324
  if (!params || typeof params !== "object") {
3325
3325
  throw new A_FeatureError(
3326
3326
  A_FeatureError.FeatureInitializationError,
3327
- `Invalid A-Feature initialization parameters of type: ${typeof params} with value: ${JSON.stringify(params).slice(0, 100)}...`
3327
+ `Invalid A-Feature initialization parameters of type: ${typeof params} with value: ${JSON.stringify(params)?.slice(0, 100)}...`
3328
3328
  );
3329
3329
  }
3330
3330
  }
@@ -3343,7 +3343,7 @@ var A_Feature = class _A_Feature {
3343
3343
  default:
3344
3344
  throw new A_FeatureError(
3345
3345
  A_FeatureError.FeatureInitializationError,
3346
- `Invalid A-Feature initialization parameters of type: ${typeof params} with value: ${JSON.stringify(params).slice(0, 100)}...`
3346
+ `Invalid A-Feature initialization parameters of type: ${typeof params} with value: ${JSON.stringify(params)?.slice(0, 100)}...`
3347
3347
  );
3348
3348
  }
3349
3349
  }
@@ -3356,13 +3356,13 @@ var A_Feature = class _A_Feature {
3356
3356
  if (!params.template || !Array.isArray(params.template)) {
3357
3357
  throw new A_FeatureError(
3358
3358
  A_FeatureError.FeatureInitializationError,
3359
- `Invalid A-Feature template provided of type: ${typeof params.template} with value: ${JSON.stringify(params.template).slice(0, 100)}...`
3359
+ `Invalid A-Feature template provided of type: ${typeof params.template} with value: ${JSON.stringify(params.template)?.slice(0, 100)}...`
3360
3360
  );
3361
3361
  }
3362
3362
  if (!params.component && (!params.scope || !(params.scope instanceof A_Scope))) {
3363
3363
  throw new A_FeatureError(
3364
3364
  A_FeatureError.FeatureInitializationError,
3365
- `Invalid A-Feature scope provided of type: ${typeof params.scope} with value: ${JSON.stringify(params.scope).slice(0, 100)}...`
3365
+ `Invalid A-Feature scope provided of type: ${typeof params.scope} with value: ${JSON.stringify(params.scope)?.slice(0, 100)}...`
3366
3366
  );
3367
3367
  }
3368
3368
  this._name = params.name;
@@ -3394,7 +3394,7 @@ var A_Feature = class _A_Feature {
3394
3394
  if (!params.component || !A_TypeGuards.isAllowedForFeatureDefinition(params.component)) {
3395
3395
  throw new A_FeatureError(
3396
3396
  A_FeatureError.FeatureInitializationError,
3397
- `Invalid A-Feature component provided of type: ${typeof params.component} with value: ${JSON.stringify(params.component).slice(0, 100)}...`
3397
+ `Invalid A-Feature component provided of type: ${typeof params.component} with value: ${JSON.stringify(params.component)?.slice(0, 100)}...`
3398
3398
  );
3399
3399
  }
3400
3400
  this._name = params.name;
@@ -3444,42 +3444,43 @@ var A_Feature = class _A_Feature {
3444
3444
  * Process stages one by one, ensuring each stage completes before starting the next
3445
3445
  */
3446
3446
  processStagesSequentially(stages, scope, index) {
3447
- try {
3448
- if (this.state === "INTERRUPTED" /* INTERRUPTED */) {
3449
- return;
3450
- }
3451
- if (index >= stages.length) {
3452
- this.completed();
3453
- return;
3454
- }
3447
+ while (index < stages.length) {
3448
+ if (this.state === "INTERRUPTED" /* INTERRUPTED */) return;
3455
3449
  const stage = stages[index];
3456
- const result = stage.process(scope);
3450
+ let result;
3451
+ try {
3452
+ result = stage.process(scope);
3453
+ } catch (error) {
3454
+ throw this.createStageError(error, stage);
3455
+ }
3457
3456
  if (A_TypeGuards.isPromiseInstance(result)) {
3458
3457
  return result.then(() => {
3459
- if (this.state === "INTERRUPTED" /* INTERRUPTED */) {
3460
- return;
3461
- }
3458
+ if (this.state === "INTERRUPTED" /* INTERRUPTED */) return;
3462
3459
  return this.processStagesSequentially(stages, scope, index + 1);
3463
3460
  }).catch((error) => {
3464
- throw this.failed(new A_FeatureError({
3465
- title: A_FeatureError.FeatureProcessingError,
3466
- description: `An error occurred while processing the A-Feature: ${this.name}. Failed at stage: ${stage.name}.`,
3467
- stage,
3468
- originalError: error
3469
- }));
3461
+ throw this.createStageError(error, stage);
3470
3462
  });
3471
- } else {
3472
- return this.processStagesSequentially(stages, scope, index + 1);
3473
3463
  }
3474
- } catch (error) {
3475
- throw this.failed(new A_FeatureError({
3476
- title: A_FeatureError.FeatureProcessingError,
3477
- description: `An error occurred while processing the A-Feature: ${this.name}. Failed at stage: ${this.stage?.name || "N/A"}.`,
3478
- stage: this.stage,
3479
- originalError: error
3480
- }));
3464
+ index++;
3465
+ }
3466
+ if (this.state !== "INTERRUPTED" /* INTERRUPTED */) {
3467
+ this.completed();
3481
3468
  }
3482
3469
  }
3470
+ createStageError(error, stage) {
3471
+ this.failed(new A_FeatureError({
3472
+ title: A_FeatureError.FeatureProcessingError,
3473
+ description: `An error occurred while processing the A-Feature: ${this.name}. Failed at stage: ${stage.name}.`,
3474
+ stage,
3475
+ originalError: error
3476
+ }));
3477
+ return new A_FeatureError({
3478
+ title: A_FeatureError.FeatureProcessingError,
3479
+ description: `An error occurred while processing the A-Feature: ${this.name}. Failed at stage: ${stage.name}.`,
3480
+ stage,
3481
+ originalError: error
3482
+ });
3483
+ }
3483
3484
  /**
3484
3485
  * This method moves the feature to the next stage
3485
3486
  *