@xeno-js/core 1.2.7 → 1.2.9
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/dist/index.cjs +16 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +16 -6
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -587,7 +587,7 @@ var init_performance_pipeline = __esm({
|
|
|
587
587
|
* @since 2025-09-30
|
|
588
588
|
* @link https://github.com/xeno-js/xeno-js
|
|
589
589
|
*/
|
|
590
|
-
constructor(_logger, thresholdMs = defaultThresholdMs) {
|
|
590
|
+
constructor(_logger, intentThresholdMS = {}, thresholdMs = defaultThresholdMs) {
|
|
591
591
|
this._logger = _logger;
|
|
592
592
|
const message = `Invalid thresholdMs value: ${thresholdMs}. It must be a positive integer.`;
|
|
593
593
|
import_shared12.Guards.throwIfNegative(thresholdMs, message);
|
|
@@ -595,6 +595,15 @@ var init_performance_pipeline = __esm({
|
|
|
595
595
|
throw new Error(message);
|
|
596
596
|
}
|
|
597
597
|
this._thresholdMs = thresholdMs;
|
|
598
|
+
for (const [intent, val] of Object.entries(intentThresholdMS)) {
|
|
599
|
+
const intentMessage = `Invalid thresholdMs value for intent '${intent}': ${val}. It must be a positive integer.`;
|
|
600
|
+
import_shared12.Guards.throwIfNegative(val, intentMessage);
|
|
601
|
+
import_shared12.Guards.throwIfNotInteger(val, intentMessage);
|
|
602
|
+
if (val === 0) {
|
|
603
|
+
throw new Error(intentMessage);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
this._intentThresholdMS = intentThresholdMS;
|
|
598
607
|
}
|
|
599
608
|
_logger;
|
|
600
609
|
/**
|
|
@@ -607,6 +616,7 @@ var init_performance_pipeline = __esm({
|
|
|
607
616
|
* @link https://github.com/xeno-js/xeno-js
|
|
608
617
|
*/
|
|
609
618
|
_thresholdMs;
|
|
619
|
+
_intentThresholdMS;
|
|
610
620
|
async handle(request, next) {
|
|
611
621
|
const startTime = performance.now();
|
|
612
622
|
try {
|
|
@@ -614,7 +624,8 @@ var init_performance_pipeline = __esm({
|
|
|
614
624
|
} finally {
|
|
615
625
|
const endTime = performance.now();
|
|
616
626
|
const duration = endTime - startTime;
|
|
617
|
-
|
|
627
|
+
const thresholdMs = this._intentThresholdMS?.[request.intent] ?? this._thresholdMs;
|
|
628
|
+
if (duration > thresholdMs) {
|
|
618
629
|
this._logger.warn(`Performance warning: ${request.intent} took ${duration.toFixed(2)}ms`);
|
|
619
630
|
}
|
|
620
631
|
}
|
|
@@ -2974,7 +2985,7 @@ var init_cqrs_module = __esm({
|
|
|
2974
2985
|
"use strict";
|
|
2975
2986
|
CqrsModule = class {
|
|
2976
2987
|
async configure(container, opts) {
|
|
2977
|
-
const { TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
2988
|
+
const { Guards: Guards51, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
2978
2989
|
const logger = container.resolve(TOKENS5.LOGGER);
|
|
2979
2990
|
const { Mediator: Mediator2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
2980
2991
|
container.addSingleton(TOKENS5.MEDIATOR, (c) => {
|
|
@@ -2988,9 +2999,8 @@ var init_cqrs_module = __esm({
|
|
|
2988
2999
|
const pipelines = [
|
|
2989
3000
|
new ExceptionPipeline2(),
|
|
2990
3001
|
new LoggingPipeline2(logger),
|
|
2991
|
-
new PerformancePipeline2(logger, thresholdMs)
|
|
3002
|
+
new PerformancePipeline2(logger, opts.performance.intentThresholdMs, thresholdMs)
|
|
2992
3003
|
];
|
|
2993
|
-
const { Guards: Guards51 } = await import("@xeno-js/shared");
|
|
2994
3004
|
if (Guards51.isDefined(opts.authorization.policies) || Guards51.isDefined(opts.authorization.customAuthorizationStrategy)) {
|
|
2995
3005
|
const { AuthUtils: AuthUtils2 } = await Promise.resolve().then(() => (init_auth_utils(), auth_utils_exports));
|
|
2996
3006
|
const authPipelines = await AuthUtils2.addAuthZ(container, opts.authorization);
|
|
@@ -5013,7 +5023,7 @@ var AppBuilder = class {
|
|
|
5013
5023
|
custom: void 0
|
|
5014
5024
|
};
|
|
5015
5025
|
_pipelineConfig = {
|
|
5016
|
-
performance: { thresholdMs: 500 },
|
|
5026
|
+
performance: { thresholdMs: 500, intentThresholdMs: void 0 },
|
|
5017
5027
|
authorization: {
|
|
5018
5028
|
policies: void 0,
|
|
5019
5029
|
customAuthorizationStrategy: void 0
|