1 import * as Sequelize from 'sequelize'
3 // Don't use barrel, import just what we need
4 import { Pod as FormatedPod } from '../../../shared/models/pod.model'
6 export namespace PodMethods {
7 export type ToFormatedJSON = () => FormatedPod
9 export type CountAllCallback = (err: Error, total: number) => void
10 export type CountAll = (callback) => void
12 export type IncrementScoresCallback = (err: Error) => void
13 export type IncrementScores = (ids: number[], value: number, callback?: IncrementScoresCallback) => void
15 export type ListCallback = (err: Error, podInstances?: PodInstance[]) => void
16 export type List = (callback: ListCallback) => void
18 export type ListAllIdsCallback = (err: Error, ids?: number[]) => void
19 export type ListAllIds = (transaction: Sequelize.Transaction, callback: ListAllIdsCallback) => void
21 export type ListRandomPodIdsWithRequestCallback = (err: Error, podInstanceIds?: number[]) => void
22 export type ListRandomPodIdsWithRequest = (limit: number, tableWithPods: string, tableWithPodsJoins: string, callback: ListRandomPodIdsWithRequestCallback) => void
24 export type ListBadPodsCallback = (err: Error, podInstances?: PodInstance[]) => void
25 export type ListBadPods = (callback: ListBadPodsCallback) => void
27 export type LoadCallback = (err: Error, podInstance: PodInstance) => void
28 export type Load = (id: number, callback: LoadCallback) => void
30 export type LoadByHostCallback = (err: Error, podInstance: PodInstance) => void
31 export type LoadByHost = (host: string, callback: LoadByHostCallback) => void
33 export type RemoveAllCallback = (err: Error) => void
34 export type RemoveAll = (callback: RemoveAllCallback) => void
36 export type UpdatePodsScore = (goodPods: number[], badPods: number[]) => void
39 export interface PodClass {
40 countAll: PodMethods.CountAll
41 incrementScores: PodMethods.IncrementScores
43 listAllIds: PodMethods.ListAllIds
44 listRandomPodIdsWithRequest: PodMethods.ListRandomPodIdsWithRequest
45 listBadPods: PodMethods.ListBadPods
47 loadByHost: PodMethods.LoadByHost
48 removeAll: PodMethods.RemoveAll
49 updatePodsScore: PodMethods.UpdatePodsScore
52 export interface PodAttributes {
55 score?: number | Sequelize.literal // Sequelize literal for 'score +' + value
59 export interface PodInstance extends PodClass, PodAttributes, Sequelize.Instance<PodAttributes> {
64 toFormatedJSON: PodMethods.ToFormatedJSON,
67 export interface PodModel extends PodClass, Sequelize.Model<PodInstance, PodAttributes> {}