WORKFLOW_DESERIALIZE
A symbol used to define custom deserialization for user-defined class instances. The static method should accept serialized data and return a new class instance.
Usage
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);
}
}API Signature
static [WORKFLOW_DESERIALIZE](data: SerializableData): TParameters
| Name | Type | Description |
|---|---|---|
data | SerializableData | The serialized data to reconstruct into a class instance. This is the same data that was returned by WORKFLOW_SERIALIZE. |
Returns
The method should return a new instance of the class, reconstructed from the serialized data.
Requirements
The method must be implemented as a static method on the class. Instance methods are not supported.
- Both
WORKFLOW_SERIALIZEandWORKFLOW_DESERIALIZEmust be implemented together - The method receives the exact data that was returned by
WORKFLOW_SERIALIZE - If
WORKFLOW_SERIALIZEreturns complex types (likeMaporDate), they will be properly deserialized before being passed to this method
This method runs inside the workflow context and is subject to the same constraints as "use workflow" functions:
- No Node.js-specific APIs (like
fs,path,crypto, etc.) - No non-deterministic operations (like
Math.random()orDate.now()) - No external network calls
Keep this method simple and focused on reconstructing the instance from the provided data.