import type { ServiceMethodFactory } from "@ethicdevs/react-monolith";
import type { Manifest, PipelineServiceDeps } from "./types";
const makeParsePipelineManifest: ServiceMethodFactory<
PipelineServiceDeps,
[string],
Promise<Manifest>
> = () => {
return async (manifestJsonOrYml: string) => {
try {
const m = JSON.parse(manifestJsonOrYml);
return { manifest: manifestJsonOrYml, version: m.version ?? "1.0" };
} catch {
throw new Error("Unsupported manifest format. Provide JSON.");
}
};
};
export default makeParsePipelineManifest;