aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/helpers/custom-validators/jobs.ts
blob: f6777ecd51610d6996a0fc6f90ef8763d6b352f1 (plain) (tree)
1
2
3
4
5
6
7

                                                 
                                                          
 
                                                                                                 

                                            




                                                   




                                                                              
            

                  
 
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' ]

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

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

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

export {
  jobStates,
  isValidJobState,
  isValidJobType
}