The `Codec` interface (#6) ships with `jsonCodec` (pass-through) and `zodCodec` (validate via Zod schema). The original issue noted Avro / Protobuf as out-of-scope for v1.
Scope:
-
`avroCodec(schema)` (peer-dep: `avsc` or similar)
- `encode`: validate + serialize to Avro binary.
- `decode`: deserialize + validate.
- Wire shape: base64-encoded bytes inside the JSON envelope (so journal layers stay JSON-shaped).
-
`protobufCodec(messageType)` (peer-dep: `protobufjs`)
- Same shape: encode/decode via protobuf.js's `MessageType`.
- Wire shape: base64.
-
Both codecs play nicely with `SchemaRegistry` — register the codec instance with the version, the registry handles the rest.
Tests:
- Round-trip a value through the codec.
- Schema mismatch on decode (wrong magic, wrong fields) surfaces a clear error.
- Versioned via `SchemaRegistry`: v1 Avro codec + v2 Protobuf codec coexist (different versions of the same manifest can use different wire formats).
Estimate: 3-5 days.
The `Codec` interface (#6) ships with `jsonCodec` (pass-through) and `zodCodec` (validate via Zod schema). The original issue noted Avro / Protobuf as out-of-scope for v1.
Scope:
`avroCodec(schema)` (peer-dep: `avsc` or similar)
`protobufCodec(messageType)` (peer-dep: `protobufjs`)
Both codecs play nicely with `SchemaRegistry` — register the codec instance with the version, the registry handles the rest.
Tests:
Estimate: 3-5 days.