Skip to content

ActionRunner

ActionRunner<V> = string extends ActionNames<V> ? { [Name in ActionNames<V>]?: ActionHandlerFor<V, Name> } : Simplify<{ [Name in HandlerRequiredActionNames<V>]: ActionHandlerFor<V, Name> } & { [Name in HandlerOptionalActionNames<V>]?: ActionHandlerFor<V, Name> }>

Defined in: packages/client/src/lib/command-processor/action-runner.types.ts:171

Typed action runner map keyed by action name, inferred from the Vessel definition.

A handler is required for every Action that is not declared effect: 'none', because such an Action without a handler is skipped and changes no Variant. A handler is optional for an Action declared effect: 'none': the framework applies its transition on its own. When the same Action name appears on several Variants, its handler is required if any of those declarations is not 'none'.

A widened definition typed as plain VesselDefinition, whose Action names are not literal, makes every handler optional.

V extends VesselDefinition = VesselDefinition

import { ok } from '@maelstrom-co/protocol';
const runner: ActionRunner<typeof myVessel> = {
selectOrder: (params) => {
// params is fully typed based on vessel definition
console.log(params.orderId);
return ok(undefined);
},
// `showList` is declared `effect: 'none'`, so it may be left out.
};