import computeShardKey from "../../utils/shardKey.js";
import { CheckpointBasisFact } from "./CheckpointBasisFactBase.js";
import { validatePositiveInteger, validateText, } from "./CheckpointBasisFactValidation.js";
export class CheckpointProvenanceFact extends CheckpointBasisFact {
    kind = 'provenance';
    target;
    patchSha;
    writerId;
    lamport;
    constructor(options) {
        super();
        this.target = validateText(options.target, 'target');
        this.patchSha = validateText(options.patchSha, 'patchSha');
        this.writerId = validateText(options.writerId, 'writerId');
        this.lamport = validatePositiveInteger(options.lamport, 'lamport');
        Object.freeze(this);
    }
    shardFamily() {
        return 'provenance';
    }
    shardPath() {
        return `provenance_${computeShardKey(this.target)}.cbor`;
    }
    sortKey() {
        return `${this.target}:${this.lamport}:${this.writerId}:${this.patchSha}`;
    }
    toTransport() {
        return {
            kind: this.kind,
            target: this.target,
            patchSha: this.patchSha,
            writerId: this.writerId,
            lamport: this.lamport,
        };
    }
}
