Synchronous codec for encoding/decoding serialized payload data.
Register a PayloadCodec to transparently transform all serialized
object values (/s{json}) before they are stored and after they are
read. Common use cases: encryption at rest, compression, or custom
binary encoding.
How It Works
The serializer stores JavaScript objects as /s{json}. When a codec
is registered, objects are instead stored as /b{encoded}:
Write: value → JSON.stringify → codec.encode(json) → "/b{encoded}" Read: "/b{encoded}" → codec.decode(encoded) → JSON.parse → value "/s{json}" → JSON.parse → value (backwardcompatible)
Constraints
Synchronous — encode and decode must be synchronous.
Use Node.js crypto (e.g., createCipheriv) or zlib
(e.g., deflateSync) for sync operations.
String-safe — encode output must be a valid UTF-8 string
(Postgres TEXT column). Use base64 encoding for binary output.
Deterministic decode — decode(encode(x)) must equal x.
Scope
The codec applies to all data flowing through the serializer's
package/unpackage path — job state, activity inputs/outputs,
timeline markers, and workflow metadata. It does not apply to
search(), entity(), or enrich() data, which bypass the
serializer.
Synchronous codec for encoding/decoding serialized payload data.
Register a
PayloadCodecto transparently transform all serialized object values (/s{json}) before they are stored and after they are read. Common use cases: encryption at rest, compression, or custom binary encoding.How It Works
The serializer stores JavaScript objects as
/s{json}. When a codec is registered, objects are instead stored as/b{encoded}:Constraints
encodeanddecodemust be synchronous. Use Node.jscrypto(e.g.,createCipheriv) orzlib(e.g.,deflateSync) for sync operations.encodeoutput must be a valid UTF-8 string (Postgres TEXT column). Use base64 encoding for binary output.decode(encode(x))must equalx.Scope
The codec applies to all data flowing through the serializer's
package/unpackagepath — job state, activity inputs/outputs, timeline markers, and workflow metadata. It does not apply tosearch(),entity(), orenrich()data, which bypass the serializer.Example: AES-256-GCM Encryption