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

export type JobArgT = Record<string, string>;
export type JobType = 'fetch_code' | 'build_docker_image.js' | 'ansible_playbook.js' | 'checkout_ci.js';
export const JobTypes: Array<JobType> = [
    'fetch_code',
    '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';