PeerTube/server/core/helpers/custom-validators/jobs.ts

22 lines
620 B
TypeScript
Raw Normal View History

import { JobState } from '@peertube/peertube-models'
import { jobTypes } from '@server/lib/job-queue/job-queue.js'
import { exists } from './misc.js'
2023-10-12 09:17:53 +02:00
const jobStates = new Set<JobState>([ 'active', 'completed', 'failed', 'waiting', 'delayed', 'paused', 'waiting-children', 'prioritized' ])
function isValidJobState (value: JobState) {
2023-10-12 09:17:53 +02:00
return exists(value) && jobStates.has(value)
2019-12-04 14:49:59 +01:00
}
function isValidJobType (value: any) {
return exists(value) && jobTypes.includes(value)
}
// ---------------------------------------------------------------------------
export {
2020-12-13 19:27:25 +01:00
jobStates,
2019-12-04 14:49:59 +01:00
isValidJobState,
isValidJobType
}