@xeno-js/core 1.2.7 → 1.2.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/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 +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1324,6 +1324,14 @@ interface PipelineConfig<TRegistry extends ApplicationRegistry<unknown> = Applic
|
|
|
1324
1324
|
* @link https://github.com/xeno-js/xeno-js
|
|
1325
1325
|
*/
|
|
1326
1326
|
thresholdMs: Optional<number>;
|
|
1327
|
+
/** @description Optional threshold in milliseconds for logging slow operations by intent. If defined, the PerformancePipeline will log a warning whenever the execution of a command or query exceeds this duration, allowing for performance monitoring and optimization. If not defined, all operations will be monitored without duration-based filtering.
|
|
1328
|
+
*
|
|
1329
|
+
* @author Xeno
|
|
1330
|
+
* @version 1.0.0
|
|
1331
|
+
* @since 2025-09-30
|
|
1332
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
1333
|
+
*/
|
|
1334
|
+
intentThresholdMs: Optional<Dictionary<number>>;
|
|
1327
1335
|
};
|
|
1328
1336
|
/** @description Configuration for authorization, allowing the enabling of authorization strategies based on tenant, policy, roles, and permissions. If enabled, the authorization pipeline will evaluate the specified strategies for each command or query, ensuring that only authorized users can perform certain actions. The configuration also includes the ability to define custom authorization strategies via injection tokens, providing flexibility in implementing application-specific access rules.
|
|
1329
1337
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1324,6 +1324,14 @@ interface PipelineConfig<TRegistry extends ApplicationRegistry<unknown> = Applic
|
|
|
1324
1324
|
* @link https://github.com/xeno-js/xeno-js
|
|
1325
1325
|
*/
|
|
1326
1326
|
thresholdMs: Optional<number>;
|
|
1327
|
+
/** @description Optional threshold in milliseconds for logging slow operations by intent. If defined, the PerformancePipeline will log a warning whenever the execution of a command or query exceeds this duration, allowing for performance monitoring and optimization. If not defined, all operations will be monitored without duration-based filtering.
|
|
1328
|
+
*
|
|
1329
|
+
* @author Xeno
|
|
1330
|
+
* @version 1.0.0
|
|
1331
|
+
* @since 2025-09-30
|
|
1332
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
1333
|
+
*/
|
|
1334
|
+
intentThresholdMs: Optional<Dictionary<number>>;
|
|
1327
1335
|
};
|
|
1328
1336
|
/** @description Configuration for authorization, allowing the enabling of authorization strategies based on tenant, policy, roles, and permissions. If enabled, the authorization pipeline will evaluate the specified strategies for each command or query, ensuring that only authorized users can perform certain actions. The configuration also includes the ability to define custom authorization strategies via injection tokens, providing flexibility in implementing application-specific access rules.
|
|
1329
1337
|
*
|
package/dist/index.js
CHANGED
|
@@ -583,7 +583,7 @@ var init_performance_pipeline = __esm({
|
|
|
583
583
|
* @since 2025-09-30
|
|
584
584
|
* @link https://github.com/xeno-js/xeno-js
|
|
585
585
|
*/
|
|
586
|
-
constructor(_logger, thresholdMs = defaultThresholdMs) {
|
|
586
|
+
constructor(_logger, intentThresholdMS = {}, thresholdMs = defaultThresholdMs) {
|
|
587
587
|
this._logger = _logger;
|
|
588
588
|
const message = `Invalid thresholdMs value: ${thresholdMs}. It must be a positive integer.`;
|
|
589
589
|
Guards5.throwIfNegative(thresholdMs, message);
|
|
@@ -591,6 +591,15 @@ var init_performance_pipeline = __esm({
|
|
|
591
591
|
throw new Error(message);
|
|
592
592
|
}
|
|
593
593
|
this._thresholdMs = thresholdMs;
|
|
594
|
+
for (const [intent, val] of Object.entries(intentThresholdMS)) {
|
|
595
|
+
const intentMessage = `Invalid thresholdMs value for intent '${intent}': ${val}. It must be a positive integer.`;
|
|
596
|
+
Guards5.throwIfNegative(val, intentMessage);
|
|
597
|
+
Guards5.throwIfNotInteger(val, intentMessage);
|
|
598
|
+
if (val === 0) {
|
|
599
|
+
throw new Error(intentMessage);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
this._intentThresholdMS = intentThresholdMS;
|
|
594
603
|
}
|
|
595
604
|
_logger;
|
|
596
605
|
/**
|
|
@@ -603,6 +612,7 @@ var init_performance_pipeline = __esm({
|
|
|
603
612
|
* @link https://github.com/xeno-js/xeno-js
|
|
604
613
|
*/
|
|
605
614
|
_thresholdMs;
|
|
615
|
+
_intentThresholdMS;
|
|
606
616
|
async handle(request, next) {
|
|
607
617
|
const startTime = performance.now();
|
|
608
618
|
try {
|
|
@@ -610,7 +620,8 @@ var init_performance_pipeline = __esm({
|
|
|
610
620
|
} finally {
|
|
611
621
|
const endTime = performance.now();
|
|
612
622
|
const duration = endTime - startTime;
|
|
613
|
-
|
|
623
|
+
const thresholdMs = this._intentThresholdMS?.[request.intent] ?? this._thresholdMs;
|
|
624
|
+
if (duration > thresholdMs) {
|
|
614
625
|
this._logger.warn(`Performance warning: ${request.intent} took ${duration.toFixed(2)}ms`);
|
|
615
626
|
}
|
|
616
627
|
}
|
|
@@ -2984,7 +2995,7 @@ var init_cqrs_module = __esm({
|
|
|
2984
2995
|
"use strict";
|
|
2985
2996
|
CqrsModule = class {
|
|
2986
2997
|
async configure(container, opts) {
|
|
2987
|
-
const { TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
2998
|
+
const { Guards: Guards51, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
2988
2999
|
const logger = container.resolve(TOKENS5.LOGGER);
|
|
2989
3000
|
const { Mediator: Mediator2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
2990
3001
|
container.addSingleton(TOKENS5.MEDIATOR, (c) => {
|
|
@@ -2998,9 +3009,8 @@ var init_cqrs_module = __esm({
|
|
|
2998
3009
|
const pipelines = [
|
|
2999
3010
|
new ExceptionPipeline2(),
|
|
3000
3011
|
new LoggingPipeline2(logger),
|
|
3001
|
-
new PerformancePipeline2(logger, thresholdMs)
|
|
3012
|
+
new PerformancePipeline2(logger, opts.performance.intentThresholdMs, thresholdMs)
|
|
3002
3013
|
];
|
|
3003
|
-
const { Guards: Guards51 } = await import("@xeno-js/shared");
|
|
3004
3014
|
if (Guards51.isDefined(opts.authorization.policies) || Guards51.isDefined(opts.authorization.customAuthorizationStrategy)) {
|
|
3005
3015
|
const { AuthUtils: AuthUtils2 } = await Promise.resolve().then(() => (init_auth_utils(), auth_utils_exports));
|
|
3006
3016
|
const authPipelines = await AuthUtils2.addAuthZ(container, opts.authorization);
|
|
@@ -5055,7 +5065,7 @@ var AppBuilder = class {
|
|
|
5055
5065
|
custom: void 0
|
|
5056
5066
|
};
|
|
5057
5067
|
_pipelineConfig = {
|
|
5058
|
-
performance: { thresholdMs: 500 },
|
|
5068
|
+
performance: { thresholdMs: 500, intentThresholdMs: void 0 },
|
|
5059
5069
|
authorization: {
|
|
5060
5070
|
policies: void 0,
|
|
5061
5071
|
customAuthorizationStrategy: void 0
|