Skip to content

VesselActionDefinition

Defined in: packages/protocol/src/lib/vessel.ts:272

Author-facing shape for a VesselAction. See VesselDefinition.

readonly description: string

Defined in: packages/protocol/src/lib/vessel.ts:276

What the Action does, written for the Planner that chooses it.


readonly optional effect?: "any" | "none" | "idempotent"

Defined in: packages/protocol/src/lib/vessel.ts:308

What running this Action does beyond its transitionsTo. Defaults to 'any'.

  • 'none': no application effect. The framework only switches the Variant, so a handler is optional. Declare it only for a view switch that needs nothing from the application, such as showing a week view. It must declare transitionsTo and no parameters, and it is safe to run again. Engine-planned Actions still need a registered runner for the Instance, and an empty useActions(id, {}) is enough.
  • 'idempotent': a handler is required, and running the Action again with the same parameters leaves the Vessel where one run would, such as opening an item that may already be open.
  • 'any': a handler is required, and the Action may append, remove or otherwise accumulate, so it is not safe to run again.

An Action without a handler that is not declared 'none' is skipped and changes no Variant, so a missing handler never reports success. The client’s ActionRunner type requires those handlers at compile time.

The Engine may re-emit an Action on a turn triggered by nothing but a chart resize, and it cannot see Vessel contents to tell a first run from a repeat. Such a turn admits only Actions declared 'none' or 'idempotent' that the model invoked with no parameters, since a parameter value there could only have come from an earlier turn.


readonly optional idempotent?: undefined

Defined in: packages/protocol/src/lib/vessel.ts:315

Removed. Declare VesselActionDefinition.effect instead: idempotent: true becomes effect: 'idempotent', and idempotent: false is the default effect: 'any'. A definition that still sets it fails to compile and fails validateVessel.


readonly name: string

Defined in: packages/protocol/src/lib/vessel.ts:274

Action name, unique within its Variant.


readonly optional parameters?: readonly object[]

Defined in: packages/protocol/src/lib/vessel.ts:278

Parameters the Action’s handler receives. Omit for none.


readonly optional transitionsTo?: string

Defined in: packages/protocol/src/lib/vessel.ts:280

The Variant the Instance moves to once the Action has run.