PeerTube/server/models/job/job-interface.ts

34 lines
1.1 KiB
TypeScript
Raw Normal View History

2017-11-30 09:51:13 +00:00
import * as Bluebird from 'bluebird'
2017-05-22 18:58:25 +00:00
import * as Sequelize from 'sequelize'
2017-11-30 09:51:13 +00:00
import { Job as FormattedJob, JobCategory, JobState } from '../../../shared/models/job.model'
import { ResultList } from '../../../shared/models/result-list.model'
2017-06-16 08:36:18 +00:00
2017-05-22 18:58:25 +00:00
export namespace JobMethods {
2017-11-30 09:51:13 +00:00
export type ListWithLimitByCategory = (limit: number, state: JobState, category: JobCategory) => Bluebird<JobInstance[]>
export type ListForApi = (start: number, count: number, sort: string) => Bluebird< ResultList<JobInstance> >
export type ToFormattedJSON = (this: JobInstance) => FormattedJob
2017-05-22 18:58:25 +00:00
}
export interface JobClass {
2017-11-09 16:51:58 +00:00
listWithLimitByCategory: JobMethods.ListWithLimitByCategory
2017-11-30 09:51:13 +00:00
listForApi: JobMethods.ListForApi,
2017-05-22 18:58:25 +00:00
}
export interface JobAttributes {
2017-06-16 08:36:18 +00:00
state: JobState
2017-11-30 09:51:13 +00:00
category: JobCategory
2017-05-22 18:58:25 +00:00
handlerName: string
2017-11-10 16:27:49 +00:00
handlerInputData: any
2017-05-22 18:58:25 +00:00
}
export interface JobInstance extends JobClass, JobAttributes, Sequelize.Instance<JobAttributes> {
id: number
createdAt: Date
updatedAt: Date
2017-11-30 09:51:13 +00:00
toFormattedJSON: JobMethods.ToFormattedJSON
2017-05-22 18:58:25 +00:00
}
export interface JobModel extends JobClass, Sequelize.Model<JobInstance, JobAttributes> {}