package org.raddatz.familienarchiv.audit;

import java.util.Set;

public enum AuditKind {

    /** Payload: none */
    FILE_UPLOADED,

    /** Payload: {@code {"oldStatus": "UPLOADED", "newStatus": "TRANSCRIBED"}} */
    STATUS_CHANGED,

    /** Payload: none */
    METADATA_UPDATED,

    /** Payload: {@code {"pageNumber": 3}} */
    TEXT_SAVED,

    /** Payload: none */
    BLOCK_REVIEWED,

    /** Payload: {@code {"pageNumber": 3}} */
    ANNOTATION_CREATED,

    /** Payload: {@code {"commentId": "uuid"}} */
    COMMENT_ADDED,

    /** Payload: {@code {"commentId": "uuid", "mentionedUserId": "uuid"}} */
    MENTION_CREATED,

    /** Payload: {@code {"userId": "uuid", "email": "addr"}} */
    USER_CREATED,

    /** Payload: {@code {"userId": "uuid", "email": "addr"}} */
    USER_DELETED,

    /** Payload: {@code {"userId": "uuid", "email": "addr", "addedGroups": ["Admin"], "removedGroups": []}} */
    GROUP_MEMBERSHIP_CHANGED,

    /** Payload: {@code {"userId": "uuid", "ip": "1.2.3.4", "ua": "Mozilla/5.0..."}} */
    LOGIN_SUCCESS,

    /** Payload: {@code {"email": "addr", "ip": "1.2.3.4", "ua": "Mozilla/5.0..."}} — password NEVER included */
    LOGIN_FAILED,

    /** Payload: {@code {"userId": "uuid", "ip": "1.2.3.4", "ua": "Mozilla/5.0...", "reason": "password_change|password_reset|admin_force_logout", "revokedCount": 3}} */
    LOGOUT,

    /** Payload: {@code {"actorId": "uuid", "targetUserId": "uuid", "revokedCount": 3}} */
    ADMIN_FORCE_LOGOUT,

    /** Payload: {@code {"ip": "1.2.3.4", "email": "addr"}} — password NEVER included */
    LOGIN_RATE_LIMITED,

    // --- Documents ---

    /** Payload: none — the deleted document's id is carried in the documentId column */
    DOCUMENT_DELETED,

    // --- Reading Journeys (Lesereisen) ---

    /** Payload: {@code {"geschichteId": "uuid", "itemId": "uuid"}} — documentId is null (journey-scoped, not document-scoped) */
    JOURNEY_ITEM_ADDED,

    /** Payload: {@code {"geschichteId": "uuid", "itemId": "uuid"}} — documentId is null */
    JOURNEY_ITEM_REMOVED,

    /** Payload: {@code {"geschichteId": "uuid", "itemId": "uuid"}} — documentId is null */
    JOURNEY_ITEM_NOTE_UPDATED,

    /** Payload: {@code {"geschichteId": "uuid", "itemCount": 3}} — documentId is null; rolled up in chronik */
    JOURNEY_ITEMS_REORDERED;

    public static final Set<AuditKind> ROLLUP_ELIGIBLE = Set.of(
            TEXT_SAVED, FILE_UPLOADED, ANNOTATION_CREATED,
            BLOCK_REVIEWED, COMMENT_ADDED, MENTION_CREATED,
            JOURNEY_ITEMS_REORDERED
    );
}
