import computeShardKey from "../../utils/shardKey.js";
import { CheckpointBasisFact } from "./CheckpointBasisFactBase.js";
import { eventSortKey, eventTransport, validateEventId, validateText, } from "./CheckpointBasisFactValidation.js";
export class CheckpointNodeLivenessFact extends CheckpointBasisFact {
    kind = 'node-liveness';
    nodeId;
    alive;
    eventId;
    constructor(options) {
        super();
        this.nodeId = validateText(options.nodeId, 'nodeId');
        this.alive = options.alive;
        this.eventId = validateEventId(options.eventId);
        Object.freeze(this);
    }
    shardFamily() {
        return 'node-liveness';
    }
    shardPath() {
        return `liveness_${computeShardKey(this.nodeId)}.cbor`;
    }
    sortKey() {
        return `${this.nodeId}:${eventSortKey(this.eventId)}`;
    }
    toTransport() {
        return {
            kind: this.kind,
            nodeId: this.nodeId,
            alive: this.alive,
            eventId: eventTransport(this.eventId),
        };
    }
}
