]>
Commit | Line | Data |
---|---|---|
e02643f3 C |
1 | import * as Sequelize from 'sequelize' |
2 | ||
69818c93 C |
3 | import { PodInstance, PodAttributes } from './pod-interface' |
4 | ||
5 | export type RequestsGrouped = { | |
6 | [ podId: number ]: { | |
7 | request: RequestInstance, | |
8 | pod: PodInstance | |
9 | }[] | |
10 | } | |
e02643f3 C |
11 | |
12 | export namespace RequestMethods { | |
69818c93 C |
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 | |
e02643f3 C |
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 | ||
69818c93 | 38 | export interface RequestInstance extends RequestClass, RequestAttributes, Sequelize.Instance<RequestAttributes> { |
e02643f3 C |
39 | id: number |
40 | createdAt: Date | |
41 | updatedAt: Date | |
42 | ||
43 | setPods: Sequelize.HasManySetAssociationsMixin<PodAttributes, number> | |
69818c93 | 44 | Pods: PodInstance[] |
e02643f3 C |
45 | } |
46 | ||
47 | export interface RequestModel extends RequestClass, Sequelize.Model<RequestInstance, RequestAttributes> {} |