Assembly: OptimaJet.Workflow.Api

Interface IOperationBuilder<TInput, TSuccess>

OptimaJet.Workflow.Api.Configuration.IOperationBuilder<TInput, TSuccess>

Registers callbacks for one operation in one application.

public interface IOperationBuilder<TInput, TSuccess>

Methods

IOperationBuilder<TInput, TSuccess> OnBefore(Func<IOperationContext<TInput>, ValueTask<IResult?>> callback) #
Adds input preparation. Null continues; a result skips the remaining before/authorization callbacks and handler, then runs OnAfter.

Parameters

Name
Type
Description
callback
Func<IOperationContext<TInput>, IResult>
The preparation callback.

Returns

Type
Description
IOperationBuilder<TInput, TSuccess>
This builder.

Remarks

Only this stage permits ReplaceInput. ASP.NET policies and HTTP binding run before the callback.
IOperationBuilder<TInput, TSuccess> OnAuthorize(Func<IOperationContext<TInput>, ValueTask<bool>> callback) #
Adds authorization over the final input. The first false returns 403 and skips the remaining authorization callbacks and handler.

Parameters

Name
Type
Description
callback
Func<IOperationContext<TInput>, Boolean>
The authorization callback.

Returns

Type
Description
IOperationBuilder<TInput, TSuccess>
This builder.

Remarks

Runs even when built-in security is disabled. Do not mutate the input or its nested values in this stage.
IOperationBuilder<TInput, TSuccess> OnAfterSuccess(Func<IOperationContext<TInput>, TSuccess, ValueTask<TSuccess>> callback) #
Adds a transformation of the original handler's successful (2xx) payload, preserving HTTP result semantics.

Parameters

Name
Type
Description
callback
Func<IOperationContext<TInput>, TSuccess, ValueTask<TSuccess>>
The payload transformation.

Returns

Type
Description
IOperationBuilder<TInput, TSuccess>
This builder.

Remarks

Skipped for results without payload (including null values), errors, authorization denials, short circuits and exception fallbacks. An empty response record is a payload.
IOperationBuilder<TInput, TSuccess> OnAfter(Func<IOperationContext<TInput>, IResult, ValueTask<IResult>> callback) #
Adds a transformation of the final result, including handler errors, short circuits, callback denials and exception fallbacks.

Parameters

Name
Type
Description
callback
Func<IOperationContext<TInput>, IResult, IResult>
The result transformation, which must return a non-null result.

Returns

Type
Description
IOperationBuilder<TInput, TSuccess>
This builder.

Remarks

Runs before result execution and serialization. Responses from external middleware are outside this pipeline.
IOperationBuilder<TInput, TSuccess> OnException(Func<IOperationContext<TInput>, Exception, ValueTask<IResult?>> callback) #
Adds exception recovery. Null passes the original exception to the next callback; the first result handles it.

Parameters

Name
Type
Description
callback
Func<IOperationContext<TInput>, Exception, IResult>
The exception recovery callback.

Returns

Type
Description
IOperationBuilder<TInput, TSuccess>
This builder.

Remarks

Covers callbacks and the handler, but not binding, result execution, serialization or an already-started response. Unhandled exceptions preserve their stack trace. Request cancellation bypasses recovery, and process/tenant guards convert protected failures to 404 first, including failures inside recovery callbacks. Other recovery failures propagate without recursively invoking the callback chain. A fallback before OnAfter passes through that stage once; a fallback for an OnAfter failure is sent directly.

Remarks

Stages run in fixed order: OnBefore, OnAuthorize, handler, OnAfterSuccess, OnAfter. Within each stage callbacks run in registration order. Resolve scoped dependencies from the callback context. Builders cannot be changed after configuration is fixed; request state is not stored in this builder.