diff options
author | Elizabeth Hunt <me@liz.coffee> | 2025-07-25 21:21:11 -0700 |
---|---|---|
committer | Elizabeth Hunt <me@liz.coffee> | 2025-07-25 22:08:15 -0700 |
commit | b1efe258974f93616c98485f2bcfb8b999f0e4ad (patch) | |
tree | 41394a0e1c6a0d5e9a4692ab816c10b2fb2a6f74 /model/job | |
parent | 0c3131c650178c5265b9ebeb021c59c86427ae6e (diff) | |
download | ci-b1efe258974f93616c98485f2bcfb8b999f0e4ad.tar.gz ci-b1efe258974f93616c98485f2bcfb8b999f0e4ad.zip |
make jobtype a parameterized type; be smart about locking the vault
Diffstat (limited to 'model/job')
-rw-r--r-- | model/job/index.ts | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/model/job/index.ts b/model/job/index.ts index b7fb3b0..473b61a 100644 --- a/model/job/index.ts +++ b/model/job/index.ts @@ -1,11 +1,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: string; + 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 && typeof j.type === 'string' && j); + !!(isObject(j) && 'arguments' in j && isObject(j.arguments) && 'type' in j && isJobType(j.type) && j); export * from './jobs.js'; |