import Transform from "../../domain/stream/Transform.js";
import WarpError from "../../domain/errors/WarpError.js";
/**
 * Stream transform that CBOR-encodes the value component of [path, data] entries.
 *
 * Input:  `[string, unknown]` — path + domain object
 * Output: `[string, Uint8Array]` — path + CBOR bytes
 */
export class CborEncodeTransform extends Transform {
    _codec;
    constructor(codec) {
        super();
        if (codec === null || codec === undefined) {
            throw new WarpError('CborEncodeTransform requires a codec', 'E_INVALID_DEPENDENCY');
        }
        this._codec = codec;
    }
    async *apply(source) {
        for await (const [path, data] of source) {
            yield [path, this._codec.encode(data)];
        }
    }
}
