]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/models/request/request-video-event-interface.ts
Create types for model enums
[github/Chocobozzz/PeerTube.git] / server / models / request / request-video-event-interface.ts
1 import * as Sequelize from 'sequelize'
2
3 import { VideoInstance } from '../video'
4 import { PodInstance } from '../pod'
5
6 import { RequestVideoEventType } from '../../../shared/models/request-scheduler.model'
7
8 export type RequestsVideoEventGrouped = {
9 [ podId: number ]: {
10 id: number
11 type: RequestVideoEventType
12 count: number
13 video: VideoInstance
14 pod: PodInstance
15 }[]
16 }
17
18 export namespace RequestVideoEventMethods {
19 export type CountTotalRequestsCallback = (err: Error, total: number) => void
20 export type CountTotalRequests = (callback: CountTotalRequestsCallback) => void
21
22 export type ListWithLimitAndRandomCallback = (err: Error, requestsGrouped?: RequestsVideoEventGrouped) => void
23 export type ListWithLimitAndRandom = (limitPods: number, limitRequestsPerPod: number, callback: ListWithLimitAndRandomCallback) => void
24
25 export type RemoveByRequestIdsAndPodCallback = () => void
26 export type RemoveByRequestIdsAndPod = (ids: number[], podId: number, callback: RemoveByRequestIdsAndPodCallback) => void
27
28 export type RemoveAllCallback = () => void
29 export type RemoveAll = (callback: RemoveAllCallback) => void
30 }
31
32 export interface RequestVideoEventClass {
33 countTotalRequests: RequestVideoEventMethods.CountTotalRequests
34 listWithLimitAndRandom: RequestVideoEventMethods.ListWithLimitAndRandom
35 removeByRequestIdsAndPod: RequestVideoEventMethods.RemoveByRequestIdsAndPod
36 removeAll: RequestVideoEventMethods.RemoveAll
37 }
38
39 export interface RequestVideoEventAttributes {
40 type: RequestVideoEventType
41 count: number
42 }
43
44 export interface RequestVideoEventInstance extends RequestVideoEventClass, RequestVideoEventAttributes, Sequelize.Instance<RequestVideoEventAttributes> {
45 id: number
46
47 Video: VideoInstance
48 }
49
50 export interface RequestVideoEventModel extends RequestVideoEventClass, Sequelize.Model<RequestVideoEventInstance, RequestVideoEventAttributes> {}