feat(pipeline): add configuration and hooks for pipeline execution

- Introduce `IPipelineExecutorConfig` to enable customizable pipeline behavior
- Add `IPipelineHooks` interface for tracing and monitoring lifecycle events
- Define callback types for pipeline start, step execution, and completion
- Export new types and interfaces for broader integration within the system
This commit is contained in:
2025-05-10 16:21:16 +02:00
parent 0846dbb758
commit 3f114bb68d
5 changed files with 126 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
import { ResponseDecorator } from '../Types/ResponseDecorator.ts';
import { IContext } from './IContext.ts';
import { IHttpErrorHandlers } from './IHttpErrorHandlers.ts';
import { IPipelineHooks } from './IPipelineHooks.ts';
/**
* Configuration object for the PipelineExecutor, defining how to handle
* errors, responses, and tracing hooks.
*
* This allows the execution logic to remain decoupled from kernel-level behavior
* while still supporting custom behavior injection.
*
* @template TContext - The context type propagated during pipeline execution.
*/
export interface IPipelineExecutorConfig<TContext extends IContext = IContext> {
/**
* Optional function used to transform or decorate the final Response object
* before it is returned to the client.
*/
decorateResponse?: ResponseDecorator<TContext>;
/**
* Optional map of error handlers, keyed by HTTP status codes (e.g., 404, 500).
* These handlers are invoked if an error occurs during middleware or handler execution.
*/
errorHandlers?: IHttpErrorHandlers<TContext>;
/**
* Optional hooks that allow tracing and lifecycle monitoring during pipeline execution.
* Each hook is called at a specific phase of the middleware/handler lifecycle.
*/
pipelineHooks?: IPipelineHooks<TContext>;
}