OpenSlides/docs/interfaces/action-service.txt

59 lines
1.7 KiB
Plaintext
Raw Normal View History

# Actions Service Interface
2020-01-20 07:43:25 +01:00
2020-11-10 17:28:57 +01:00
/**
* JSON resonse with a status code of !=200:
* {
* success: false;
* message: string;
* }
*
*/
2020-01-21 18:05:47 +01:00
Exception ActionException(message: string);
2020-01-20 07:43:25 +01:00
/**
2020-04-03 13:24:15 +02:00
* Executes multiple actions in the context of the user given by the user_id.
2020-11-10 17:28:57 +01:00
* All actions are depdend: If one fails, nothing is written to the DataStore.
* It can be seen as one transaction.
2020-02-03 23:32:24 +01:00
*
2020-11-10 17:28:57 +01:00
* For each action an ActionResult is returned. If an action has an error,
* ActionError is used in combination wuth error_index to indicate, which action
* resulted in an error.
2020-01-20 07:43:25 +01:00
*
2020-11-10 17:28:57 +01:00
* For general, non specific action-related, errors an ActionException is used.
2020-01-21 18:05:47 +01:00
*
* @throws ActionException
2020-01-20 07:43:25 +01:00
*/
2020-11-11 08:33:59 +01:00
handle_request (payload: Action[], user_id: Id): ActionsResponse | ActionError
2020-01-20 07:43:25 +01:00
interface Action {
2020-01-21 18:05:47 +01:00
action: string;
2020-11-10 17:28:57 +01:00
data: object[]; # An array of action specific data.
2020-02-03 23:32:24 +01:00
}
2020-11-11 08:33:59 +01:00
interace ActionsResponse {
2020-11-10 17:28:57 +01:00
success: true;
2020-02-03 23:32:24 +01:00
message: string;
2020-11-10 17:28:57 +01:00
/**
* this is a potentially double-array with entries for each action
* and, if not null, an array for each data provided for each action.
*
*
* If an action does not producy a result, the inner array can be omitted and
* null can be used. If the inner array is given, each entry must be an object
* with the result (e.g. for a create action `{id: <the id>}`) or null.
* E.g. for valid arrays (two actions with two data entries each):
* - [null, null]
* - [null, [null, null]]
* - [null, [{id: 2}, null]]
* - [[{id: 2}, {id: 3}], [{id: 5}, {id: 8}]]
**/
results: ((object | null)[] | null )[]
2020-01-20 07:43:25 +01:00
}
2020-11-10 17:28:57 +01:00
interface ActionError {
success: false;
message: string;
error_index: number;
}