# models Shared type definitions for state-machine state, actions, and reducers. This entry point re-exports the cross-cutting types consumed by the runtime modules ([`store`](https://www.hyperfrontend.dev/docs/libraries/state-machine/store.md), [`reducer`](https://www.hyperfrontend.dev/docs/libraries/state-machine/reducer.md), [`selectors`](https://www.hyperfrontend.dev/docs/libraries/state-machine/selectors.md), [`state-change`](https://www.hyperfrontend.dev/docs/libraries/state-machine/state-change.md)). Consumers writing their own action handlers or reducers import from here to stay aligned with the shapes the rest of the library expects, without having to dig into module-private files. ## API Reference ### Interfaces #### Action Base action with a type discriminator **Properties** | Name | Type | Description | | --- | --- | --- | | `type` | `string` | Action type identifier | #### DerivedState Derived state computed from core state flags **Properties** | Name | Type | Description | | --- | --- | --- | | `notStarted` | `boolean` | Operation has not started | | `inProgress` | `boolean` | Operation is in progress | | `done` | `boolean` | Operation has completed | | `successful` | `boolean` | Operation completed successfully | | `failed` | `boolean` | Operation failed | | `retrying` | `boolean` | Operation is retrying | | `restarting` | `boolean` | Operation is restarting | | `paused` | `boolean` | Operation is paused | | `cancelled` | `boolean` | Operation was cancelled | #### Handlers Map of action type constants to their handler functions **Properties** | Name | Type | Description | | --- | --- | --- | | `process started` | `(state: State, action: { payload: unknown; type: string }) => State` | Handler for start action | | `process paused` | `(state: State, action: { payload: unknown; type: string }) => State` | Handler for pause action | | `process cancelled` | `(state: State, action: { payload: unknown; type: string }) => State` | Handler for cancel action | | `process completed successfully` | `(state: State, action: { payload: unknown; type: string }) => State` | Handler for success action | | `process failed` | `(state: State, action: { error: any; type: string }) => State` | Handler for fail action | #### State Core state machine state flags **Properties** | Name | Type | Description | | --- | --- | --- | | `inProgress` | `boolean` | Whether the operation is currently in progress | | `success` | `boolean` | Whether the operation completed successfully | | `fail` | `boolean` | Whether the operation failed | | `halt` | `boolean` | Whether the operation is halted | ### Types #### Event Event name type derived from the event constant object ```typescript type Event = indexedAccess ``` #### StateDeriver Function that derives full DerivedState from State ```typescript type StateDeriver = (state: State) => DerivedState ``` #### StateStatusDeriver Function that derives a single status boolean from state ```typescript type StateStatusDeriver = (state: State) => boolean ``` ### Variables #### event ```typescript const event: { Cancelled: "cancelled"; Done: "done"; Failed: "failed"; InProgress: "inProgress"; NotStarted: "notStarted"; Paused: "paused"; Restarting: "restarting"; Retrying: "retrying"; Successful: "successful" } ``` **Value** `...` --- Canonical page: https://www.hyperfrontend.dev/docs/libraries/state-machine/models/ This file: https://www.hyperfrontend.dev/docs/libraries/state-machine/models.md Documentation index: https://www.hyperfrontend.dev/llms.txt