<commit_before>/**
 * The identifier of a message.
 */
export type MessageId = string

/**
 * The identifier of a message.
 */
export type MessageType = string

/**
 * The kind of a message.
 */
export enum MessageKind {
    message = "message",
    action = "action",
    command = "command",
    query = "query",
    result = "result",
    error = "error",
    event = "event",
}

/**
 * The name of a message.
 */
export interface MessageHeaders {
    messageType: MessageType
    messageId: MessageId

    [key: string]: string | number
}

/**
 * The constructor of a message.
 * @template M the type of the message
 */
export interface MessageConstructor<M extends Message = Message> {
    new(...args: any[]): M
}

/**
 * A message is an information which can be identified.
 * @template B the type of the body
 * @template H the type of the headers
 */
export interface Message<B = any, H extends MessageHeaders = MessageHeaders> {
    readonly kind: MessageKind
    readonly headers: H
    readonly body: B
}

/**
 * An action is a message which expects a result.
 * It can be to mutate the system, c.f. {@link MessageCommand} or request a view of the system state, c.f. {@link MessageQuery}.
 * @template B the type of the body<commit_msg>chore(ceb-messaging-core): improve documentation<commit_after>/**
 * The identifier of a message.
 */
export type MessageId = string

/**
 * The identifier of a message.
 */
export type MessageType = string

/**
 * The kind of a message.
 */
export enum MessageKind {
    /**
     * Refer to {@link Message}
     */
    message = "message",
    /**
     * Refer to {@link MessageAction}
     */
    action = "action",
    /**
     * Refer to {@link MessageCommand}
     */
    command = "command",
    /**
     * Refer to {@link MessageQuery}
     */
    query = "query",
    /**
     * Refer to {@link MessageResult}
     */
    result = "result",
    /**
     * Refer to {@link MessageError}
     */
    error = "error",
    /**
     * Refer to {@link MessageEvent}
     */
    event = "event",
}

/**
 * The name of a message.
 */
export interface MessageHeaders {
    /**
     * The type of the message.
     */
    messageType: MessageType
    /**
     * The identifier of the message.
     */
    messageId: MessageId

    [key: string]: string | number
}

/**
 * The constructor of a message.
 * @template M the type of the message
 */
export interface MessageConstructor<M extends Message = Message> {
    new(...args: any[]): M
}

/**
 * A message is an information which can be identified.
 * @template B the type of the body
 * @template H the type of the headers
 */
export interface Message<B = any, H extends MessageHeaders = MessageHeaders> {
    /**
     * The kind of the message.
     */
    readonly kind: MessageKind
    /**
     * The headers.
     */
    readonly headers: H
    /**
     * The body.
     */
    readonly body: B
}

/**
 * An action is a message which expects a result.
 * It can be to mutate the system, c.f. {@link MessageCommand} or request a view of the system state, c.f. {@link MessageQuery}.
 * @template B the type of the body
{'fraction_non_alphanumeric': 0.12083333333333333, 'fraction_numerical': 0.0, 'mean_word_length': 2.4639289678135405, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '401560', 'n_tokens_mistral': 894, 'n_tokens_neox': 897, 'n_words': 358}