]>
Commit | Line | Data |
---|---|---|
e02643f3 C |
1 | import * as Sequelize from 'sequelize' |
2 | ||
69818c93 C |
3 | // Don't use barrel, import just what we need |
4 | import { Pod as FormatedPod } from '../../shared/models/pod.model' | |
5 | ||
e02643f3 | 6 | export namespace PodMethods { |
69818c93 | 7 | export type ToFormatedJSON = () => FormatedPod |
e02643f3 | 8 | |
69818c93 | 9 | export type CountAllCallback = (err: Error, total: number) => void |
e02643f3 | 10 | export type CountAll = (callback) => void |
69818c93 C |
11 | |
12 | export type IncrementScoresCallback = (err: Error) => void | |
13 | export type IncrementScores = (ids: number[], value: number, callback?: IncrementScoresCallback) => void | |
14 | ||
15 | export type ListCallback = (err: Error, podInstances?: PodInstance[]) => void | |
16 | export type List = (callback: ListCallback) => void | |
17 | ||
18 | export type ListAllIdsCallback = (err: Error, ids?: number[]) => void | |
19 | export type ListAllIds = (transaction: Sequelize.Transaction, callback: ListAllIdsCallback) => void | |
20 | ||
21 | export type ListRandomPodIdsWithRequestCallback = (err: Error, podInstanceIds?: number[]) => void | |
22 | export type ListRandomPodIdsWithRequest = (limit: number, tableWithPods: string, tableWithPodsJoins: string, callback: ListRandomPodIdsWithRequestCallback) => void | |
23 | ||
24 | export type ListBadPodsCallback = (err: Error, podInstances?: PodInstance[]) => void | |
25 | export type ListBadPods = (callback: ListBadPodsCallback) => void | |
26 | ||
27 | export type LoadCallback = (err: Error, podInstance: PodInstance) => void | |
28 | export type Load = (id: number, callback: LoadCallback) => void | |
29 | ||
30 | export type LoadByHostCallback = (err: Error, podInstance: PodInstance) => void | |
31 | export type LoadByHost = (host: string, callback: LoadByHostCallback) => void | |
32 | ||
33 | export type RemoveAllCallback = (err: Error) => void | |
34 | export type RemoveAll = (callback: RemoveAllCallback) => void | |
35 | ||
36 | export type UpdatePodsScore = (goodPods: number[], badPods: number[]) => void | |
e02643f3 C |
37 | } |
38 | ||
39 | export interface PodClass { | |
40 | countAll: PodMethods.CountAll | |
41 | incrementScores: PodMethods.IncrementScores | |
42 | list: PodMethods.List | |
43 | listAllIds: PodMethods.ListAllIds | |
44 | listRandomPodIdsWithRequest: PodMethods.ListRandomPodIdsWithRequest | |
45 | listBadPods: PodMethods.ListBadPods | |
46 | load: PodMethods.Load | |
47 | loadByHost: PodMethods.LoadByHost | |
48 | removeAll: PodMethods.RemoveAll | |
49 | updatePodsScore: PodMethods.UpdatePodsScore | |
50 | } | |
51 | ||
52 | export interface PodAttributes { | |
53 | host?: string | |
54 | publicKey?: string | |
55 | score?: number | Sequelize.literal // Sequelize literal for 'score +' + value | |
56 | email?: string | |
57 | } | |
58 | ||
59 | export interface PodInstance extends PodClass, PodAttributes, Sequelize.Instance<PodAttributes> { | |
60 | id: number | |
61 | createdAt: Date | |
62 | updatedAt: Date | |
63 | ||
64 | toFormatedJSON: PodMethods.ToFormatedJSON, | |
65 | } | |
66 | ||
67 | export interface PodModel extends PodClass, Sequelize.Model<PodInstance, PodAttributes> {} |