@xeno-js/core 1.2.6 → 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 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
- if (duration > this._thresholdMs) {
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);
@@ -3325,11 +3335,11 @@ var init_fastify_http_adapter = __esm({
3325
3335
  import_shared61 = require("@xeno-js/shared");
3326
3336
  init_base_http_adapter();
3327
3337
  FastifyHttpAdapter = class extends BaseHttpAdapter {
3328
- adapt(req, _res) {
3338
+ adapt(req, res) {
3329
3339
  const headers = this.parseHeaders(req.headers);
3330
3340
  const url = this.parseUrl(req.url, req.headers, req.query);
3331
3341
  const body = req.body;
3332
- return this.createXenoWebTransport(url, req.method, headers, body);
3342
+ return this.createXenoWebTransport(url, req.method, headers, body, res);
3333
3343
  }
3334
3344
  handleHeaderChange(res, name, value, action) {
3335
3345
  if (action === "delete") {
@@ -3388,10 +3398,10 @@ var init_vercel_http_adapter = __esm({
3388
3398
  import_shared62 = require("@xeno-js/shared");
3389
3399
  init_base_http_adapter();
3390
3400
  VercelHttpAdapter = class extends BaseHttpAdapter {
3391
- adapt(req, _res) {
3401
+ adapt(req, res) {
3392
3402
  const headers = this.parseHeaders(req.headers);
3393
3403
  const url = this.parseUrl(req.url, req.headers, req.query);
3394
- return this.createXenoWebTransport(url, req.method, headers, req.body);
3404
+ return this.createXenoWebTransport(url, req.method, headers, req.body, res);
3395
3405
  }
3396
3406
  handleHeaderChange(res, name, value, action) {
3397
3407
  if (action === "delete") {
@@ -4701,6 +4711,7 @@ __export(index_exports, {
4701
4711
  BaseAuthorizationStrategy: () => BaseAuthorizationStrategy,
4702
4712
  BaseController: () => BaseController,
4703
4713
  BaseHandler: () => BaseHandler,
4714
+ BaseHttpAdapter: () => BaseHttpAdapter,
4704
4715
  BasePostgresSqlDataSource: () => BasePostgresSqlDataSource,
4705
4716
  BaseQuery: () => import_shared84.Query,
4706
4717
  BaseSqliteSqlDataSource: () => BaseSqliteSqlDataSource,
@@ -5012,7 +5023,7 @@ var AppBuilder = class {
5012
5023
  custom: void 0
5013
5024
  };
5014
5025
  _pipelineConfig = {
5015
- performance: { thresholdMs: 500 },
5026
+ performance: { thresholdMs: 500, intentThresholdMs: void 0 },
5016
5027
  authorization: {
5017
5028
  policies: void 0,
5018
5029
  customAuthorizationStrategy: void 0
@@ -5533,6 +5544,7 @@ var import_shared79 = require("@xeno-js/shared");
5533
5544
 
5534
5545
  // src/infrastructure/index.ts
5535
5546
  init_factories();
5547
+ init_http();
5536
5548
  init_idempotency();
5537
5549
 
5538
5550
  // src/infrastructure/loggers/index.ts
@@ -5654,6 +5666,7 @@ var import_shared84 = require("@xeno-js/shared");
5654
5666
  BaseAuthorizationStrategy,
5655
5667
  BaseController,
5656
5668
  BaseHandler,
5669
+ BaseHttpAdapter,
5657
5670
  BasePostgresSqlDataSource,
5658
5671
  BaseQuery,
5659
5672
  BaseSqliteSqlDataSource,