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