diff options
Diffstat (limited to 'server/models/request/request-interface.ts')
-rw-r--r-- | server/models/request/request-interface.ts | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/server/models/request/request-interface.ts b/server/models/request/request-interface.ts new file mode 100644 index 000000000..70fd734e1 --- /dev/null +++ b/server/models/request/request-interface.ts | |||
@@ -0,0 +1,47 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | |||
3 | import { PodInstance, PodAttributes } from '../pod' | ||
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> {} | ||