Serialization symbols for custom class serialization in Workflow SDK.
By default, Workflow SDK can serialize standard JavaScript types like primitives, objects, arrays, Date, Map, Set, and more. However, custom class instances are not serializable by default because the serialization system doesn't know how to reconstruct them.
The @workflow/serde package provides two symbols that allow you to define custom serialization and deserialization logic for your classes, enabling them to be passed between workflow and step functions.
import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from "@workflow/serde";
class Point {
constructor(public x: number, public y: number) {}
static [WORKFLOW_SERIALIZE](instance: Point) {
return { x: instance.x, y: instance.y };
}
static [WORKFLOW_DESERIALIZE](data: { x: number; y: number }) {
return new Point(data.x, data.y);
}
}








