summaryrefslogtreecommitdiff
path: root/model/job/index.ts
diff options
context:
space:
mode:
authorElizabeth Hunt <me@liz.coffee>2025-07-25 21:21:11 -0700
committerElizabeth Hunt <me@liz.coffee>2025-07-25 21:28:29 -0700
commitc5322996c19867f3e69aa201d2a4fae69cd99a19 (patch)
tree6da21bb1ebdf53ab33b52d2eadee7e80d64f3007 /model/job/index.ts
parent0c3131c650178c5265b9ebeb021c59c86427ae6e (diff)
downloadci-testci.tar.gz
ci-testci.zip
make jobtype a parameterized type; be smart about locking the vaulttestci
Diffstat (limited to 'model/job/index.ts')
-rw-r--r--model/job/index.ts21
1 files changed, 19 insertions, 2 deletions
diff --git a/model/job/index.ts b/model/job/index.ts
index b7fb3b0..2eea9cf 100644
--- a/model/job/index.ts
+++ b/model/job/index.ts
@@ -1,11 +1,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: 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';