]>
Commit | Line | Data |
---|---|---|
e4f97bab | 1 | import * as Bluebird from 'bluebird' |
7a7724e6 C |
2 | import * as Sequelize from 'sequelize' |
3 | import { Account as FormattedAccount, ActivityPubActor } from '../../../shared' | |
4 | import { ResultList } from '../../../shared/models/result-list.model' | |
e4f97bab C |
5 | import { PodInstance } from '../pod/pod-interface' |
6 | import { VideoChannelInstance } from '../video/video-channel-interface' | |
e4f97bab C |
7 | |
8 | export namespace AccountMethods { | |
7a7724e6 C |
9 | export type LoadApplication = () => Bluebird<AccountInstance> |
10 | ||
e4f97bab C |
11 | export type Load = (id: number) => Bluebird<AccountInstance> |
12 | export type LoadByUUID = (uuid: string) => Bluebird<AccountInstance> | |
ce548a10 | 13 | export type LoadByUrl = (url: string, transaction?: Sequelize.Transaction) => Bluebird<AccountInstance> |
e4f97bab | 14 | export type LoadAccountByPodAndUUID = (uuid: string, podId: number, transaction: Sequelize.Transaction) => Bluebird<AccountInstance> |
7a7724e6 | 15 | export type LoadLocalAccountByNameAndPod = (name: string, host: string) => Bluebird<AccountInstance> |
e4f97bab | 16 | export type ListOwned = () => Bluebird<AccountInstance[]> |
8e696487 C |
17 | export type ListAcceptedFollowerUrlsForApi = (id: number, start: number, count?: number) => Promise< ResultList<string> > |
18 | export type ListAcceptedFollowingUrlsForApi = (id: number, start: number, count?: number) => Promise< ResultList<string> > | |
7a7724e6 C |
19 | export type ListFollowingForApi = (id: number, start: number, count: number, sort: string) => Bluebird< ResultList<AccountInstance> > |
20 | export type ListFollowersForApi = (id: number, start: number, count: number, sort: string) => Bluebird< ResultList<AccountInstance> > | |
e4f97bab C |
21 | |
22 | export type ToActivityPubObject = (this: AccountInstance) => ActivityPubActor | |
7a7724e6 | 23 | export type ToFormattedJSON = (this: AccountInstance) => FormattedAccount |
e4f97bab C |
24 | export type IsOwned = (this: AccountInstance) => boolean |
25 | export type GetFollowerSharedInboxUrls = (this: AccountInstance) => Bluebird<string[]> | |
26 | export type GetFollowingUrl = (this: AccountInstance) => string | |
27 | export type GetFollowersUrl = (this: AccountInstance) => string | |
28 | export type GetPublicKeyUrl = (this: AccountInstance) => string | |
29 | } | |
30 | ||
31 | export interface AccountClass { | |
7a7724e6 | 32 | loadApplication: AccountMethods.LoadApplication |
e4f97bab C |
33 | loadAccountByPodAndUUID: AccountMethods.LoadAccountByPodAndUUID |
34 | load: AccountMethods.Load | |
35 | loadByUUID: AccountMethods.LoadByUUID | |
36 | loadByUrl: AccountMethods.LoadByUrl | |
7a7724e6 | 37 | loadLocalAccountByNameAndPod: AccountMethods.LoadLocalAccountByNameAndPod |
e4f97bab | 38 | listOwned: AccountMethods.ListOwned |
8e696487 C |
39 | listAcceptedFollowerUrlsForApi: AccountMethods.ListAcceptedFollowerUrlsForApi |
40 | listAcceptedFollowingUrlsForApi: AccountMethods.ListAcceptedFollowingUrlsForApi | |
7a7724e6 C |
41 | listFollowingForApi: AccountMethods.ListFollowingForApi |
42 | listFollowersForApi: AccountMethods.ListFollowersForApi | |
e4f97bab C |
43 | } |
44 | ||
45 | export interface AccountAttributes { | |
46 | name: string | |
47 | url: string | |
48 | publicKey: string | |
49 | privateKey: string | |
50 | followersCount: number | |
51 | followingCount: number | |
52 | inboxUrl: string | |
53 | outboxUrl: string | |
54 | sharedInboxUrl: string | |
55 | followersUrl: string | |
56 | followingUrl: string | |
57 | ||
58 | uuid?: string | |
59 | ||
60 | podId?: number | |
61 | userId?: number | |
62 | applicationId?: number | |
63 | } | |
64 | ||
65 | export interface AccountInstance extends AccountClass, AccountAttributes, Sequelize.Instance<AccountAttributes> { | |
66 | isOwned: AccountMethods.IsOwned | |
67 | toActivityPubObject: AccountMethods.ToActivityPubObject | |
7a7724e6 | 68 | toFormattedJSON: AccountMethods.ToFormattedJSON |
e4f97bab C |
69 | getFollowerSharedInboxUrls: AccountMethods.GetFollowerSharedInboxUrls |
70 | getFollowingUrl: AccountMethods.GetFollowingUrl | |
71 | getFollowersUrl: AccountMethods.GetFollowersUrl | |
72 | getPublicKeyUrl: AccountMethods.GetPublicKeyUrl | |
73 | ||
74 | id: number | |
75 | createdAt: Date | |
76 | updatedAt: Date | |
77 | ||
78 | Pod: PodInstance | |
79 | VideoChannels: VideoChannelInstance[] | |
80 | } | |
81 | ||
82 | export interface AccountModel extends AccountClass, Sequelize.Model<AccountInstance, AccountAttributes> {} |