Action<TPayload, TResult, TUndoState>
@blobs/sdk / actions/types / Action
Defined in: actions/types.ts:76
Command-pattern contract every action must implement.
Action instances carry their own payload, capture undo state on
execution, and can replay or roll back via Action.redo and
Action.undo. Actions are normally executed through
ActionManager.execute so the manager can track them in history.
Type Parameters
TPayload
TPayload = unknown
The shape of the action’s input parameters.
TResult
TResult = unknown
The shape of the result data on success.
TUndoState
TUndoState = unknown
The shape of the snapshot captured for undo.
Properties
id
readonlyid:string
Defined in: actions/types.ts:78
Unique action ID
type
readonlytype:string
Defined in: actions/types.ts:80
Action type identifier
description
readonlydescription:string
Defined in: actions/types.ts:82
Human-readable description
payload
readonlypayload:TPayload
Defined in: actions/types.ts:84
Action payload/parameters
status
status:
ActionStatus
Defined in: actions/types.ts:86
Current status
createdAt
readonlycreatedAt:number
Defined in: actions/types.ts:88
Timestamp of creation
executedAt?
optionalexecutedAt?:number
Defined in: actions/types.ts:90
Timestamp of execution
previousState?
optionalpreviousState?:ActionState<TUndoState>
Defined in: actions/types.ts:92
State captured before execution (for undo)
result?
optionalresult?:ActionResult<TResult>
Defined in: actions/types.ts:94
Result of execution
canUndo
readonlycanUndo:boolean
Defined in: actions/types.ts:96
Whether this action can be undone
canRedo
readonlycanRedo:boolean
Defined in: actions/types.ts:98
Whether this action can be redone after undo
Methods
execute()
execute(
context):Promise<ActionResult<TResult>>
Defined in: actions/types.ts:106
Executes the action, capturing undo state first if canUndo is true.
Parameters
context
Per-execution context.
Returns
Promise<ActionResult<TResult>>
The execution result.
undo()
undo(
context):Promise<ActionResult<TResult>>
Defined in: actions/types.ts:114
Reverses the action by restoring the captured undo state.
Parameters
context
Per-execution context.
Returns
Promise<ActionResult<TResult>>
The undo result.
redo()
redo(
context):Promise<ActionResult<TResult>>
Defined in: actions/types.ts:122
Re-applies a previously undone action.
Parameters
context
Per-execution context.
Returns
Promise<ActionResult<TResult>>
The redo result.
captureState()
captureState(
context):Promise<TUndoState>
Defined in: actions/types.ts:131
Captures the state needed to reverse this action. Called automatically by BaseAction.execute before the operation runs.
Parameters
context
Per-execution context.
Returns
Promise<TUndoState>
The undo-state snapshot.
validate()
validate(
context):Promise<ActionResult<void>>
Defined in: actions/types.ts:139
Validates whether the action can run in the given context.
Parameters
context
Per-execution context.
Returns
Promise<ActionResult<void>>
A success result, or a failure result with an error reason.