Skip to content

MoveBlobAction

@blobs/sdk v0.1.0


@blobs/sdk / actions/blob / MoveBlobAction

Defined in: actions/blob/MoveBlobAction.ts:78

Action that moves a blob to a new parent or to the root level.

Forward path: calls BlobsService.update(id, { parent_id }) with the new parent. The backend treats an empty string as NULL, so root moves use '' over the wire. Undo path: writes the original parent reference back. The captured MoveBlobUndoState stores the original parent id (and optionally title for display).

Validation rejects moving a blob to itself; circular-reference detection (moving a parent into one of its descendants) is a TODO and currently delegated to the backend.

Remarks

Use ActionManager.execute for managed flow — adds the action to a linear history stack so manager.undo() / manager.redo() find it without you keeping a reference, discards forward branches on a new execute, emits action:executing / action:completed events, and injects a pre-configured ActionContext. Calling action.execute(context) directly is also supported for one-shot use without history; see BaseAction for the full contract.

Examples

const action = createMoveBlobAction(payload);
await actionManager.execute(action);
await actionManager.undo();
const action = createMoveBlobAction(payload);
await action.execute({ blobsService: blobs.blobs });
await action.undo({ blobsService: blobs.blobs });

Extends

Constructors

Constructor

new MoveBlobAction(payload): MoveBlobAction

Defined in: actions/blob/MoveBlobAction.ts:91

Parameters

payload

MoveBlobPayload

MoveBlobPayload describing the move.

Returns

MoveBlobAction

Overrides

BaseAction.constructor

Properties

id

readonly id: string

Defined in: actions/BaseAction.ts:74

Unique action identifier; assigned at construction time.

Inherited from

BaseAction.id


payload

readonly payload: MoveBlobPayload

Defined in: actions/BaseAction.ts:80

The original payload the action was constructed with.

Inherited from

BaseAction.payload


createdAt

readonly createdAt: number

Defined in: actions/BaseAction.ts:82

Wall-clock timestamp (ms) when the action was instantiated.

Inherited from

BaseAction.createdAt


canUndo

readonly canUndo: boolean

Defined in: actions/BaseAction.ts:84

Whether BaseAction.undo is allowed for this action.

Inherited from

BaseAction.canUndo


canRedo

readonly canRedo: boolean

Defined in: actions/BaseAction.ts:86

Whether BaseAction.redo is allowed after undo.

Inherited from

BaseAction.canRedo


status

status: ActionStatus = 'pending'

Defined in: actions/BaseAction.ts:89

Current lifecycle status; mutated by execute/undo/redo.

Inherited from

BaseAction.status


executedAt?

optional executedAt?: number

Defined in: actions/BaseAction.ts:91

Wall-clock timestamp (ms) when execute most recently completed.

Inherited from

BaseAction.executedAt


previousState?

optional previousState?: ActionState<MoveBlobUndoState>

Defined in: actions/BaseAction.ts:93

Captured pre-execution state used by undo.

Inherited from

BaseAction.previousState


result?

optional result?: ActionResult<Blob>

Defined in: actions/BaseAction.ts:95

Last result produced by execute/undo/redo.

Inherited from

BaseAction.result


type

readonly type: "blob:move" = 'blob:move'

Defined in: actions/blob/MoveBlobAction.ts:79

Action type tag (e.g. 'blob:delete'); set by subclasses.

Overrides

BaseAction.type

Accessors

description

Get Signature

get description(): string

Defined in: actions/blob/MoveBlobAction.ts:82

Human-readable description used in undo/redo UI listings.

Returns

string

Human-readable description used in UI history listings.

Overrides

BaseAction.description

Methods

execute()

execute(context): Promise<ActionResult<Blob>>

Defined in: actions/BaseAction.ts:123

Runs the action: validates first, captures undo state when applicable, then dispatches to the subclass-implemented doExecute. Catches exceptions and converts them into a failed ActionResult.

Parameters

context

ActionContext

Per-execution context.

Returns

Promise<ActionResult<Blob>>

The execution result.

Inherited from

BaseAction.execute


undo()

undo(context): Promise<ActionResult<Blob>>

Defined in: actions/BaseAction.ts:171

Reverses the action by delegating to the subclass doUndo with the captured undo state. Refuses to run unless the action previously completed (or was last redone) and undo state is available.

Parameters

context

ActionContext

Per-execution context.

Returns

Promise<ActionResult<Blob>>

The undo result.

Inherited from

BaseAction.undo


redo()

redo(context): Promise<ActionResult<Blob>>

Defined in: actions/BaseAction.ts:215

Re-applies a previously undone action. By default delegates to doExecute; subclasses can override doRedo for an optimized path that does not re-capture undo state.

Parameters

context

ActionContext

Per-execution context.

Returns

Promise<ActionResult<Blob>>

The redo result.

Inherited from

BaseAction.redo


doRedo()

protected doRedo(context): Promise<ActionResult<Blob>>

Defined in: actions/BaseAction.ts:292

Subclass hook performing the redo path. The default implementation re-runs doExecute; override when redo can be performed without recomputing state.

Parameters

context

ActionContext

Per-execution context.

Returns

Promise<ActionResult<Blob>>

The redo result.

Inherited from

BaseAction.doRedo


toJSON()

toJSON(): Record<string, unknown>

Defined in: actions/BaseAction.ts:300

Serializes the action’s identity and lifecycle metadata for storage or transmission. Excludes captured undo state and methods.

Returns

Record<string, unknown>

Inherited from

BaseAction.toJSON


validate()

validate(context): Promise<ActionResult<void>>

Defined in: actions/blob/MoveBlobAction.ts:101

Validates that a BlobsService is reachable and that the move does not target the blob itself.

Parameters

context

ActionContext

Per-execution context.

Returns

Promise<ActionResult<void>>

Overrides

BaseAction.validate


captureState()

captureState(context): Promise<MoveBlobUndoState>

Defined in: actions/blob/MoveBlobAction.ts:133

Loads the blob and records its current parent_id so undo can move it back.

Parameters

context

ActionContext

Per-execution context.

Returns

Promise<MoveBlobUndoState>

The captured undo state.

Throws

When the blob cannot be loaded.

Overrides

BaseAction.captureState


doExecute()

protected doExecute(context): Promise<ActionResult<Blob>>

Defined in: actions/blob/MoveBlobAction.ts:158

Issues the move by updating the blob’s parent_id. Sends '' for a null target (root) since the backend treats empty strings as NULL.

Parameters

context

ActionContext

Returns

Promise<ActionResult<Blob>>

Overrides

BaseAction.doExecute


doUndo()

protected doUndo(context, previousState): Promise<ActionResult<Blob>>

Defined in: actions/blob/MoveBlobAction.ts:197

Restores the blob’s original parent reference.

Parameters

context

ActionContext

Per-execution context.

previousState

MoveBlobUndoState

The pre-move snapshot.

Returns

Promise<ActionResult<Blob>>

Overrides

BaseAction.doUndo