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