summaryrefslogtreecommitdiff
path: root/model/job/index.ts
blob: 473b61a034d306d2cfaac9830e7810e31ddf1236 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { isObject } from '@emprespresso/pengueno';

export type JobArgT = Record<string, string>;
export type JobType = 'fetch_code' | 'ci_pipeline' | 'build_docker_image.js' | 'ansible_playbook.js' | 'checkout_ci.js';
export const JobTypes: Array<JobType> = [
    'fetch_code',
    'ci_pipeline',
    'build_docker_image.js',
    'ansible_playbook.js',
    'checkout_ci.js',
];
export interface Job {
    readonly type: JobType;
    readonly arguments: JobArgT;
}

export const isJobType = (j: unknown): j is JobType => typeof j === 'string' && JobTypes.includes(<JobType>j);

export const isJob = (j: unknown): j is Job =>
    !!(isObject(j) && 'arguments' in j && isObject(j.arguments) && 'type' in j && isJobType(j.type) && j);

export * from './jobs.js';