import { Either, IEither } from '@emprespresso/pengueno'; import { isPipeline, Pipeline, PipelineStage } from './index.js'; export class PipelineImpl implements Pipeline { constructor(public readonly serialJobs: Array) {} public serialize() { return JSON.stringify({ serialJobs: 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)); } }