import { StateRepresentation } from './state-pepresentation'; import { StateMachine } from './state-machine'; import { Transition } from './transition'; import { DynamicStateInfos } from './reflection/dynamic-state-infos'; /** * The configuration for a single state value. * * @export * @class StateConfiguration * @template TState * @template TTrigger * @link https://github.com/dotnet-state-machine/stateless/blob/dev/src/Stateless/StateConfiguration.cs */ export declare class StateConfiguration { private readonly _machine; private readonly _representation; private readonly _lookup; /** * Creates an instance of StateConfiguration. * @param {StateMachine} _machine * @param {StateRepresentation} _representation * @param {(state: TState) => StateRepresentation} _lookup * @memberof StateConfiguration */ constructor(_machine: StateMachine, _representation: StateRepresentation, _lookup: (state: TState) => StateRepresentation); /** * The state that is configured with this configuration. * * @memberof StateConfiguration */ readonly state: TState; /** * The machine that is configured with this configuration. * * @readonly * @type {StateMachine} * @memberof StateConfiguration */ readonly machine: StateMachine; /** * Accept the specified trigger and transition to the destination state. * * @param {TTrigger} trigger The accepted trigger. * @param {TState} destinationState The state that the trigger will cause a transition to. * @returns {StateConfiguration} The reciever. * @memberof StateConfiguration */ permit(trigger: TTrigger, destinationState: TState): StateConfiguration; /** * Add an internal transition to the state machine. An internal action does not cause the Exit and Entry actions to be triggered, and does not change the state of the state machine * * @param {TTrigger} trigger * @param {((...args: any[]) => boolean | Promise)} guard * @param {((transition: Transition, ...args: any[]) => any | Promise)} internalAction * @param {(string | null)} [guardDescription=null] A description of the guard condition * @returns {StateConfiguration} * @memberof StateConfiguration */ internalTransitionIf(trigger: TTrigger, guard: (...args: any[]) => boolean | Promise, internalAction: (transition: Transition, ...args: any[]) => any | Promise, guardDescription?: string | null): StateConfiguration; /** * Add an internal transition to the state machine. An internal action does not cause the Exit and Entry actions to be triggered, and does not change the state of the state machine * * @param {TTrigger} trigger * @param {((transition: Transition, ...args: any[]) => any | Promise)} entryAction * @param {(string | null)} [description=null] * @returns {StateConfiguration} * @memberof StateConfiguration */ internalTransition(trigger: TTrigger, entryAction: (transition: Transition, ...args: any[]) => any | Promise, description?: string | null): StateConfiguration; /** * Accept the specified trigger and transition to the destination state. * * @param {TTrigger} The accepted trigger. * @param {TState} destinationState The state that the trigger will cause a transition to. * @param {(Array<{ guard: (...args: any[]) => boolean | Promise, description?: string | null } | ((...args: any[]) => boolean | Promise)> | ((...args: any[]) => boolean | Promise))} guards Functions and their descriptions that must return true in order for the trigger to be accepted. * @param {(string | null)} [description=null] * @returns {StateConfiguration} * @memberof StateConfiguration */ permitIf(trigger: TTrigger, destinationState: TState, guards: Array<{ guard: (...args: any[]) => boolean | Promise; description?: string | null; } | ((...args: any[]) => boolean | Promise)> | ((...args: any[]) => boolean | Promise), description?: string | null): StateConfiguration; /** * Accept the specified trigger, execute exit actions and re-execute entry actions. * * @description Applies to the current state only. Will not re-execute superstate actions, or cause actions to execute transitioning between super- and sub-states. * @param {TTrigger} trigger The accepted trigger. * @returns {StateConfiguration} The reciever. * @memberof StateConfiguration */ permitReentry(trigger: TTrigger): StateConfiguration; /** * Accept the specified trigger, execute exit actions and re-execute entry actions. * Reentry behaves as though the configured state transitions to an identical sibling state. * * @description Applies to the current state only. Will not re-execute superstate actions, or cause actions to execute transitioning between super- and sub-states. * @param {TTrigger} trigger The accepted trigger. * @param {(Array<{ guard: (...args: any[]) => boolean | Promise, description?: string | null } | ((...args: any[]) => boolean | Promise)> | ((...args: any[]) => boolean | Promise))} guards Functions and their descriptions that must return true in order for the trigger to be accepted. * @param {(string | null)} [description=null] The reciever. * @returns {StateConfiguration} * @memberof StateConfiguration */ permitReentryIf(trigger: TTrigger, guards: Array<{ guard: (...args: any[]) => boolean | Promise; description?: string | null; } | ((...args: any[]) => boolean | Promise)> | ((...args: any[]) => boolean | Promise), description?: string | null): StateConfiguration; /** * Ignore the specified trigger when in the configured state. * * @param {TTrigger} trigger * @returns {StateConfiguration} The trigger to ignore. * @memberof StateConfigurationThe receiver. */ ignore(trigger: TTrigger): StateConfiguration; /** * Ignore the specified trigger when in the configured state, if the guard returns true. * * @param {TTrigger} trigger The trigger to ignore. * @param {TState} state The state to ignore. * @param {(Array<{ guard: (...args: any[]) => boolean | Promise, description?: string | null } | ((...args: any[]) => boolean | Promise)> | ((...args: any[]) => boolean | Promise))} guards Functions and their descriptions that must return true in order for the trigger to be ignored. * @param {(string | null)} [description=null] Description. * @returns {StateConfiguration} The receiver. * @memberof StateConfiguration */ ignoreIf(trigger: TTrigger, state: TState, guards: Array<{ guard: (...args: any[]) => boolean | Promise; description?: string | null; } | ((...args: any[]) => boolean | Promise)> | ((...args: any[]) => boolean | Promise), description?: string | null): StateConfiguration; /** * Specify an action that will execute when activating the configured state. * * @param {(() => any | Promise)} activateAction Action to execute. * @param {(string | null)} [activateActionDescription=null] Action description. * @returns {StateConfiguration} * @memberof StateConfiguration */ onActivate(activateAction: () => any | Promise, activateActionDescription?: string | null): StateConfiguration; /** * Specify an action that will execute when deactivating * * @param {(() => any | Promise)} deactivateAction Action to execute. * @param {(string | null)} [deactivateActionDescription=null] Action description. * @returns {StateConfiguration} * @memberof StateConfiguration */ onDeactivate(deactivateAction: () => any | Promise, deactivateActionDescription?: string | null): StateConfiguration; /** * Specify an action that will execute when transitioning into the configured state. * * @param {((transition: Transition) => any | Promise)} entryAction Action to execute. * @param {(string | null)} [entryActionDescription=null] Action description. * @returns {StateConfiguration} The receiver. * @memberof StateConfiguration */ onEntry(entryAction: (transition: Transition) => any | Promise, entryActionDescription?: string | null): StateConfiguration; /** * Specify an action that will execute when transitioning into the configured state. * * @param {TTrigger} trigger The trigger by which the state must be entered in order for the action to execute. * @param {((transition: Transition, ...args: any[]) => any | Promise)} entryAction Action to execute, providing details of the transition. * @param {string | null} [entryActionDescription] Action description. * @returns {StateConfiguration} The receiver. * @memberof StateConfiguration */ onEntryFrom(trigger: TTrigger, entryAction: (transition: Transition, ...args: any[]) => any | Promise, entryActionDescription?: string | null): StateConfiguration; /** * Specify an action that will execute when transitioning from the configured state. * * @param {((transition: Transition) => any | Promise)} exitAction Action to execute. * @param {string} [exitActionDescription] Action description. * @returns {StateConfiguration} * @memberof StateConfiguration */ onExit(exitAction: (transition: Transition) => any | Promise, exitActionDescription?: string | null): StateConfiguration; /** * Sets the superstate that the configured state is a substate of. * @description Substates inherit the allowed transitions of their superstate. * entry actions for the superstate are executed. * Likewise when leaving from the substate to outside the supserstate, * exit actions for the superstate will execute. * @param {TState} superstate The superstate. * @returns {StateConfiguration} The receiver. * @memberof StateConfiguration */ substateOf(superstate: TState): StateConfiguration; /** * Accept the specified trigger and transition to the destination state, calculated dynamically by the supplied function. * * @param {TTrigger} trigger * @param {(args: any[]) => TState} destinationStateSelector Function to calculate the state that the trigger will cause a transition to. * @param {(string | null)} [destinationStateSelectorDescription=null] Optional description of the function to calculate the state . * @param {(DynamicStateInfos | null)} [possibleDestinationStates=null] >Optional array of possible destination states (used by output formatters) * @returns {StateConfiguration} The reciever. * @memberof StateConfiguration */ permitDynamic(trigger: TTrigger, destinationStateSelector: (args: any[]) => TState, destinationStateSelectorDescription?: string | null, possibleDestinationStates?: DynamicStateInfos | null): StateConfiguration; /** * Accept the specified trigger and transition to the destination state, calculated dynamically by the supplied function. * * @param {TTrigger} trigger The accepted trigger. * @param {(args: any[]) => TState} destinationStateSelector Function to calculate the state that the trigger will cause transition to. * @param {(Array<{ guard: (...args: any[]) => boolean | Promise, description?: string | null } | ((...args: any[]) => boolean | Promise)> | ((...args: any[]) => boolean | Promise))} guards Functions and their descriptions that must return true in order for the trigger to be accepted. * @param {(string | null)} [description=null] * @returns {StateConfiguration} The reciever. * @memberof StateConfiguration */ permitDynamicIf(trigger: TTrigger, destinationStateSelector: (args: any[]) => TState, guards: Array<{ guard: (...args: any[]) => boolean | Promise; description?: string | null; } | ((...args: any[]) => boolean | Promise)> | ((...args: any[]) => boolean | Promise), description?: string | null): StateConfiguration; private enforceNotIdentityTransition; private internalPermit; private internalPermitIf; private internalPermitReentryIf; private internalPermitDynamicIf; /** * Adds internal transition to this state. When entering the current state the state machine will look for an initial transition, and enter the target state. * * @param {TState} targetState The target initial state * @returns {StateConfiguration} A stateConfiguration object * @memberof StateConfiguration */ initialTransition(targetState: TState): StateConfiguration; } //# sourceMappingURL=state-configuration.d.ts.map