import AttachmentRecord from "./AttachmentRecord.js";
import WarpError from "../errors/WarpError.js";
export const GRAPH_ATTACHMENT_SET_OP = 'GraphAttachmentSet';
/** Runtime-backed graph operation that sets an attachment payload. */
export default class GraphAttachmentSetOp {
    type = GRAPH_ATTACHMENT_SET_OP;
    record;
    constructor(fields) {
        const checkedFields = requireFields(fields);
        this.record = requireAttachmentRecord(checkedFields.record);
        Object.freeze(this);
    }
}
/** Validates the graph-attachment operation constructor envelope. */
function requireFields(fields) {
    if (fields === null || fields === undefined) {
        throw new WarpError('GraphAttachmentSetOp fields must be provided', 'E_VALIDATION');
    }
    return fields;
}
/** Requires a runtime-backed attachment record. */
function requireAttachmentRecord(record) {
    if (!(record instanceof AttachmentRecord)) {
        throw new WarpError('GraphAttachmentSetOp record must be an AttachmentRecord', 'E_VALIDATION');
    }
    return record;
}
