Events Doc - AutolabJS/autolabcli GitHub Wiki

We are following an event-based approach for communication of controller with input, output and the model

The general body of an event is as follows-

{
    name: 'event_name',
    details: {
      datail1: 'datail1_value',
      detail2: 'detail2_value',
      ...
    }
}

Init Command

  • The controller of init first sends an event to the output for welcome message -
initOutput.sendOutput({
    name: 'welcome'
});
  • Then the controller gets input from init/input and send another event to the output to indicate that the authentication process has started.
initOutput.sendOutput({
    name: 'authentication_started'
});
  • The model, after fetching the private token from the gitlab server, sends it to the controller along with the status of the task.
| status code | status detail |
-------------------------------
| 200         | success       |
| 401         | unauthorized  |
|   4         | no connection |
  • After getting the status from the model, the controller send an event to the the output to indicate that the authentication has ended along with the status from the model.
initOutput.sendOutput({
    name: 'authentication_ended',
    details: {
      ...status
    }
  });

The above code uses the spread operator of ES6.

Exit Command

  • The controller of exit sends an event to the output when the model has successfully logged out -
initOutput.sendOutput({
    name: 'logout_success'
});

Prefs Command

  • The prefs input returns an event according to the arguments to the prefs command.

    Main server changed

    {
     name: 'server_changed',
     details: {
       host,
       port,
       type: 'ms',
     },
    }
    

    Gitlab server changed

    {
     name: 'server_changed',
     details: {
       host,
       type: 'gitlab',
     },
    }
    
  • In case the input provided to change the server is invalid, appropriate events are returned.

    Invalid host

    {
     name: 'invalid_host',
    }
    

    Invalid port

    {
     name: 'invalid_port',
    }
    
  • When the input is to to show the stored prefs, the returned event is -
    {
     name: 'show_prefs',
    }
    

Eval Command

  • The controller of eval sends an event to the output to show that the evaluation has started after it receives the input from evalInput -

    {
     name: 'eval_started',
    }
    
  • The eval controller then passes the input to the model along with a callback function. The model calls this callback function with one of the below events when it receives a response from the server. The controller forwards this event to the eval output.

    Invalid submission

    {
     name: 'invalid',
    }
    

    ISubmission Pending

    {
     name: 'submission_pending',
    }
    

    Invalid host

    {
     name: 'scores',
     details: {
       ...dataFromServer
     }
    }