openworkflowdev / openworkflowdev/openworkflow

Custom serializer for step/workflow output

Open
#506 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
1.3k
Forks
66
Avg merge
1d 1h
Merged PRs (30d)
69

Description

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>;
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the BackendSqlite.connect serializer option and the StepApi output typing shown in the issue. Trace how step and workflow output is serialized, then define whether completion means supporting custom serialize/deserialize functions, restricting outputs to JsonValue, or both; verify the Date example and non-serializable output behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
sqlite, typescript
Domain
backend, database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.