@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.
- package/benchmarks/feature-chaining.bench.ts +465 -0
- package/benchmarks/feature-optimize.bench.ts +205 -0
- package/dist/browser/index.d.mts +2 -1
- package/dist/browser/index.mjs +2 -2
- package/dist/browser/index.mjs.map +1 -1
- package/dist/node/index.cjs +35 -34
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.mts +2 -1
- package/dist/node/index.d.ts +2 -1
- package/dist/node/index.mjs +35 -34
- package/dist/node/index.mjs.map +1 -1
- package/package.json +3 -1
- package/src/lib/A-Entity/A-Entity.class.ts +3 -3
- package/src/lib/A-Feature/A-Feature.class.ts +46 -41
- package/tests/A-Feature.test.ts +101 -0
package/dist/node/index.cjs
CHANGED
|
@@ -1119,13 +1119,13 @@ var A_Entity = class {
|
|
|
1119
1119
|
* @param lifecycleMethod
|
|
1120
1120
|
* @param args
|
|
1121
1121
|
*/
|
|
1122
|
-
|
|
1122
|
+
call(feature, scope) {
|
|
1123
1123
|
const newFeature = new A_Feature({
|
|
1124
1124
|
name: feature,
|
|
1125
1125
|
component: this,
|
|
1126
1126
|
scope
|
|
1127
1127
|
});
|
|
1128
|
-
return
|
|
1128
|
+
return newFeature.process(scope);
|
|
1129
1129
|
}
|
|
1130
1130
|
// ====================================================================
|
|
1131
1131
|
// ================== Entity Base Methods =============================
|
|
@@ -3326,7 +3326,7 @@ var A_Feature = class _A_Feature {
|
|
|
3326
3326
|
if (!params || typeof params !== "object") {
|
|
3327
3327
|
throw new A_FeatureError(
|
|
3328
3328
|
A_FeatureError.FeatureInitializationError,
|
|
3329
|
-
`Invalid A-Feature initialization parameters of type: ${typeof params} with value: ${JSON.stringify(params)
|
|
3329
|
+
`Invalid A-Feature initialization parameters of type: ${typeof params} with value: ${JSON.stringify(params)?.slice(0, 100)}...`
|
|
3330
3330
|
);
|
|
3331
3331
|
}
|
|
3332
3332
|
}
|
|
@@ -3345,7 +3345,7 @@ var A_Feature = class _A_Feature {
|
|
|
3345
3345
|
default:
|
|
3346
3346
|
throw new A_FeatureError(
|
|
3347
3347
|
A_FeatureError.FeatureInitializationError,
|
|
3348
|
-
`Invalid A-Feature initialization parameters of type: ${typeof params} with value: ${JSON.stringify(params)
|
|
3348
|
+
`Invalid A-Feature initialization parameters of type: ${typeof params} with value: ${JSON.stringify(params)?.slice(0, 100)}...`
|
|
3349
3349
|
);
|
|
3350
3350
|
}
|
|
3351
3351
|
}
|
|
@@ -3358,13 +3358,13 @@ var A_Feature = class _A_Feature {
|
|
|
3358
3358
|
if (!params.template || !Array.isArray(params.template)) {
|
|
3359
3359
|
throw new A_FeatureError(
|
|
3360
3360
|
A_FeatureError.FeatureInitializationError,
|
|
3361
|
-
`Invalid A-Feature template provided of type: ${typeof params.template} with value: ${JSON.stringify(params.template)
|
|
3361
|
+
`Invalid A-Feature template provided of type: ${typeof params.template} with value: ${JSON.stringify(params.template)?.slice(0, 100)}...`
|
|
3362
3362
|
);
|
|
3363
3363
|
}
|
|
3364
3364
|
if (!params.component && (!params.scope || !(params.scope instanceof A_Scope))) {
|
|
3365
3365
|
throw new A_FeatureError(
|
|
3366
3366
|
A_FeatureError.FeatureInitializationError,
|
|
3367
|
-
`Invalid A-Feature scope provided of type: ${typeof params.scope} with value: ${JSON.stringify(params.scope)
|
|
3367
|
+
`Invalid A-Feature scope provided of type: ${typeof params.scope} with value: ${JSON.stringify(params.scope)?.slice(0, 100)}...`
|
|
3368
3368
|
);
|
|
3369
3369
|
}
|
|
3370
3370
|
this._name = params.name;
|
|
@@ -3396,7 +3396,7 @@ var A_Feature = class _A_Feature {
|
|
|
3396
3396
|
if (!params.component || !A_TypeGuards.isAllowedForFeatureDefinition(params.component)) {
|
|
3397
3397
|
throw new A_FeatureError(
|
|
3398
3398
|
A_FeatureError.FeatureInitializationError,
|
|
3399
|
-
`Invalid A-Feature component provided of type: ${typeof params.component} with value: ${JSON.stringify(params.component)
|
|
3399
|
+
`Invalid A-Feature component provided of type: ${typeof params.component} with value: ${JSON.stringify(params.component)?.slice(0, 100)}...`
|
|
3400
3400
|
);
|
|
3401
3401
|
}
|
|
3402
3402
|
this._name = params.name;
|
|
@@ -3446,42 +3446,43 @@ var A_Feature = class _A_Feature {
|
|
|
3446
3446
|
* Process stages one by one, ensuring each stage completes before starting the next
|
|
3447
3447
|
*/
|
|
3448
3448
|
processStagesSequentially(stages, scope, index) {
|
|
3449
|
-
|
|
3450
|
-
if (this.state === "INTERRUPTED" /* INTERRUPTED */)
|
|
3451
|
-
return;
|
|
3452
|
-
}
|
|
3453
|
-
if (index >= stages.length) {
|
|
3454
|
-
this.completed();
|
|
3455
|
-
return;
|
|
3456
|
-
}
|
|
3449
|
+
while (index < stages.length) {
|
|
3450
|
+
if (this.state === "INTERRUPTED" /* INTERRUPTED */) return;
|
|
3457
3451
|
const stage = stages[index];
|
|
3458
|
-
|
|
3452
|
+
let result;
|
|
3453
|
+
try {
|
|
3454
|
+
result = stage.process(scope);
|
|
3455
|
+
} catch (error) {
|
|
3456
|
+
throw this.createStageError(error, stage);
|
|
3457
|
+
}
|
|
3459
3458
|
if (A_TypeGuards.isPromiseInstance(result)) {
|
|
3460
3459
|
return result.then(() => {
|
|
3461
|
-
if (this.state === "INTERRUPTED" /* INTERRUPTED */)
|
|
3462
|
-
return;
|
|
3463
|
-
}
|
|
3460
|
+
if (this.state === "INTERRUPTED" /* INTERRUPTED */) return;
|
|
3464
3461
|
return this.processStagesSequentially(stages, scope, index + 1);
|
|
3465
3462
|
}).catch((error) => {
|
|
3466
|
-
throw this.
|
|
3467
|
-
title: A_FeatureError.FeatureProcessingError,
|
|
3468
|
-
description: `An error occurred while processing the A-Feature: ${this.name}. Failed at stage: ${stage.name}.`,
|
|
3469
|
-
stage,
|
|
3470
|
-
originalError: error
|
|
3471
|
-
}));
|
|
3463
|
+
throw this.createStageError(error, stage);
|
|
3472
3464
|
});
|
|
3473
|
-
} else {
|
|
3474
|
-
return this.processStagesSequentially(stages, scope, index + 1);
|
|
3475
3465
|
}
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
stage: this.stage,
|
|
3481
|
-
originalError: error
|
|
3482
|
-
}));
|
|
3466
|
+
index++;
|
|
3467
|
+
}
|
|
3468
|
+
if (this.state !== "INTERRUPTED" /* INTERRUPTED */) {
|
|
3469
|
+
this.completed();
|
|
3483
3470
|
}
|
|
3484
3471
|
}
|
|
3472
|
+
createStageError(error, stage) {
|
|
3473
|
+
this.failed(new A_FeatureError({
|
|
3474
|
+
title: A_FeatureError.FeatureProcessingError,
|
|
3475
|
+
description: `An error occurred while processing the A-Feature: ${this.name}. Failed at stage: ${stage.name}.`,
|
|
3476
|
+
stage,
|
|
3477
|
+
originalError: error
|
|
3478
|
+
}));
|
|
3479
|
+
return new A_FeatureError({
|
|
3480
|
+
title: A_FeatureError.FeatureProcessingError,
|
|
3481
|
+
description: `An error occurred while processing the A-Feature: ${this.name}. Failed at stage: ${stage.name}.`,
|
|
3482
|
+
stage,
|
|
3483
|
+
originalError: error
|
|
3484
|
+
});
|
|
3485
|
+
}
|
|
3485
3486
|
/**
|
|
3486
3487
|
* This method moves the feature to the next stage
|
|
3487
3488
|
*
|