@kellanjs/actioncraft
Version:
Fluent, type-safe builder for Next.js server actions.
69 lines (68 loc) • 2.33 kB
TypeScript
import type { CraftedAction } from "../../types/actions.js";
import type { Config, Schemas, Errors, Callbacks } from "../../types/builder.js";
import type { CraftBuilder } from "../craft-builder.js";
export declare class Executor<TConfig extends Config, TSchemas extends Schemas, TErrors extends Errors, TCallbacks extends Callbacks<TConfig, TSchemas, TErrors, TData>, TData> {
private readonly _config;
private readonly _schemas;
private readonly _errors;
private readonly _callbacks;
private readonly _handler?;
private _actionId?;
constructor(builder: CraftBuilder<TConfig, TSchemas, TErrors, TCallbacks, TData>);
/**
* Builds and returns the final executable server action.
*/
craft(): CraftedAction<TConfig, TSchemas, TErrors, TData>;
/**
* Generates a unique identifier for this action instance.
*/
private _generateActionId;
/**
* Orchestrates action execution (validation, business logic, callbacks, and result formatting.)
*/
private _runAction;
/**
* Extracts bind arguments, previous state, and input from raw action arguments.
*/
private _extractActionArgs;
/**
* Transforms internal Result objects to client-facing action result format.
*/
private _toActionResult;
/**
* Handles uncaught exceptions during action execution.
*/
private _handleThrownError;
/**
* Validates input using the shared helper.
*/
private _validateInput;
/**
* Validates bound arguments using the configured bind schemas.
*/
private _validateBindArgs;
/**
* Validates output data using the configured output schema.
*/
private _validateOutput;
/**
* Validates input data only (used by the $validate method).
*/
private _validateInputOnly;
/**
* Executes the onStart callback if defined.
*/
private _executeOnStartCallback;
/**
* Executes result-based lifecycle callbacks (onSuccess, onError, onSettled).
*/
private _executeResultCallbacks;
/**
* Ensures a Result object has the correct action ID.
*/
private _ensureResultActionId;
/**
* Creates error functions that return a Result object when called by the action handler.
*/
private _buildErrorFunctions;
}