summaryrefslogtreecommitdiff
path: root/model
diff options
context:
space:
mode:
Diffstat (limited to 'model')
-rw-r--r--model/job.ts10
-rw-r--r--model/pipeline.ts26
2 files changed, 22 insertions, 14 deletions
diff --git a/model/job.ts b/model/job.ts
index a3b52dd..52386eb 100644
--- a/model/job.ts
+++ b/model/job.ts
@@ -6,8 +6,14 @@ export interface Job {
readonly arguments: JobArgT;
}
export const isJob = (j: unknown): j is Job =>
- !!(isObject(j) && "arguments" in j && isObject(j.arguments) &&
- "type" in j && typeof j.type === "string" && j);
+ !!(
+ isObject(j) &&
+ "arguments" in j &&
+ isObject(j.arguments) &&
+ "type" in j &&
+ typeof j.type === "string" &&
+ j
+ );
export interface FetchCodeJobProps extends JobArgT {
readonly remoteUrl: string;
diff --git a/model/pipeline.ts b/model/pipeline.ts
index b0db1b7..d7b6435 100644
--- a/model/pipeline.ts
+++ b/model/pipeline.ts
@@ -5,7 +5,9 @@ export interface PipelineStage {
readonly parallelJobs: Array<Job>;
}
export const isPipelineStage = (t: unknown): t is PipelineStage =>
- isObject(t) && "parallelJobs" in t && Array.isArray(t.parallelJobs) &&
+ isObject(t) &&
+ "parallelJobs" in t &&
+ Array.isArray(t.parallelJobs) &&
t.parallelJobs.every((j) => isJob(j));
export interface Pipeline {
@@ -13,7 +15,9 @@ export interface Pipeline {
serialize(): string;
}
export const isPipeline = (t: unknown): t is Pipeline =>
- isObject(t) && "serialJobs" in t && Array.isArray(t.serialJobs) &&
+ isObject(t) &&
+ "serialJobs" in t &&
+ Array.isArray(t.serialJobs) &&
t.serialJobs.every((p) => isPipelineStage(p));
export interface PipelineBuilder {
@@ -29,15 +33,13 @@ export class PipelineImpl implements Pipeline {
}
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));
+ 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));
}
}
@@ -64,7 +66,7 @@ export class DefaultGitHookPipelineBuilder extends BasePipelineBuilder {
this.addStage({
parallelJobs: [
- <FetchCodeJob> {
+ <FetchCodeJob>{
type: "fetch_code",
arguments: {
remoteUrl,