import * as Sequelize from 'sequelize' import * as Bluebird from 'bluebird' // Don't use barrel, import just what we need import { AccountInstance } from './account-interface' import { User as FormattedUser } from '../../../shared/models/users/user.model' import { ResultList } from '../../../shared/models/result-list.model' import { UserRight } from '../../../shared/models/users/user-right.enum' import { UserRole } from '../../../shared/models/users/user-role' export namespace UserMethods { export type HasRight = (this: UserInstance, right: UserRight) => boolean export type IsPasswordMatch = (this: UserInstance, password: string) => Promise export type ToFormattedJSON = (this: UserInstance) => FormattedUser export type IsAbleToUploadVideo = (this: UserInstance, videoFile: Express.Multer.File) => Promise export type CountTotal = () => Bluebird export type GetByUsername = (username: string) => Bluebird export type ListForApi = (start: number, count: number, sort: string) => Bluebird< ResultList > export type LoadById = (id: number) => Bluebird export type LoadByUsername = (username: string) => Bluebird export type LoadByUsernameAndPopulateChannels = (username: string) => Bluebird export type LoadByUsernameOrEmail = (username: string, email: string) => Bluebird } export interface UserClass { isPasswordMatch: UserMethods.IsPasswordMatch, toFormattedJSON: UserMethods.ToFormattedJSON, hasRight: UserMethods.HasRight, isAbleToUploadVideo: UserMethods.IsAbleToUploadVideo, countTotal: UserMethods.CountTotal, getByUsername: UserMethods.GetByUsername, listForApi: UserMethods.ListForApi, loadById: UserMethods.LoadById, loadByUsername: UserMethods.LoadByUsername, loadByUsernameAndPopulateChannels: UserMethods.LoadByUsernameAndPopulateChannels, loadByUsernameOrEmail: UserMethods.LoadByUsernameOrEmail } export interface UserAttributes { id?: number password: string username: string email: string displayNSFW?: boolean role: UserRole videoQuota: number Account?: AccountInstance } export interface UserInstance extends UserClass, UserAttributes, Sequelize.Instance { id: number createdAt: Date updatedAt: Date isPasswordMatch: UserMethods.IsPasswordMatch toFormattedJSON: UserMethods.ToFormattedJSON hasRight: UserMethods.HasRight } export interface UserModel extends UserClass, Sequelize.Model {}