]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/models/account/account-interface.ts
Cleanup models
[github/Chocobozzz/PeerTube.git] / server / models / account / account-interface.ts
1 import * as Bluebird from 'bluebird'
2 import * as Sequelize from 'sequelize'
3 import { Account as FormattedAccount, ActivityPubActor } from '../../../shared'
4 import { ServerInstance } from '../server/server-interface'
5 import { VideoChannelInstance } from '../video/video-channel-interface'
6
7 export namespace AccountMethods {
8 export type LoadApplication = () => Bluebird<AccountInstance>
9
10 export type Load = (id: number) => Bluebird<AccountInstance>
11 export type LoadByUUID = (uuid: string) => Bluebird<AccountInstance>
12 export type LoadByUrl = (url: string, transaction?: Sequelize.Transaction) => Bluebird<AccountInstance>
13 export type LoadLocalByName = (name: string) => Bluebird<AccountInstance>
14 export type LoadByNameAndHost = (name: string, host: string) => Bluebird<AccountInstance>
15
16 export type ToActivityPubObject = (this: AccountInstance) => ActivityPubActor
17 export type ToFormattedJSON = (this: AccountInstance) => FormattedAccount
18 export type IsOwned = (this: AccountInstance) => boolean
19 export type GetFollowerSharedInboxUrls = (this: AccountInstance) => Bluebird<string[]>
20 export type GetFollowingUrl = (this: AccountInstance) => string
21 export type GetFollowersUrl = (this: AccountInstance) => string
22 export type GetPublicKeyUrl = (this: AccountInstance) => string
23 }
24
25 export interface AccountClass {
26 loadApplication: AccountMethods.LoadApplication
27 load: AccountMethods.Load
28 loadByUUID: AccountMethods.LoadByUUID
29 loadByUrl: AccountMethods.LoadByUrl
30 loadLocalByName: AccountMethods.LoadLocalByName
31 loadByNameAndHost: AccountMethods.LoadByNameAndHost
32 }
33
34 export interface AccountAttributes {
35 name: string
36 url?: string
37 publicKey: string
38 privateKey: string
39 followersCount: number
40 followingCount: number
41 inboxUrl: string
42 outboxUrl: string
43 sharedInboxUrl: string
44 followersUrl: string
45 followingUrl: string
46
47 uuid?: string
48
49 serverId?: number
50 userId?: number
51 applicationId?: number
52 }
53
54 export interface AccountInstance extends AccountClass, AccountAttributes, Sequelize.Instance<AccountAttributes> {
55 isOwned: AccountMethods.IsOwned
56 toActivityPubObject: AccountMethods.ToActivityPubObject
57 toFormattedJSON: AccountMethods.ToFormattedJSON
58 getFollowerSharedInboxUrls: AccountMethods.GetFollowerSharedInboxUrls
59 getFollowingUrl: AccountMethods.GetFollowingUrl
60 getFollowersUrl: AccountMethods.GetFollowersUrl
61 getPublicKeyUrl: AccountMethods.GetPublicKeyUrl
62
63 id: number
64 createdAt: Date
65 updatedAt: Date
66
67 Server: ServerInstance
68 VideoChannels: VideoChannelInstance[]
69 }
70
71 export interface AccountModel extends AccountClass, Sequelize.Model<AccountInstance, AccountAttributes> {}