Skip to content

Custom serializer for step/workflow output #506

@zihaolam

Description

@zihaolam

Desired Behavior

Currently serializers are using JSON.stringify/JSON.parse. Any plans to support custom serializers to support non serializable json data? Just ran into a gotcha case where Date was serialized to string but still typed as a Date in step output.

Example Usage

const backend = BackendSqlite.connect(dbPath, { serializer: {
    serialize(data) {
        return devalue.stringify(data)
    },
    deserialize(data: string) {
        return devalue.parse(data)
    }
})

If there are no plans to support custom serializers, i guess it might be good to type StepOutputs in a way that makes typescript complain errors when output returned are not serializable

Maybe Output extends JsonValue or something

export interface StepApi {
  run: <Output extends JsonValue>(
    config: Readonly<StepFunctionConfig>,
    fn: StepFunction<Output>,
  ) => Promise<Output>;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions