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