diff options
author | Elizabeth Hunt <me@liz.coffee> | 2025-06-20 14:53:38 -0700 |
---|---|---|
committer | Elizabeth Hunt <me@liz.coffee> | 2025-06-20 14:53:38 -0700 |
commit | d4791f3d357634daf506fb8f91cc5332a794c421 (patch) | |
tree | 1bb01d2d4d8fa74d83bb6f99f2c8aa4146ca2d11 /model/pipeline/impl.ts | |
parent | d7e8d31c94cd713a2f4cf799e20e993acc69e361 (diff) | |
download | ci-d4791f3d357634daf506fb8f91cc5332a794c421.tar.gz ci-d4791f3d357634daf506fb8f91cc5332a794c421.zip |
Move to nodejs
Diffstat (limited to 'model/pipeline/impl.ts')
-rw-r--r-- | model/pipeline/impl.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/model/pipeline/impl.ts b/model/pipeline/impl.ts new file mode 100644 index 0000000..2e08d6e --- /dev/null +++ b/model/pipeline/impl.ts @@ -0,0 +1,20 @@ +import { Either, IEither } from '@emprespresso/pengueno'; +import { isPipeline, Pipeline, PipelineStage } from '.'; + +export class PipelineImpl implements Pipeline { + constructor(public readonly serialJobs: Array<PipelineStage>) {} + + public serialize() { + return JSON.stringify(this.serialJobs); + } + + public static from(s: string): IEither<Error, Pipeline> { + return Either.fromFailable<Error, unknown>(() => JSON.parse(s)) + .flatMap<Pipeline>((eitherPipelineJson) => + isPipeline(eitherPipelineJson) + ? Either.right(eitherPipelineJson) + : Either.left(new Error('oh noes D: its a bad pipewine :((')), + ) + .mapRight((pipeline) => new PipelineImpl(pipeline.serialJobs)); + } +} |