<commit_before>// Actions Service Interface

/**
 * Executes multiple actions in the context of the user given by the user_id.
 * There are two modes of execution:
 * atomic=false (default):
 *   All actions are validated in common, so if one action or one payload of
 *   one action fails, the request is aborted with an ActionException indicating
 *   the problematic action with both indices.
 * atomic=true:
 *   Each action is validated by it's own. If there is an error, the error must
 *   be reported via an ActionError in the ActionsResponse. The actions result
 *   is not written into the Datastore. It might raise an ActionException if the
 *   single write request to the Datastore fails (e.g. because of locking there)
 *
 * For general, non specific action-related, errors an ActionException is used.
 *
 * @throws ActionException
 */
handle_request(payload: Action[], user_id: Id, atomic?: boolean): ActionsResponse

interface Action {
    action: string;
    data: object[];
}

interace ActionsResponse {
    success: true;
    message: string;

    /**
     * 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 produce 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}]]
     *
     *
     * To report errors, use the ActionError format!
     **/
    results: ((object | ActionError | null)[] | null )[]
}

interface ActionError {
    success: false;
    message: string;
}

/**
 * JSON resonse with a status code of !=200. If a specific action raised the error,
 * use the action_error_index and action_payload_error_index to indicate the errored
 * action and payload. If there were general errors, both indices must be omitted or null.
 *
 * If the atomic flag was true in the request, it is not allowed to send
 * action-specific errors with this exception. It must be responded with an
 * ActionError through ActionsResponse (resulting in a status code of 200).
 */
Exception ActionException {
    success: false;
    message: string;
    action_error_index?: number;
    action_payload_error_index?: number;
}
<commit_msg>Fix action interface<commit_after>// Actions Service Interface

/**
 * Executes multiple actions in the context of the user given by the user_id.
 * There are two modes of execution:
 * atomic=false (default):
 *   All actions are validated in common, so if one action or one payload of
 *   one action fails, the request is aborted with an ActionException indicating
 *   the problematic action with both indices.
 * atomic=true:
 *   Each action is validated by it's own. If there is an error, the error must
 *   be reported via an ActionError in the ActionsResponse. The actions result
 *   is not written into the Datastore. It might raise an ActionException if the
 *   single write request to the Datastore fails (e.g. because of locking there)
 *
 * For general, non specific action-related, errors an ActionException is used.
 *
 * @throws ActionException
 */
handle_request(payload: Action[], user_id: Id, atomic?: boolean): ActionsResponse

interface Action {
    action: string;
    data: object[];
}

interace ActionsResponse {
    success: true;
    message: string;

    /**
     * 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 produce 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}]]
     *
     *
     * To report errors, use the ActionError format!
     **/
    results: (object[] | ActionError | null )[]
}

/**
 * If action_data_error_index is given, the error can be directly associated with the
 * respective action data. If not, the error is of general fashion and/or not directly
 * associated with a single action data.
 *
 * Note: ActionError can only be used if atomic=true.
 */
interface ActionError {
    success: false;
    message: string;
    action_data_error_index?: number;
}

/**
 * JSON resonse with a status code of !=200. If a specific action raised the error,
 * use the action_error_index and action_data_error_index to indicate the errored
 * action and data, respectively. If there were general errors, both indices must be
 * omitted or null.
 *
 * If the atomic flag was true in the request, it is not allowed to send
 * action-specific errors with this exception. It must be responded with an
 * ActionError through ActionsResponse (resulting in a status code of 200).
 */
Exception ActionException {
    success: false;
    message: string;
    action_error_index?: number;
    action_data_error_index?: number;
}

{'fraction_non_alphanumeric': 0.0853273975143758, 'fraction_numerical': 0.004080875533296235, 'mean_word_length': 3.2290196078431372, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1989103', 'n_tokens_mistral': 1513, 'n_tokens_neox': 1466, 'n_words': 718}