]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/models/request-interface.ts
Type functions
[github/Chocobozzz/PeerTube.git] / server / models / request-interface.ts
1 import * as Sequelize from 'sequelize'
2
3 import { PodInstance, PodAttributes } from './pod-interface'
4
5 export type RequestsGrouped = {
6 [ podId: number ]: {
7 request: RequestInstance,
8 pod: PodInstance
9 }[]
10 }
11
12 export namespace RequestMethods {
13 export type CountTotalRequestsCallback = (err: Error, total: number) => void
14 export type CountTotalRequests = (callback: CountTotalRequestsCallback) => void
15
16 export type ListWithLimitAndRandomCallback = (err: Error, requestsGrouped?: RequestsGrouped) => void
17 export type ListWithLimitAndRandom = (limitPods, limitRequestsPerPod, callback: ListWithLimitAndRandomCallback) => void
18
19 export type RemoveWithEmptyToCallback = (err: Error) => void
20 export type RemoveWithEmptyTo = (callback: RemoveWithEmptyToCallback) => void
21
22 export type RemoveAllCallback = (err: Error) => void
23 export type RemoveAll = (callback: RemoveAllCallback) => void
24 }
25
26 export interface RequestClass {
27 countTotalRequests: RequestMethods.CountTotalRequests
28 listWithLimitAndRandom: RequestMethods.ListWithLimitAndRandom
29 removeWithEmptyTo: RequestMethods.RemoveWithEmptyTo
30 removeAll: RequestMethods.RemoveAll
31 }
32
33 export interface RequestAttributes {
34 request: object
35 endpoint: string
36 }
37
38 export interface RequestInstance extends RequestClass, RequestAttributes, Sequelize.Instance<RequestAttributes> {
39 id: number
40 createdAt: Date
41 updatedAt: Date
42
43 setPods: Sequelize.HasManySetAssociationsMixin<PodAttributes, number>
44 Pods: PodInstance[]
45 }
46
47 export interface RequestModel extends RequestClass, Sequelize.Model<RequestInstance, RequestAttributes> {}