aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/jobs.ts
blob: c168b3e919ed1dca50df9f5f29f2114889a846eb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { JobState } from '../../../shared/models'
import { exists } from './misc'
import { jobTypes } from '@server/lib/job-queue/job-queue'

const jobStates: JobState[] = [ 'active', 'completed', 'failed', 'waiting', 'delayed', 'paused', 'waiting-children' ]

function isValidJobState (value: JobState) {
  return exists(value) && jobStates.includes(value)
}

function isValidJobType (value: any) {
  return exists(value) && jobTypes.includes(value)
}

// ---------------------------------------------------------------------------

export {
  jobStates,
  isValidJobState,
  isValidJobType
}