From d4791f3d357634daf506fb8f91cc5332a794c421 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Fri, 20 Jun 2025 14:53:38 -0700 Subject: Move to nodejs --- model/pipeline/impl.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 model/pipeline/impl.ts (limited to 'model/pipeline/impl.ts') 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) {} + + public serialize() { + return JSON.stringify(this.serialJobs); + } + + public static from(s: string): IEither { + return Either.fromFailable(() => JSON.parse(s)) + .flatMap((eitherPipelineJson) => + isPipeline(eitherPipelineJson) + ? Either.right(eitherPipelineJson) + : Either.left(new Error('oh noes D: its a bad pipewine :((')), + ) + .mapRight((pipeline) => new PipelineImpl(pipeline.serialJobs)); + } +} -- cgit v1.2.3-70-g09d2