import * as Constants from './constants' ; import * as Types from './types' ; import type { RobotApiRequestMeta } from '../robot-api/types' ; import type { Mount } from '../pipettes/types' ; export const fetchLights = ( robotName ) : Types . FetchLightsAction => ( { type : Constants . FETCH_LIGHTS , payload : { robotName } , meta : { } , } ) ; export const fetchLightsSuccess = ( robotName , lightsOn , meta ) : Types . FetchLightsSuccessAction => ( { type : Constants . FETCH_LIGHTS_SUCCESS , payload : { robotName , lightsOn } , meta , } ) ; export const fetchLightsFailure = ( robotName , error , meta ) : Types . FetchLightsFailureAction => ( { type : Constants . FETCH_LIGHTS_FAILURE , payload : { robotName , error } , meta , } ) ; export const updateLights = ( robotName , lightsOn ) : Types . UpdateLightsAction => ( { type : Constants . UPDATE_LIGHTS , payload : { robotName , lightsOn } , meta : { } as RobotApiRequestMeta , } ) ; export const updateLightsSuccess = ( robotName , lightsOn , meta ) : Types . UpdateLightsSuccessAction => ( { type : Constants . UPDATE_LIGHTS_SUCCESS , payload : { robotName , lightsOn } , meta , } ) ; export const updateLightsFailure = ( robotName , error , meta ) : Types . UpdateLightsFailureAction => ( { type : Constants . UPDATE_LIGHTS_FAILURE , payload : { robotName , error } , meta , } ) ; type HomeActionCreator = ( ( robotName : string , target : 'robot' ) => Types . HomeAction ) & ( ( robotName : string , target : 'pipette' , mount : Mount ) => Types . HomeAction ) ; export const home = ( robotName , target , mount ? ) : Types . HomeAction => ( { type : Constants . HOME , payload : target === Constants . PIPETTE && typeof mount === 'string' ? { robotName , target : Constants . PIPETTE , mount } : { robotName , target : Constants . ROBOT } , meta : { } , } ) ; export const homeSuccess = ( robotName , meta ) : Types . HomeSuccessAction => ( { type : Constants . HOME_SUCCESS , payload : { robotName } , meta , } ) ; export const homeFailure = ( robotName , error , meta ) : Types . HomeFailureAction => ( { type : Constants . HOME_FAILURE , payload : { robotName , error } , meta , } ) ; export const move = ( robotName , position , mount , disengageMotors = false ) : Types . MoveAction => ( { type : Constants . MOVE , payload : { robotName , mount , position , disengageMotors } , meta : { } , } ) ; export const moveSuccess = ( robotName , meta ) : Types . MoveSuccessAction => ( { type : Constants . MOVE_SUCCESS , payload : { robotName } , meta , } ) ; export const moveFailure = ( robotName , error , meta ) : Types . MoveFailureAction => ( { type : Constants . MOVE_FAILURE , payload : { robotName , error } , meta , } ) ; export const clearMovementStatus = ( robotName ) : Types . ClearMovementStatusAction => ( { type : Constants . CLEAR_MOVEMENT_STATUS , payload : { robotName } , } ) ;