summaryrefslogtreecommitdiff
path: root/model/job/index.ts
blob: da44528b07e1bf270272e333d337d76366e1f5d0 (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
29
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'
    | 'npm_publish.js';
export const JobTypes: Array<JobType> = [
    'fetch_code',
    'ci_pipeline',
    'build_docker_image.js',
    'ansible_playbook.js',
    'checkout_ci.js',
    'npm_publish.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';