Merge pull request #187 from h3poteto/divide/namespace/entity
Create entity namespace for entities
This commit is contained in:
commit
9a7271ce3e
|
@ -1,10 +1,10 @@
|
|||
import { Mastodon, Instance, Response } from 'megalodon'
|
||||
import { Mastodon, Entity, Response } from 'megalodon'
|
||||
|
||||
const BASE_URL: string = 'http://mastodon.social'
|
||||
console.log('start')
|
||||
|
||||
const client = new Mastodon(BASE_URL)
|
||||
|
||||
client.getInstance().then((res: Response<Instance>) => {
|
||||
client.getInstance().then((res: Response<Entity.Instance>) => {
|
||||
console.log(res)
|
||||
})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Mastodon, Response, Results, isCancel } from 'megalodon'
|
||||
import { Mastodon, Response, Entity, isCancel } from 'megalodon'
|
||||
|
||||
const BASE_URL: string = 'https://pleroma.io'
|
||||
|
||||
|
@ -8,7 +8,7 @@ const client = new Mastodon(BASE_URL, access_token)
|
|||
|
||||
client
|
||||
.search('whalebird', 'hashtags', null, null, null, true)
|
||||
.then((resp: Response<Results>) => {
|
||||
.then((resp: Response<Entity.Results>) => {
|
||||
console.log(resp.data.hashtags)
|
||||
})
|
||||
.catch((err: Error) => {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Mastodon, Status, Response } from 'megalodon'
|
||||
import { Mastodon, Entity, Response } from 'megalodon'
|
||||
|
||||
declare var process: {
|
||||
env: {
|
||||
|
@ -12,7 +12,7 @@ const access_token: string = process.env.MASTODON_ACCESS_TOKEN
|
|||
|
||||
const client = new Mastodon(BASE_URL, access_token)
|
||||
|
||||
client.getFavourites().then((res: Response<Array<Status>>) => {
|
||||
client.getFavourites().then((res: Response<Array<Entity.Status>>) => {
|
||||
console.log(res.headers)
|
||||
console.log(res.data)
|
||||
})
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { Mastodon, Instance, Response } from 'megalodon'
|
||||
import { Mastodon, Entity, Response } from 'megalodon'
|
||||
|
||||
const BASE_URL: string = 'http://mastodon.social'
|
||||
|
||||
const client = new Mastodon(BASE_URL)
|
||||
|
||||
client.getInstance().then((res: Response<Instance>) => {
|
||||
client.getInstance().then((res: Response<Entity.Instance>) => {
|
||||
console.log(res)
|
||||
})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Mastodon, Instance, ProxyConfig, Response } from 'megalodon'
|
||||
import { Mastodon, Entity, ProxyConfig, Response } from 'megalodon'
|
||||
|
||||
declare var process: {
|
||||
env: {
|
||||
|
@ -18,6 +18,6 @@ const proxy: ProxyConfig = {
|
|||
|
||||
const client = new Mastodon(BASE_URL, '', null, proxy)
|
||||
|
||||
client.getInstance().then((res: Response<Instance>) => {
|
||||
client.getInstance().then((res: Response<Entity.Instance>) => {
|
||||
console.log(res)
|
||||
})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Mastodon, Status, Notification, StreamListener, ProxyConfig } from 'megalodon'
|
||||
import { Mastodon, Entity, StreamListener, ProxyConfig } from 'megalodon'
|
||||
|
||||
declare var process: {
|
||||
env: {
|
||||
|
@ -30,11 +30,11 @@ stream.on('not-event-stream', (mes: string) => {
|
|||
console.log(mes)
|
||||
})
|
||||
|
||||
stream.on('update', (status: Status) => {
|
||||
stream.on('update', (status: Entity.Status) => {
|
||||
console.log(status)
|
||||
})
|
||||
|
||||
stream.on('notification', (notification: Notification) => {
|
||||
stream.on('notification', (notification: Entity.Notification) => {
|
||||
console.log(notification)
|
||||
})
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Mastodon, Status, Response, ProxyConfig } from 'megalodon'
|
||||
import { Mastodon, Entity, Response, ProxyConfig } from 'megalodon'
|
||||
|
||||
declare var process: {
|
||||
env: {
|
||||
|
@ -21,6 +21,6 @@ const proxy: ProxyConfig = {
|
|||
|
||||
const client = new Mastodon(BASE_URL, access_token, null, proxy)
|
||||
|
||||
client.getPublicTimeline().then((resp: Response<Array<Status>>) => {
|
||||
client.getPublicTimeline().then((resp: Response<Array<Entity.Status>>) => {
|
||||
console.log(resp.data)
|
||||
})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Mastodon, Status, Notification, WebSocket, ProxyConfig } from 'megalodon'
|
||||
import { Mastodon, Entity, WebSocket, ProxyConfig } from 'megalodon'
|
||||
import log4js from 'log4js'
|
||||
|
||||
declare var process: {
|
||||
|
@ -35,11 +35,11 @@ stream.on('pong', () => {
|
|||
logger.debug('pong')
|
||||
})
|
||||
|
||||
stream.on('update', (status: Status) => {
|
||||
stream.on('update', (status: Entity.Status) => {
|
||||
logger.debug(status)
|
||||
})
|
||||
|
||||
stream.on('notification', (notification: Notification) => {
|
||||
stream.on('notification', (notification: Entity.Notification) => {
|
||||
logger.debug(notification)
|
||||
})
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Mastodon, Status, Notification, StreamListener } from 'megalodon'
|
||||
import { Mastodon, Entity, StreamListener } from 'megalodon'
|
||||
|
||||
declare var process: {
|
||||
env: {
|
||||
|
@ -21,11 +21,11 @@ stream.on('not-event-stream', (mes: string) => {
|
|||
console.log(mes)
|
||||
})
|
||||
|
||||
stream.on('update', (status: Status) => {
|
||||
stream.on('update', (status: Entity.Status) => {
|
||||
console.log(status)
|
||||
})
|
||||
|
||||
stream.on('notification', (notification: Notification) => {
|
||||
stream.on('notification', (notification: Entity.Notification) => {
|
||||
console.log(notification)
|
||||
})
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Mastodon, Status, Response } from 'megalodon'
|
||||
import { Mastodon, Entity, Response } from 'megalodon'
|
||||
|
||||
declare var process: {
|
||||
env: {
|
||||
|
@ -12,6 +12,6 @@ const access_token: string = process.env.MASTODON_ACCESS_TOKEN
|
|||
|
||||
const client = new Mastodon(BASE_URL, access_token)
|
||||
|
||||
client.getPublicTimeline().then((resp: Response<Array<Status>>) => {
|
||||
client.getPublicTimeline().then((resp: Response<Array<Entity.Status>>) => {
|
||||
console.log(resp.data)
|
||||
})
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as readline from 'readline'
|
||||
import { Mastodon, Status, Response } from 'megalodon'
|
||||
import { Mastodon, Entity, Response } from 'megalodon'
|
||||
|
||||
const rl: readline.ReadLine = readline.createInterface({
|
||||
input: process.stdin,
|
||||
|
@ -16,7 +16,7 @@ new Promise(resolve => {
|
|||
rl.question('Toot: ', status => {
|
||||
client
|
||||
.postStatus(status)
|
||||
.then((res: Response<Status>) => {
|
||||
.then((res: Response<Entity.Status>) => {
|
||||
console.log(res)
|
||||
rl.close()
|
||||
resolve(res)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Mastodon, Status, Notification, WebSocket } from 'megalodon'
|
||||
import { Mastodon, Entity, WebSocket } from 'megalodon'
|
||||
import log4js from 'log4js'
|
||||
|
||||
declare var process: {
|
||||
|
@ -26,11 +26,11 @@ stream.on('pong', () => {
|
|||
logger.debug('pong')
|
||||
})
|
||||
|
||||
stream.on('update', (status: Status) => {
|
||||
stream.on('update', (status: Entity.Status) => {
|
||||
logger.debug(status.url)
|
||||
})
|
||||
|
||||
stream.on('notification', (notification: Notification) => {
|
||||
stream.on('notification', (notification: Entity.Notification) => {
|
||||
logger.debug(notification)
|
||||
})
|
||||
|
||||
|
|
|
@ -1,25 +1,26 @@
|
|||
import { Emoji } from './emoji'
|
||||
import { Source } from './source'
|
||||
|
||||
export type Account = {
|
||||
id: string
|
||||
username: string
|
||||
acct: string
|
||||
display_name: string
|
||||
locked: boolean
|
||||
created_at: string
|
||||
followers_count: number
|
||||
following_count: number
|
||||
statuses_count: number
|
||||
note: string
|
||||
url: string
|
||||
avatar: string
|
||||
avatar_static: string
|
||||
header: string
|
||||
header_static: string
|
||||
emojis: Array<Emoji>
|
||||
moved: Account | null
|
||||
fields: object | null
|
||||
bot: boolean | null
|
||||
source?: Source
|
||||
/// <reference path="emoji.ts" />
|
||||
/// <reference path="source.ts" />
|
||||
namespace Entity {
|
||||
export type Account = {
|
||||
id: string
|
||||
username: string
|
||||
acct: string
|
||||
display_name: string
|
||||
locked: boolean
|
||||
created_at: string
|
||||
followers_count: number
|
||||
following_count: number
|
||||
statuses_count: number
|
||||
note: string
|
||||
url: string
|
||||
avatar: string
|
||||
avatar_static: string
|
||||
header: string
|
||||
header_static: string
|
||||
emojis: Array<Emoji>
|
||||
moved: Account | null
|
||||
fields: object | null
|
||||
bot: boolean | null
|
||||
source?: Source
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
export type Activity = {
|
||||
week: string
|
||||
statuses: string
|
||||
logins: string
|
||||
registrations: string
|
||||
namespace Entity {
|
||||
export type Activity = {
|
||||
week: string
|
||||
statuses: string
|
||||
logins: string
|
||||
registrations: string
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
export type Application = {
|
||||
name: string
|
||||
website?: string | null
|
||||
vapid_key?: string | null
|
||||
namespace Entity {
|
||||
export type Application = {
|
||||
name: string
|
||||
website?: string | null
|
||||
vapid_key?: string | null
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
export type Attachment = {
|
||||
id: string
|
||||
type: 'unknown' | 'image' | 'gifv' | 'video'
|
||||
url: string
|
||||
remote_url: string | null
|
||||
preview_url: string
|
||||
text_url: string | null
|
||||
meta: object | null
|
||||
description: string | null
|
||||
namespace Entity {
|
||||
export type Attachment = {
|
||||
id: string
|
||||
type: 'unknown' | 'image' | 'gifv' | 'video'
|
||||
url: string
|
||||
remote_url: string | null
|
||||
preview_url: string
|
||||
text_url: string | null
|
||||
meta: object | null
|
||||
description: string | null
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
export type Card = {
|
||||
url: string
|
||||
title: string
|
||||
description: string
|
||||
image: string | null
|
||||
type: 'link' | 'photo' | 'video' | 'rich'
|
||||
author_name: string | null
|
||||
author_url: string | null
|
||||
provider_name: string | null
|
||||
provider_url: string | null
|
||||
html: string | null
|
||||
width: number | null
|
||||
height: number | null
|
||||
namespace Entity {
|
||||
export type Card = {
|
||||
url: string
|
||||
title: string
|
||||
description: string
|
||||
image: string | null
|
||||
type: 'link' | 'photo' | 'video' | 'rich'
|
||||
author_name: string | null
|
||||
author_url: string | null
|
||||
provider_name: string | null
|
||||
provider_url: string | null
|
||||
html: string | null
|
||||
width: number | null
|
||||
height: number | null
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import { Status } from './status'
|
||||
/// <reference path="status.ts" />
|
||||
|
||||
export type Context = {
|
||||
ancestors: Array<Status>
|
||||
descendants: Array<Status>
|
||||
namespace Entity {
|
||||
export type Context = {
|
||||
ancestors: Array<Status>
|
||||
descendants: Array<Status>
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import { Account } from './account'
|
||||
import { Status } from './status'
|
||||
/// <reference path="account.ts" />
|
||||
/// <reference path="status.ts" />
|
||||
|
||||
export type Conversation = {
|
||||
id: string
|
||||
accounts: Array<Account>
|
||||
last_status: Status | null
|
||||
unread: boolean
|
||||
namespace Entity {
|
||||
export type Conversation = {
|
||||
id: string
|
||||
accounts: Array<Account>
|
||||
last_status: Status | null
|
||||
unread: boolean
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
export type Emoji = {
|
||||
shortcode: string
|
||||
static_url: string
|
||||
url: string
|
||||
visible_in_picker: boolean
|
||||
namespace Entity {
|
||||
export type Emoji = {
|
||||
shortcode: string
|
||||
static_url: string
|
||||
url: string
|
||||
visible_in_picker: boolean
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
export type FeaturedTag = {
|
||||
id: string
|
||||
name: string
|
||||
statuses_count: number
|
||||
last_status_at: string
|
||||
namespace Entity {
|
||||
export type FeaturedTag = {
|
||||
id: string
|
||||
name: string
|
||||
statuses_count: number
|
||||
last_status_at: string
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
export type Field = {
|
||||
name: string
|
||||
value: string
|
||||
verified_at: string | null
|
||||
namespace Entity {
|
||||
export type Field = {
|
||||
name: string
|
||||
value: string
|
||||
verified_at: string | null
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
export type Filter = {
|
||||
id: string
|
||||
phrase: string
|
||||
context: Array<string>
|
||||
expires_at: string | null
|
||||
irreversible: boolean
|
||||
whole_word: boolean
|
||||
namespace Entity {
|
||||
export type Filter = {
|
||||
id: string
|
||||
phrase: string
|
||||
context: Array<string>
|
||||
expires_at: string | null
|
||||
irreversible: boolean
|
||||
whole_word: boolean
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
export type History = {
|
||||
day: string
|
||||
uses: number
|
||||
accounts: number
|
||||
namespace Entity {
|
||||
export type History = {
|
||||
day: string
|
||||
uses: number
|
||||
accounts: number
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
export type IdentityProof = {
|
||||
provider: string
|
||||
provider_username: string
|
||||
updated_at: string
|
||||
proof_url: string
|
||||
profile_url: string
|
||||
namespace Entity {
|
||||
export type IdentityProof = {
|
||||
provider: string
|
||||
provider_username: string
|
||||
updated_at: string
|
||||
proof_url: string
|
||||
profile_url: string
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,20 @@
|
|||
import { Account } from './account'
|
||||
import { URLs } from './urls'
|
||||
import { Stats } from './stats'
|
||||
/// <reference path="account.ts" />
|
||||
/// <reference path="urls.ts" />
|
||||
/// <reference path="stats.ts" />
|
||||
|
||||
export type Instance = {
|
||||
uri: string
|
||||
title: string
|
||||
description: string
|
||||
email: string
|
||||
version: string
|
||||
thumbnail: string | null
|
||||
urls: URLs
|
||||
stats: Stats
|
||||
languages: Array<string>
|
||||
contact_account: Account | null
|
||||
max_toot_chars?: number
|
||||
registrations?: boolean
|
||||
namespace Entity {
|
||||
export type Instance = {
|
||||
uri: string
|
||||
title: string
|
||||
description: string
|
||||
email: string
|
||||
version: string
|
||||
thumbnail: string | null
|
||||
urls: URLs
|
||||
stats: Stats
|
||||
languages: Array<string>
|
||||
contact_account: Account | null
|
||||
max_toot_chars?: number
|
||||
registrations?: boolean
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
export type List = {
|
||||
id: string
|
||||
title: string
|
||||
namespace Entity {
|
||||
export type List = {
|
||||
id: string
|
||||
title: string
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
export type Marker = {
|
||||
home: {
|
||||
last_read_id: string
|
||||
version: number
|
||||
updated_at: string
|
||||
}
|
||||
notifications: {
|
||||
last_read_id: string
|
||||
version: number
|
||||
updated_at: string
|
||||
namespace Entity {
|
||||
export type Marker = {
|
||||
home: {
|
||||
last_read_id: string
|
||||
version: number
|
||||
updated_at: string
|
||||
}
|
||||
notifications: {
|
||||
last_read_id: string
|
||||
version: number
|
||||
updated_at: string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
export type Mention = {
|
||||
id: string
|
||||
username: string
|
||||
url: string
|
||||
acct: string
|
||||
namespace Entity {
|
||||
export type Mention = {
|
||||
id: string
|
||||
username: string
|
||||
url: string
|
||||
acct: string
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import { Account } from './account'
|
||||
import { Status } from './status'
|
||||
/// <reference path="account.ts" />
|
||||
/// <reference path="status.ts" />
|
||||
|
||||
export type Notification = {
|
||||
account: Account
|
||||
created_at: string
|
||||
id: string
|
||||
status: Status | null
|
||||
type: 'mention' | 'reblog' | 'favourite' | 'follow'
|
||||
namespace Entity {
|
||||
export type Notification = {
|
||||
account: Account
|
||||
created_at: string
|
||||
id: string
|
||||
status: Status | null
|
||||
type: 'mention' | 'reblog' | 'favourite' | 'follow'
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
import { PollOption } from './poll_option'
|
||||
/// <reference path="poll_option.ts" />
|
||||
|
||||
export type Poll = {
|
||||
id: string
|
||||
expires_at: string | null
|
||||
expired: boolean
|
||||
multiple: boolean
|
||||
votes_count: number
|
||||
options: Array<PollOption>
|
||||
voted: boolean
|
||||
namespace Entity {
|
||||
export type Poll = {
|
||||
id: string
|
||||
expires_at: string | null
|
||||
expired: boolean
|
||||
multiple: boolean
|
||||
votes_count: number
|
||||
options: Array<PollOption>
|
||||
voted: boolean
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
export type PollOption = {
|
||||
title: string
|
||||
votes_count: number | null
|
||||
namespace Entity {
|
||||
export type PollOption = {
|
||||
title: string
|
||||
votes_count: number | null
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
export type Preferences = {
|
||||
'posting:default:visibility': 'public' | 'unlisted' | 'private' | 'direct'
|
||||
'posting:default:sensitive': boolean
|
||||
'posting:default:language': string | null
|
||||
'reading:expand:media': 'default' | 'show_all' | 'hide_all'
|
||||
'reading:expand:spoilers': boolean
|
||||
namespace Entity {
|
||||
export type Preferences = {
|
||||
'posting:default:visibility': 'public' | 'unlisted' | 'private' | 'direct'
|
||||
'posting:default:sensitive': boolean
|
||||
'posting:default:language': string | null
|
||||
'reading:expand:media': 'default' | 'show_all' | 'hide_all'
|
||||
'reading:expand:spoilers': boolean
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
export type PushSubscription = {
|
||||
id: string
|
||||
endpoint: string
|
||||
server_key: string
|
||||
alerts: object
|
||||
namespace Entity {
|
||||
export type PushSubscription = {
|
||||
id: string
|
||||
endpoint: string
|
||||
server_key: string
|
||||
alerts: object
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
export type Relationship = {
|
||||
id: string
|
||||
following: boolean
|
||||
followed_by: boolean
|
||||
blocking: boolean
|
||||
muting: boolean
|
||||
muting_notifications: boolean
|
||||
requested: boolean
|
||||
domain_blocking: boolean
|
||||
showing_reblogs: boolean
|
||||
endorsed: boolean
|
||||
namespace Entity {
|
||||
export type Relationship = {
|
||||
id: string
|
||||
following: boolean
|
||||
followed_by: boolean
|
||||
blocking: boolean
|
||||
muting: boolean
|
||||
muting_notifications: boolean
|
||||
requested: boolean
|
||||
domain_blocking: boolean
|
||||
showing_reblogs: boolean
|
||||
endorsed: boolean
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
export type Report = {
|
||||
id: string
|
||||
action_taken: string
|
||||
comment: string
|
||||
account_id: string
|
||||
status_ids: Array<string>
|
||||
namespace Entity {
|
||||
export type Report = {
|
||||
id: string
|
||||
action_taken: string
|
||||
comment: string
|
||||
account_id: string
|
||||
status_ids: Array<string>
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import { Account } from './account'
|
||||
import { Status } from './status'
|
||||
import { Tag } from './tag'
|
||||
/// <reference path="account.ts" />
|
||||
/// <reference path="status.ts" />
|
||||
/// <reference path="tag.ts" />
|
||||
|
||||
export type Results = {
|
||||
accounts: Array<Account>
|
||||
statuses: Array<Status>
|
||||
hashtags: Array<Tag>
|
||||
namespace Entity {
|
||||
export type Results = {
|
||||
accounts: Array<Account>
|
||||
statuses: Array<Status>
|
||||
hashtags: Array<Tag>
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import { Attachment } from './attachment'
|
||||
// <reference path="attachment.ts" />
|
||||
|
||||
export type ScheduledStatus = {
|
||||
id: string
|
||||
scheduled_at: string
|
||||
params: object
|
||||
media_attachments: Array<Attachment>
|
||||
namespace Entity {
|
||||
export type ScheduledStatus = {
|
||||
id: string
|
||||
scheduled_at: string
|
||||
params: object
|
||||
media_attachments: Array<Attachment>
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
export type Source = {
|
||||
privacy: string | null
|
||||
sensitive: boolean | null
|
||||
language: string | null
|
||||
note: string
|
||||
fields: object
|
||||
namespace Entity {
|
||||
export type Source = {
|
||||
privacy: string | null
|
||||
sensitive: boolean | null
|
||||
language: string | null
|
||||
note: string
|
||||
fields: object
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
export type Stats = {
|
||||
user_count: number
|
||||
status_count: number
|
||||
domain_count: number
|
||||
namespace Entity {
|
||||
export type Stats = {
|
||||
user_count: number
|
||||
status_count: number
|
||||
domain_count: number
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,38 +1,40 @@
|
|||
import { Account } from './account'
|
||||
import { Application } from './application'
|
||||
import { Mention } from './mention'
|
||||
import { Tag } from './tag'
|
||||
import { Attachment } from './attachment'
|
||||
import { Emoji } from './emoji'
|
||||
import { Card } from './card'
|
||||
import { Poll } from './poll'
|
||||
/// <reference path="account.ts" />
|
||||
/// <reference path="application.ts" />
|
||||
/// <reference path="mention.ts" />
|
||||
/// <reference path="tag.ts" />
|
||||
/// <reference path="attachment.ts" />
|
||||
/// <reference path="emoji.ts" />
|
||||
/// <reference path="card.ts" />
|
||||
/// <reference path="poll.ts" />
|
||||
|
||||
export type Status = {
|
||||
id: string
|
||||
uri: string
|
||||
url: string
|
||||
account: Account
|
||||
in_reply_to_id: string | null
|
||||
in_reply_to_account_id: string | null
|
||||
reblog: Status | null
|
||||
content: string
|
||||
created_at: string
|
||||
emojis: Emoji[]
|
||||
replies_count: number
|
||||
reblogs_count: number
|
||||
favourites_count: number
|
||||
reblogged: boolean | null
|
||||
favourited: boolean | null
|
||||
muted: boolean | null
|
||||
sensitive: boolean
|
||||
spoiler_text: string
|
||||
visibility: 'public' | 'unlisted' | 'private' | 'direct'
|
||||
media_attachments: Array<Attachment>
|
||||
mentions: Array<Mention>
|
||||
tags: Array<Tag>
|
||||
card: Card | null
|
||||
poll: Poll | null
|
||||
application: Application
|
||||
language: string | null
|
||||
pinned: boolean | null
|
||||
namespace Entity {
|
||||
export type Status = {
|
||||
id: string
|
||||
uri: string
|
||||
url: string
|
||||
account: Account
|
||||
in_reply_to_id: string | null
|
||||
in_reply_to_account_id: string | null
|
||||
reblog: Status | null
|
||||
content: string
|
||||
created_at: string
|
||||
emojis: Emoji[]
|
||||
replies_count: number
|
||||
reblogs_count: number
|
||||
favourites_count: number
|
||||
reblogged: boolean | null
|
||||
favourited: boolean | null
|
||||
muted: boolean | null
|
||||
sensitive: boolean
|
||||
spoiler_text: string
|
||||
visibility: 'public' | 'unlisted' | 'private' | 'direct'
|
||||
media_attachments: Array<Attachment>
|
||||
mentions: Array<Mention>
|
||||
tags: Array<Tag>
|
||||
card: Card | null
|
||||
poll: Poll | null
|
||||
application: Application
|
||||
language: string | null
|
||||
pinned: boolean | null
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
export type StatusParams = {
|
||||
text: string
|
||||
in_reply_to_id: string | null
|
||||
media_ids: Array<string> | null
|
||||
sensitive: boolean | null
|
||||
spoiler_text: string | null
|
||||
visibility: 'public' | 'unlisted' | 'private' | 'direct'
|
||||
scheduled_at: string | null
|
||||
application_id: string
|
||||
namespace Entity {
|
||||
export type StatusParams = {
|
||||
text: string
|
||||
in_reply_to_id: string | null
|
||||
media_ids: Array<string> | null
|
||||
sensitive: boolean | null
|
||||
spoiler_text: string | null
|
||||
visibility: 'public' | 'unlisted' | 'private' | 'direct'
|
||||
scheduled_at: string | null
|
||||
application_id: string
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import { History } from './history'
|
||||
/// <reference path="history.ts" />
|
||||
|
||||
export type Tag = {
|
||||
name: string
|
||||
url: string
|
||||
history: Array<History> | null
|
||||
namespace Entity {
|
||||
export type Tag = {
|
||||
name: string
|
||||
url: string
|
||||
history: Array<History> | null
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
export type Token = {
|
||||
access_token: string
|
||||
token_type: string
|
||||
scope: string
|
||||
created_at: number
|
||||
namespace Entity {
|
||||
export type Token = {
|
||||
access_token: string
|
||||
token_type: string
|
||||
scope: string
|
||||
created_at: number
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
export type URLs = {
|
||||
streaming_api: string
|
||||
namespace Entity {
|
||||
export type URLs = {
|
||||
streaming_api: string
|
||||
}
|
||||
}
|
||||
|
|
35
src/entity.ts
Normal file
35
src/entity.ts
Normal file
|
@ -0,0 +1,35 @@
|
|||
/// <reference path="./entities/account.ts" />
|
||||
/// <reference path="./entities/activity.ts" />
|
||||
/// <reference path="./entities/application.ts" />
|
||||
/// <reference path="./entities/attachment.ts" />
|
||||
/// <reference path="./entities/card.ts" />
|
||||
/// <reference path="./entities/context.ts" />
|
||||
/// <reference path="./entities/conversation.ts" />
|
||||
/// <reference path="./entities/emoji.ts" />
|
||||
/// <reference path="./entities/featured_tag.ts" />
|
||||
/// <reference path="./entities/field.ts" />
|
||||
/// <reference path="./entities/filter.ts" />
|
||||
/// <reference path="./entities/history.ts" />
|
||||
/// <reference path="./entities/identity_proof.ts" />
|
||||
/// <reference path="./entities/instance.ts" />
|
||||
/// <reference path="./entities/list.ts" />
|
||||
/// <reference path="./entities/marker.ts" />
|
||||
/// <reference path="./entities/mention.ts" />
|
||||
/// <reference path="./entities/notification.ts" />
|
||||
/// <reference path="./entities/poll.ts" />
|
||||
/// <reference path="./entities/poll_option.ts" />
|
||||
/// <reference path="./entities/preferences.ts" />
|
||||
/// <reference path="./entities/push_subscription.ts" />
|
||||
/// <reference path="./entities/relationship.ts" />
|
||||
/// <reference path="./entities/report.ts" />
|
||||
/// <reference path="./entities/results.ts" />
|
||||
/// <reference path="./entities/scheduled_status.ts" />
|
||||
/// <reference path="./entities/source.ts" />
|
||||
/// <reference path="./entities/stats.ts" />
|
||||
/// <reference path="./entities/status.ts" />
|
||||
/// <reference path="./entities/status_params.ts" />
|
||||
/// <reference path="./entities/tag.ts" />
|
||||
/// <reference path="./entities/token.ts" />
|
||||
/// <reference path="./entities/urls.ts" />
|
||||
|
||||
export default Entity
|
62
src/index.ts
62
src/index.ts
|
@ -9,36 +9,7 @@ import { ProxyConfig } from './proxy_config'
|
|||
import generator, { MegalodonInterface } from './megalodon'
|
||||
import Mastodon from './mastodon'
|
||||
import Pleroma from './pleroma'
|
||||
/**
|
||||
* Entities
|
||||
*/
|
||||
import { Account } from './entities/account'
|
||||
import { Application } from './entities/application'
|
||||
import { Attachment } from './entities/attachment'
|
||||
import { Card } from './entities/card'
|
||||
import { Context } from './entities/context'
|
||||
import { Conversation } from './entities/conversation'
|
||||
import { Emoji } from './entities/emoji'
|
||||
import { Field } from './entities/field'
|
||||
import { Filter } from './entities/filter'
|
||||
import { History } from './entities/history'
|
||||
import { Instance } from './entities/instance'
|
||||
import { List } from './entities/list'
|
||||
import { Mention } from './entities/mention'
|
||||
import { Notification } from './entities/notification'
|
||||
import { Poll } from './entities/poll'
|
||||
import { PollOption } from './entities/poll_option'
|
||||
import { PushSubscription } from './entities/push_subscription'
|
||||
import { Relationship } from './entities/relationship'
|
||||
import { Results } from './entities/results'
|
||||
import { ScheduledStatus } from './entities/scheduled_status'
|
||||
import { Source } from './entities/source'
|
||||
import { Stats } from './entities/stats'
|
||||
import { Status } from './entities/status'
|
||||
import { StatusParams } from './entities/status_params'
|
||||
import { Tag } from './entities/tag'
|
||||
import { Token } from './entities/token'
|
||||
import { URLs } from './entities/urls'
|
||||
import Entity from './entity'
|
||||
|
||||
export {
|
||||
MastodonAPI,
|
||||
|
@ -53,36 +24,7 @@ export {
|
|||
MegalodonInterface,
|
||||
Mastodon,
|
||||
Pleroma,
|
||||
/**
|
||||
* Entities
|
||||
*/
|
||||
Account,
|
||||
Application,
|
||||
Attachment,
|
||||
Card,
|
||||
Context,
|
||||
Conversation,
|
||||
Emoji,
|
||||
Field,
|
||||
Filter,
|
||||
History,
|
||||
Instance,
|
||||
List,
|
||||
Mention,
|
||||
Notification,
|
||||
Poll,
|
||||
PollOption,
|
||||
PushSubscription,
|
||||
Relationship,
|
||||
Results,
|
||||
ScheduledStatus,
|
||||
Source,
|
||||
Stats,
|
||||
Status,
|
||||
StatusParams,
|
||||
Tag,
|
||||
Token,
|
||||
URLs
|
||||
Entity
|
||||
}
|
||||
|
||||
export default generator
|
||||
|
|
386
src/mastodon.ts
386
src/mastodon.ts
|
@ -6,30 +6,7 @@ import Response from './response'
|
|||
import StreamListener from './stream_listener'
|
||||
import WebSocket from './web_socket'
|
||||
import { MegalodonInterface, NoImplementedError } from './megalodon'
|
||||
import { Application } from './entities/application'
|
||||
import { Account } from './entities/account'
|
||||
import { Status } from './entities/status'
|
||||
import { List } from './entities/list'
|
||||
import { IdentityProof } from './entities/identity_proof'
|
||||
import { Relationship } from './entities/relationship'
|
||||
import { Filter } from './entities/filter'
|
||||
import { Report } from './entities/report'
|
||||
import { FeaturedTag } from './entities/featured_tag'
|
||||
import { Tag } from './entities/tag'
|
||||
import { Preferences } from './entities/preferences'
|
||||
import { Context } from './entities/context'
|
||||
import { Attachment } from './entities/attachment'
|
||||
import { Poll } from './entities/poll'
|
||||
import { ScheduledStatus } from './entities/scheduled_status'
|
||||
import { Conversation } from './entities/conversation'
|
||||
import { Marker } from './entities/marker'
|
||||
import { Notification } from './entities/notification'
|
||||
import { Results } from './entities/results'
|
||||
import { Instance } from './entities/instance'
|
||||
import { Activity } from './entities/activity'
|
||||
import { Emoji } from './entities/emoji'
|
||||
import { PushSubscription } from './entities/push_subscription'
|
||||
import { Token } from './entities/token'
|
||||
import Entity from './entity'
|
||||
|
||||
const NO_REDIRECT = 'urn:ietf:wg:oauth:2.0:oob'
|
||||
const DEFAULT_SCOPE = 'read write follow'
|
||||
|
@ -149,8 +126,8 @@ export default class Mastodon implements MegalodonInterface {
|
|||
// ======================================
|
||||
// apps
|
||||
// ======================================
|
||||
public verifyAppCredentials(): Promise<Response<Application>> {
|
||||
return this.client.get<Application>('/api/v1/apps/verify_credentials')
|
||||
public verifyAppCredentials(): Promise<Response<Entity.Application>> {
|
||||
return this.client.get<Entity.Application>('/api/v1/apps/verify_credentials')
|
||||
}
|
||||
|
||||
// ======================================
|
||||
|
@ -202,7 +179,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
agreement: boolean,
|
||||
locale: string,
|
||||
reason?: string | null
|
||||
): Promise<Response<Token>> {
|
||||
): Promise<Response<Entity.Token>> {
|
||||
let params = {
|
||||
username: username,
|
||||
email: email,
|
||||
|
@ -215,11 +192,11 @@ export default class Mastodon implements MegalodonInterface {
|
|||
reason: reason
|
||||
})
|
||||
}
|
||||
return this.client.post<Token>('/api/v1/accounts', params)
|
||||
return this.client.post<Entity.Token>('/api/v1/accounts', params)
|
||||
}
|
||||
|
||||
public verifyAccountCredentials(): Promise<Response<Account>> {
|
||||
return this.client.get<Account>('/api/v1/accounts/verify_credentials')
|
||||
public verifyAccountCredentials(): Promise<Response<Entity.Account>> {
|
||||
return this.client.get<Entity.Account>('/api/v1/accounts/verify_credentials')
|
||||
}
|
||||
|
||||
public updateCredentials(
|
||||
|
@ -236,7 +213,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
language?: string
|
||||
} | null,
|
||||
fields_attributes?: Array<{ name: string; value: string }>
|
||||
): Promise<Response<Account>> {
|
||||
): Promise<Response<Entity.Account>> {
|
||||
let params = {}
|
||||
if (discoverable) {
|
||||
params = Object.assign(params, {
|
||||
|
@ -283,25 +260,25 @@ export default class Mastodon implements MegalodonInterface {
|
|||
fields_attributes: fields_attributes
|
||||
})
|
||||
}
|
||||
return this.client.patch<Account>('/api/v1/accounts/update_credentials', params)
|
||||
return this.client.patch<Entity.Account>('/api/v1/accounts/update_credentials', params)
|
||||
}
|
||||
|
||||
public getAccount(id: string): Promise<Response<Account>> {
|
||||
return this.client.get<Account>(`/api/v1/accounts/${id}`)
|
||||
public getAccount(id: string): Promise<Response<Entity.Account>> {
|
||||
return this.client.get<Entity.Account>(`/api/v1/accounts/${id}`)
|
||||
}
|
||||
|
||||
public getAccountStatuses(id: string): Promise<Response<Array<Status>>> {
|
||||
return this.client.get<Array<Status>>(`/api/v1/accounts/${id}/statuses`)
|
||||
public getAccountStatuses(id: string): Promise<Response<Array<Entity.Status>>> {
|
||||
return this.client.get<Array<Entity.Status>>(`/api/v1/accounts/${id}/statuses`)
|
||||
}
|
||||
|
||||
public subscribeAccount(_id: string): Promise<Response<Relationship>> {
|
||||
public subscribeAccount(_id: string): Promise<Response<Entity.Relationship>> {
|
||||
return new Promise((_, reject) => {
|
||||
const err = new NoImplementedError('mastodon does not support')
|
||||
reject(err)
|
||||
})
|
||||
}
|
||||
|
||||
public unsubscribeAccount(_id: string): Promise<Response<Relationship>> {
|
||||
public unsubscribeAccount(_id: string): Promise<Response<Entity.Relationship>> {
|
||||
return new Promise((_, reject) => {
|
||||
const err = new NoImplementedError('mastodon does not support')
|
||||
reject(err)
|
||||
|
@ -313,7 +290,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
_limit?: number | null,
|
||||
_max_id?: string | null,
|
||||
_since_id?: string | null
|
||||
): Promise<Response<Array<Status>>> {
|
||||
): Promise<Response<Array<Entity.Status>>> {
|
||||
return new Promise((_, reject) => {
|
||||
const err = new NoImplementedError('mastodon does not support')
|
||||
reject(err)
|
||||
|
@ -325,7 +302,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
limit?: number | null,
|
||||
max_id?: string | null,
|
||||
since_id?: string | null
|
||||
): Promise<Response<Array<Account>>> {
|
||||
): Promise<Response<Array<Entity.Account>>> {
|
||||
let params = {}
|
||||
if (max_id) {
|
||||
params = Object.assign(params, {
|
||||
|
@ -342,7 +319,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
limit: limit
|
||||
})
|
||||
}
|
||||
return this.client.get<Array<Account>>(`/api/v1/accounts/${id}/followers`, params)
|
||||
return this.client.get<Array<Entity.Account>>(`/api/v1/accounts/${id}/followers`, params)
|
||||
}
|
||||
|
||||
public getAccountFollowing(
|
||||
|
@ -350,7 +327,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
limit?: number | null,
|
||||
max_id?: string | null,
|
||||
since_id?: string | null
|
||||
): Promise<Response<Array<Account>>> {
|
||||
): Promise<Response<Array<Entity.Account>>> {
|
||||
let params = {}
|
||||
if (max_id) {
|
||||
params = Object.assign(params, {
|
||||
|
@ -367,55 +344,55 @@ export default class Mastodon implements MegalodonInterface {
|
|||
limit: limit
|
||||
})
|
||||
}
|
||||
return this.client.get<Array<Account>>(`/api/v1/accounts/${id}/following`, params)
|
||||
return this.client.get<Array<Entity.Account>>(`/api/v1/accounts/${id}/following`, params)
|
||||
}
|
||||
|
||||
public getAccountLists(id: string): Promise<Response<Array<List>>> {
|
||||
return this.client.get<Array<List>>(`/api/v1/accounts/${id}/lists`)
|
||||
public getAccountLists(id: string): Promise<Response<Array<Entity.List>>> {
|
||||
return this.client.get<Array<Entity.List>>(`/api/v1/accounts/${id}/lists`)
|
||||
}
|
||||
|
||||
public getIdentityProof(id: string): Promise<Response<Array<IdentityProof>>> {
|
||||
return this.client.get<Array<IdentityProof>>(`/api/v1/accounts/${id}/identity_proofs`)
|
||||
public getIdentityProof(id: string): Promise<Response<Array<Entity.IdentityProof>>> {
|
||||
return this.client.get<Array<Entity.IdentityProof>>(`/api/v1/accounts/${id}/identity_proofs`)
|
||||
}
|
||||
|
||||
public followAccount(id: string, reblog: boolean = true): Promise<Response<Relationship>> {
|
||||
return this.client.post<Relationship>(`/api/v1/accounts/${id}/follow`, {
|
||||
public followAccount(id: string, reblog: boolean = true): Promise<Response<Entity.Relationship>> {
|
||||
return this.client.post<Entity.Relationship>(`/api/v1/accounts/${id}/follow`, {
|
||||
reblog: reblog
|
||||
})
|
||||
}
|
||||
|
||||
public unfollowAccount(id: string): Promise<Response<Relationship>> {
|
||||
return this.client.post<Relationship>(`/api/v1/accounts/${id}/unfollow`)
|
||||
public unfollowAccount(id: string): Promise<Response<Entity.Relationship>> {
|
||||
return this.client.post<Entity.Relationship>(`/api/v1/accounts/${id}/unfollow`)
|
||||
}
|
||||
|
||||
public blockAccount(id: string): Promise<Response<Relationship>> {
|
||||
return this.client.post<Relationship>(`/api/v1/accounts/${id}/block`)
|
||||
public blockAccount(id: string): Promise<Response<Entity.Relationship>> {
|
||||
return this.client.post<Entity.Relationship>(`/api/v1/accounts/${id}/block`)
|
||||
}
|
||||
|
||||
public unblockAccount(id: string): Promise<Response<Relationship>> {
|
||||
return this.client.post<Relationship>(`/api/v1/accounts/${id}/unblock`)
|
||||
public unblockAccount(id: string): Promise<Response<Entity.Relationship>> {
|
||||
return this.client.post<Entity.Relationship>(`/api/v1/accounts/${id}/unblock`)
|
||||
}
|
||||
|
||||
public muteAccount(id: string, notifications: boolean = true): Promise<Response<Relationship>> {
|
||||
return this.client.post<Relationship>(`/api/v1/accounts/${id}/mute`, {
|
||||
public muteAccount(id: string, notifications: boolean = true): Promise<Response<Entity.Relationship>> {
|
||||
return this.client.post<Entity.Relationship>(`/api/v1/accounts/${id}/mute`, {
|
||||
notifications: notifications
|
||||
})
|
||||
}
|
||||
|
||||
public unmuteAccount(id: string): Promise<Response<Relationship>> {
|
||||
return this.client.post<Relationship>(`/api/v1/accounts/${id}/unmute`)
|
||||
public unmuteAccount(id: string): Promise<Response<Entity.Relationship>> {
|
||||
return this.client.post<Entity.Relationship>(`/api/v1/accounts/${id}/unmute`)
|
||||
}
|
||||
|
||||
public pinAccount(id: string): Promise<Response<Relationship>> {
|
||||
return this.client.post<Relationship>(`/api/v1/accounts/${id}/pin`)
|
||||
public pinAccount(id: string): Promise<Response<Entity.Relationship>> {
|
||||
return this.client.post<Entity.Relationship>(`/api/v1/accounts/${id}/pin`)
|
||||
}
|
||||
|
||||
public unpinAccount(id: string): Promise<Response<Relationship>> {
|
||||
return this.client.post<Relationship>(`/api/v1/accounts/${id}/unpin`)
|
||||
public unpinAccount(id: string): Promise<Response<Entity.Relationship>> {
|
||||
return this.client.post<Entity.Relationship>(`/api/v1/accounts/${id}/unpin`)
|
||||
}
|
||||
|
||||
public getRelationship(ids: Array<string>): Promise<Response<Relationship>> {
|
||||
return this.client.get<Relationship>('/api/v1/accounts/relationships', {
|
||||
public getRelationship(ids: Array<string>): Promise<Response<Entity.Relationship>> {
|
||||
return this.client.get<Entity.Relationship>('/api/v1/accounts/relationships', {
|
||||
id: ids
|
||||
})
|
||||
}
|
||||
|
@ -425,7 +402,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
limit?: number | null,
|
||||
max_id?: string | null,
|
||||
since_id?: string | null
|
||||
): Promise<Response<Array<Account>>> {
|
||||
): Promise<Response<Array<Entity.Account>>> {
|
||||
let params = { q: q }
|
||||
if (max_id) {
|
||||
params = Object.assign(params, {
|
||||
|
@ -442,7 +419,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
limit: limit
|
||||
})
|
||||
}
|
||||
return this.client.get<Array<Account>>('/api/v1/accounts/search', params)
|
||||
return this.client.get<Array<Entity.Account>>('/api/v1/accounts/search', params)
|
||||
}
|
||||
|
||||
// ======================================
|
||||
|
@ -454,7 +431,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
max_id?: string | null,
|
||||
since_id?: string | null,
|
||||
min_id?: string | null
|
||||
): Promise<Response<Array<Status>>> {
|
||||
): Promise<Response<Array<Entity.Status>>> {
|
||||
let params = {}
|
||||
if (max_id) {
|
||||
params = Object.assign(params, {
|
||||
|
@ -476,14 +453,14 @@ export default class Mastodon implements MegalodonInterface {
|
|||
min_id: min_id
|
||||
})
|
||||
}
|
||||
return this.client.get<Array<Status>>('/api/v1/bookmarks', params)
|
||||
return this.client.get<Array<Entity.Status>>('/api/v1/bookmarks', params)
|
||||
}
|
||||
|
||||
// ======================================
|
||||
// accounts/favourites
|
||||
// ======================================
|
||||
|
||||
public getFavourites(limit?: number | null, max_id?: string | null, min_id?: string | null): Promise<Response<Array<Status>>> {
|
||||
public getFavourites(limit?: number | null, max_id?: string | null, min_id?: string | null): Promise<Response<Array<Entity.Status>>> {
|
||||
let params = {}
|
||||
if (min_id) {
|
||||
params = Object.assign(params, {
|
||||
|
@ -500,14 +477,14 @@ export default class Mastodon implements MegalodonInterface {
|
|||
limit: limit
|
||||
})
|
||||
}
|
||||
return this.client.get<Array<Status>>('/api/v1/favourites', params)
|
||||
return this.client.get<Array<Entity.Status>>('/api/v1/favourites', params)
|
||||
}
|
||||
|
||||
// ======================================
|
||||
// accounts/mutes
|
||||
// ======================================
|
||||
|
||||
public getMutes(limit?: number | null, max_id?: string | null, min_id?: string | null): Promise<Response<Array<Account>>> {
|
||||
public getMutes(limit?: number | null, max_id?: string | null, min_id?: string | null): Promise<Response<Array<Entity.Account>>> {
|
||||
let params = {}
|
||||
if (min_id) {
|
||||
params = Object.assign(params, {
|
||||
|
@ -524,14 +501,14 @@ export default class Mastodon implements MegalodonInterface {
|
|||
limit: limit
|
||||
})
|
||||
}
|
||||
return this.client.get<Array<Account>>('/api/v1/mutes', params)
|
||||
return this.client.get<Array<Entity.Account>>('/api/v1/mutes', params)
|
||||
}
|
||||
|
||||
// ======================================
|
||||
// accounts/blocks
|
||||
// ======================================
|
||||
|
||||
public getBlocks(limit?: number | null, max_id?: string | null, min_id?: string | null): Promise<Response<Array<Account>>> {
|
||||
public getBlocks(limit?: number | null, max_id?: string | null, min_id?: string | null): Promise<Response<Array<Entity.Account>>> {
|
||||
let params = {}
|
||||
if (min_id) {
|
||||
params = Object.assign(params, {
|
||||
|
@ -548,7 +525,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
limit: limit
|
||||
})
|
||||
}
|
||||
return this.client.get<Array<Account>>('/api/v1/blocks', params)
|
||||
return this.client.get<Array<Entity.Account>>('/api/v1/blocks', params)
|
||||
}
|
||||
|
||||
// ======================================
|
||||
|
@ -590,12 +567,12 @@ export default class Mastodon implements MegalodonInterface {
|
|||
// accounts/filters
|
||||
// ======================================
|
||||
|
||||
public getFilters(): Promise<Response<Array<Filter>>> {
|
||||
return this.client.get<Array<Filter>>('/api/v1/filters')
|
||||
public getFilters(): Promise<Response<Array<Entity.Filter>>> {
|
||||
return this.client.get<Array<Entity.Filter>>('/api/v1/filters')
|
||||
}
|
||||
|
||||
public getFilter(id: string): Promise<Response<Filter>> {
|
||||
return this.client.get<Filter>(`/api/v1/filters/${id}`)
|
||||
public getFilter(id: string): Promise<Response<Entity.Filter>> {
|
||||
return this.client.get<Entity.Filter>(`/api/v1/filters/${id}`)
|
||||
}
|
||||
|
||||
public createFilter(
|
||||
|
@ -604,7 +581,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
irreversible?: boolean | null,
|
||||
whole_word?: boolean | null,
|
||||
expires_in?: string | null
|
||||
): Promise<Response<Filter>> {
|
||||
): Promise<Response<Entity.Filter>> {
|
||||
let params = {
|
||||
phrase: phrase,
|
||||
context: context
|
||||
|
@ -624,7 +601,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
expires_in: expires_in
|
||||
})
|
||||
}
|
||||
return this.client.post<Filter>('/api/v1/filters', params)
|
||||
return this.client.post<Entity.Filter>('/api/v1/filters', params)
|
||||
}
|
||||
|
||||
public updateFilter(
|
||||
|
@ -634,7 +611,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
irreversible?: boolean | null,
|
||||
whole_word?: boolean | null,
|
||||
expires_in?: string | null
|
||||
): Promise<Response<Filter>> {
|
||||
): Promise<Response<Entity.Filter>> {
|
||||
let params = {
|
||||
phrase: phrase,
|
||||
context: context
|
||||
|
@ -654,11 +631,11 @@ export default class Mastodon implements MegalodonInterface {
|
|||
expires_in: expires_in
|
||||
})
|
||||
}
|
||||
return this.client.post<Filter>(`/api/v1/filters/${id}`, params)
|
||||
return this.client.post<Entity.Filter>(`/api/v1/filters/${id}`, params)
|
||||
}
|
||||
|
||||
public deleteFilter(id: string): Promise<Response<Filter>> {
|
||||
return this.client.del<Filter>(`/api/v1/filters/${id}`)
|
||||
public deleteFilter(id: string): Promise<Response<Entity.Filter>> {
|
||||
return this.client.del<Entity.Filter>(`/api/v1/filters/${id}`)
|
||||
}
|
||||
|
||||
// ======================================
|
||||
|
@ -669,7 +646,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
status_ids?: Array<string> | null,
|
||||
comment?: string | null,
|
||||
forward?: boolean | null
|
||||
): Promise<Response<Report>> {
|
||||
): Promise<Response<Entity.Report>> {
|
||||
let params = {
|
||||
account_id: account_id
|
||||
}
|
||||
|
@ -688,34 +665,38 @@ export default class Mastodon implements MegalodonInterface {
|
|||
forward: forward
|
||||
})
|
||||
}
|
||||
return this.client.post<Report>('/api/v1/reports', params)
|
||||
return this.client.post<Entity.Report>('/api/v1/reports', params)
|
||||
}
|
||||
|
||||
// ======================================
|
||||
// accounts/follow_requests
|
||||
// ======================================
|
||||
public getFollowRequests(limit?: number): Promise<Response<Array<Account>>> {
|
||||
public getFollowRequests(limit?: number): Promise<Response<Array<Entity.Account>>> {
|
||||
if (limit) {
|
||||
return this.client.get<Array<Account>>('/api/v1/follow_requests', {
|
||||
return this.client.get<Array<Entity.Account>>('/api/v1/follow_requests', {
|
||||
limit: limit
|
||||
})
|
||||
} else {
|
||||
return this.client.get<Array<Account>>('/api/v1/follow_requests')
|
||||
return this.client.get<Array<Entity.Account>>('/api/v1/follow_requests')
|
||||
}
|
||||
}
|
||||
|
||||
public acceptFollowRequest(id: string): Promise<Response<Relationship>> {
|
||||
return this.client.post<Relationship>(`/api/v1/follow_requests/${id}/authorize`)
|
||||
public acceptFollowRequest(id: string): Promise<Response<Entity.Relationship>> {
|
||||
return this.client.post<Entity.Relationship>(`/api/v1/follow_requests/${id}/authorize`)
|
||||
}
|
||||
|
||||
public rejectFollowRequest(id: string): Promise<Response<Relationship>> {
|
||||
return this.client.post<Relationship>(`/api/v1/follow_requests/${id}/reject`)
|
||||
public rejectFollowRequest(id: string): Promise<Response<Entity.Relationship>> {
|
||||
return this.client.post<Entity.Relationship>(`/api/v1/follow_requests/${id}/reject`)
|
||||
}
|
||||
|
||||
// ======================================
|
||||
// accounts/endorsements
|
||||
// ======================================
|
||||
public getEndorsements(limit?: number | null, max_id?: string | null, since_id?: string | null): Promise<Response<Array<Account>>> {
|
||||
public getEndorsements(
|
||||
limit?: number | null,
|
||||
max_id?: string | null,
|
||||
since_id?: string | null
|
||||
): Promise<Response<Array<Entity.Account>>> {
|
||||
let params = {}
|
||||
if (limit) {
|
||||
params = Object.assign(params, {
|
||||
|
@ -732,18 +713,18 @@ export default class Mastodon implements MegalodonInterface {
|
|||
since_id: since_id
|
||||
})
|
||||
}
|
||||
return this.client.get<Array<Account>>('/api/v1/endorsements', params)
|
||||
return this.client.get<Array<Entity.Account>>('/api/v1/endorsements', params)
|
||||
}
|
||||
|
||||
// ======================================
|
||||
// accounts/featured_tags
|
||||
// ======================================
|
||||
public getFeaturedTags(): Promise<Response<Array<FeaturedTag>>> {
|
||||
return this.client.get<Array<FeaturedTag>>('/api/v1/featured_tags')
|
||||
public getFeaturedTags(): Promise<Response<Array<Entity.FeaturedTag>>> {
|
||||
return this.client.get<Array<Entity.FeaturedTag>>('/api/v1/featured_tags')
|
||||
}
|
||||
|
||||
public createFeaturedTag(name: string): Promise<Response<FeaturedTag>> {
|
||||
return this.client.post<FeaturedTag>('/api/v1/featured_tags', {
|
||||
public createFeaturedTag(name: string): Promise<Response<Entity.FeaturedTag>> {
|
||||
return this.client.post<Entity.FeaturedTag>('/api/v1/featured_tags', {
|
||||
name: name
|
||||
})
|
||||
}
|
||||
|
@ -752,27 +733,27 @@ export default class Mastodon implements MegalodonInterface {
|
|||
return this.client.del<{}>(`/api/v1/featured_tags/${id}`)
|
||||
}
|
||||
|
||||
public getSuggestedTags(): Promise<Response<Array<Tag>>> {
|
||||
return this.client.get<Array<Tag>>('/api/v1/featured_tags/suggestions')
|
||||
public getSuggestedTags(): Promise<Response<Array<Entity.Tag>>> {
|
||||
return this.client.get<Array<Entity.Tag>>('/api/v1/featured_tags/suggestions')
|
||||
}
|
||||
|
||||
// ======================================
|
||||
// accounts/preferences
|
||||
// ======================================
|
||||
public getPreferences(): Promise<Response<Preferences>> {
|
||||
return this.client.get<Preferences>('/api/v1/preferences')
|
||||
public getPreferences(): Promise<Response<Entity.Preferences>> {
|
||||
return this.client.get<Entity.Preferences>('/api/v1/preferences')
|
||||
}
|
||||
|
||||
// ======================================
|
||||
// accounts/suggestions
|
||||
// ======================================
|
||||
public getSuggestions(limit?: number): Promise<Response<Array<Account>>> {
|
||||
public getSuggestions(limit?: number): Promise<Response<Array<Entity.Account>>> {
|
||||
if (limit) {
|
||||
return this.client.get<Array<Account>>('/api/v1/suggestions', {
|
||||
return this.client.get<Array<Entity.Account>>('/api/v1/suggestions', {
|
||||
limit: limit
|
||||
})
|
||||
} else {
|
||||
return this.client.get<Array<Account>>('/api/v1/suggestions')
|
||||
return this.client.get<Array<Entity.Account>>('/api/v1/suggestions')
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -789,7 +770,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
visibility?: 'public' | 'unlisted' | 'private' | 'direct' | null,
|
||||
scheduled_at?: string | null,
|
||||
language?: string | null
|
||||
): Promise<Response<Status>> {
|
||||
): Promise<Response<Entity.Status>> {
|
||||
let params = {
|
||||
status: status
|
||||
}
|
||||
|
@ -847,73 +828,73 @@ export default class Mastodon implements MegalodonInterface {
|
|||
language: language
|
||||
})
|
||||
}
|
||||
return this.client.post<Status>('/api/v1/statuses', params)
|
||||
return this.client.post<Entity.Status>('/api/v1/statuses', params)
|
||||
}
|
||||
|
||||
public getStatus(id: string): Promise<Response<Status>> {
|
||||
return this.client.get<Status>(`/api/v1/statuses/${id}`)
|
||||
public getStatus(id: string): Promise<Response<Entity.Status>> {
|
||||
return this.client.get<Entity.Status>(`/api/v1/statuses/${id}`)
|
||||
}
|
||||
|
||||
public deleteStatus(id: string): Promise<Response<Status>> {
|
||||
return this.client.del<Status>(`/api/v1/statuses/${id}`)
|
||||
public deleteStatus(id: string): Promise<Response<Entity.Status>> {
|
||||
return this.client.del<Entity.Status>(`/api/v1/statuses/${id}`)
|
||||
}
|
||||
|
||||
public getStatusContext(id: string): Promise<Response<Context>> {
|
||||
return this.client.get<Context>(`/api/v1/statuses/${id}/context`)
|
||||
public getStatusContext(id: string): Promise<Response<Entity.Context>> {
|
||||
return this.client.get<Entity.Context>(`/api/v1/statuses/${id}/context`)
|
||||
}
|
||||
|
||||
public getStatusRebloggedBy(id: string): Promise<Response<Array<Account>>> {
|
||||
return this.client.get<Array<Account>>(`/api/v1/statuses/${id}/reblogged_by`)
|
||||
public getStatusRebloggedBy(id: string): Promise<Response<Array<Entity.Account>>> {
|
||||
return this.client.get<Array<Entity.Account>>(`/api/v1/statuses/${id}/reblogged_by`)
|
||||
}
|
||||
|
||||
public getStatusFavouritedBy(id: string): Promise<Response<Array<Account>>> {
|
||||
return this.client.get<Array<Account>>(`/api/v1/statuses/${id}/favourited_by`)
|
||||
public getStatusFavouritedBy(id: string): Promise<Response<Array<Entity.Account>>> {
|
||||
return this.client.get<Array<Entity.Account>>(`/api/v1/statuses/${id}/favourited_by`)
|
||||
}
|
||||
|
||||
public favouriteStatus(id: string): Promise<Response<Status>> {
|
||||
return this.client.post<Status>(`/api/v1/statuses/${id}/favourite`)
|
||||
public favouriteStatus(id: string): Promise<Response<Entity.Status>> {
|
||||
return this.client.post<Entity.Status>(`/api/v1/statuses/${id}/favourite`)
|
||||
}
|
||||
|
||||
public unfavouriteStatus(id: string): Promise<Response<Status>> {
|
||||
return this.client.post<Status>(`/api/v1/statuses/${id}/unfavourite`)
|
||||
public unfavouriteStatus(id: string): Promise<Response<Entity.Status>> {
|
||||
return this.client.post<Entity.Status>(`/api/v1/statuses/${id}/unfavourite`)
|
||||
}
|
||||
|
||||
public reblogStatus(id: string): Promise<Response<Status>> {
|
||||
return this.client.post<Status>(`/api/v1/statuses/${id}/reblog`)
|
||||
public reblogStatus(id: string): Promise<Response<Entity.Status>> {
|
||||
return this.client.post<Entity.Status>(`/api/v1/statuses/${id}/reblog`)
|
||||
}
|
||||
|
||||
public unreblogStatus(id: string): Promise<Response<Status>> {
|
||||
return this.client.post<Status>(`/api/v1/statuses/${id}/unreblog`)
|
||||
public unreblogStatus(id: string): Promise<Response<Entity.Status>> {
|
||||
return this.client.post<Entity.Status>(`/api/v1/statuses/${id}/unreblog`)
|
||||
}
|
||||
|
||||
public bookmarkStatus(id: string): Promise<Response<Status>> {
|
||||
return this.client.post<Status>(`/api/v1/statuses/${id}/bookmark`)
|
||||
public bookmarkStatus(id: string): Promise<Response<Entity.Status>> {
|
||||
return this.client.post<Entity.Status>(`/api/v1/statuses/${id}/bookmark`)
|
||||
}
|
||||
|
||||
public unbookmarkStatus(id: string): Promise<Response<Status>> {
|
||||
return this.client.post<Status>(`/api/v1/statuses/${id}/unbookmark`)
|
||||
public unbookmarkStatus(id: string): Promise<Response<Entity.Status>> {
|
||||
return this.client.post<Entity.Status>(`/api/v1/statuses/${id}/unbookmark`)
|
||||
}
|
||||
|
||||
public muteStatus(id: string): Promise<Response<Status>> {
|
||||
return this.client.post<Status>(`/api/v1/statuses/${id}/mute`)
|
||||
public muteStatus(id: string): Promise<Response<Entity.Status>> {
|
||||
return this.client.post<Entity.Status>(`/api/v1/statuses/${id}/mute`)
|
||||
}
|
||||
|
||||
public unmuteStatus(id: string): Promise<Response<Status>> {
|
||||
return this.client.post<Status>(`/api/v1/statuses/${id}/unmute`)
|
||||
public unmuteStatus(id: string): Promise<Response<Entity.Status>> {
|
||||
return this.client.post<Entity.Status>(`/api/v1/statuses/${id}/unmute`)
|
||||
}
|
||||
|
||||
public pinStatus(id: string): Promise<Response<Status>> {
|
||||
return this.client.post<Status>(`/api/v1/statuses/${id}/pin`)
|
||||
public pinStatus(id: string): Promise<Response<Entity.Status>> {
|
||||
return this.client.post<Entity.Status>(`/api/v1/statuses/${id}/pin`)
|
||||
}
|
||||
|
||||
public unpinStatus(id: string): Promise<Response<Status>> {
|
||||
return this.client.post<Status>(`/api/v1/statuses/${id}/unpin`)
|
||||
public unpinStatus(id: string): Promise<Response<Entity.Status>> {
|
||||
return this.client.post<Entity.Status>(`/api/v1/statuses/${id}/unpin`)
|
||||
}
|
||||
|
||||
// ======================================
|
||||
// statuses/media
|
||||
// ======================================
|
||||
public uploadMedia(file: any, description?: string | null, focus?: string | null): Promise<Response<Attachment>> {
|
||||
public uploadMedia(file: any, description?: string | null, focus?: string | null): Promise<Response<Entity.Attachment>> {
|
||||
let params = {
|
||||
file: file
|
||||
}
|
||||
|
@ -927,10 +908,10 @@ export default class Mastodon implements MegalodonInterface {
|
|||
focus: focus
|
||||
})
|
||||
}
|
||||
return this.client.post<Attachment>('/api/v1/media', params)
|
||||
return this.client.post<Entity.Attachment>('/api/v1/media', params)
|
||||
}
|
||||
|
||||
public updateMedia(id: string, file?: any, description?: string | null, focus?: string | null): Promise<Response<Attachment>> {
|
||||
public updateMedia(id: string, file?: any, description?: string | null, focus?: string | null): Promise<Response<Entity.Attachment>> {
|
||||
let params = {}
|
||||
if (file) {
|
||||
params = Object.assign(params, {
|
||||
|
@ -947,18 +928,18 @@ export default class Mastodon implements MegalodonInterface {
|
|||
focus: focus
|
||||
})
|
||||
}
|
||||
return this.client.put<Attachment>(`/api/v1/media/${id}`, params)
|
||||
return this.client.put<Entity.Attachment>(`/api/v1/media/${id}`, params)
|
||||
}
|
||||
|
||||
// ======================================
|
||||
// statuses/polls
|
||||
// ======================================
|
||||
public getPoll(id: string): Promise<Response<Poll>> {
|
||||
return this.client.get<Poll>(`/api/v1/polls/${id}`)
|
||||
public getPoll(id: string): Promise<Response<Entity.Poll>> {
|
||||
return this.client.get<Entity.Poll>(`/api/v1/polls/${id}`)
|
||||
}
|
||||
|
||||
public votePoll(id: string, choices: Array<number>): Promise<Response<Poll>> {
|
||||
return this.client.post<Poll>(`/api/v1/polls/${id}/votes`, {
|
||||
public votePoll(id: string, choices: Array<number>): Promise<Response<Entity.Poll>> {
|
||||
return this.client.post<Entity.Poll>(`/api/v1/polls/${id}/votes`, {
|
||||
choices: choices
|
||||
})
|
||||
}
|
||||
|
@ -971,7 +952,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
max_id?: string | null,
|
||||
since_id?: string | null,
|
||||
min_id?: string | null
|
||||
): Promise<Response<Array<ScheduledStatus>>> {
|
||||
): Promise<Response<Array<Entity.ScheduledStatus>>> {
|
||||
let params = {}
|
||||
if (limit) {
|
||||
params = Object.assign(params, {
|
||||
|
@ -993,21 +974,21 @@ export default class Mastodon implements MegalodonInterface {
|
|||
min_id: min_id
|
||||
})
|
||||
}
|
||||
return this.client.get<Array<ScheduledStatus>>('/api/v1/scheduled_statuses', params)
|
||||
return this.client.get<Array<Entity.ScheduledStatus>>('/api/v1/scheduled_statuses', params)
|
||||
}
|
||||
|
||||
public getScheduledStatus(id: string): Promise<Response<ScheduledStatus>> {
|
||||
return this.client.get<ScheduledStatus>(`/api/v1/scheduled_statuses/${id}`)
|
||||
public getScheduledStatus(id: string): Promise<Response<Entity.ScheduledStatus>> {
|
||||
return this.client.get<Entity.ScheduledStatus>(`/api/v1/scheduled_statuses/${id}`)
|
||||
}
|
||||
|
||||
public scheduleStatus(id: string, scheduled_at?: string | null): Promise<Response<ScheduledStatus>> {
|
||||
public scheduleStatus(id: string, scheduled_at?: string | null): Promise<Response<Entity.ScheduledStatus>> {
|
||||
let params = {}
|
||||
if (scheduled_at) {
|
||||
params = Object.assign(params, {
|
||||
scheduled_at: scheduled_at
|
||||
})
|
||||
}
|
||||
return this.client.put<ScheduledStatus>(`/api/v1/scheduled_statuses/${id}`, params)
|
||||
return this.client.put<Entity.ScheduledStatus>(`/api/v1/scheduled_statuses/${id}`, params)
|
||||
}
|
||||
|
||||
public cancelScheduledStatus(id: string): Promise<Response<{}>> {
|
||||
|
@ -1024,7 +1005,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
max_id?: string | null,
|
||||
since_id?: string | null,
|
||||
min_id?: string | null
|
||||
): Promise<Response<Array<Status>>> {
|
||||
): Promise<Response<Array<Entity.Status>>> {
|
||||
let params = {}
|
||||
if (local !== null) {
|
||||
params = Object.assign(params, {
|
||||
|
@ -1056,7 +1037,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
limit: limit
|
||||
})
|
||||
}
|
||||
return this.client.get<Array<Status>>('/api/v1/timelines/public', params)
|
||||
return this.client.get<Array<Entity.Status>>('/api/v1/timelines/public', params)
|
||||
}
|
||||
|
||||
public getTagTimeline(
|
||||
|
@ -1067,7 +1048,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
max_id?: string | null,
|
||||
since_id?: string | null,
|
||||
min_id?: string | null
|
||||
): Promise<Response<Array<Status>>> {
|
||||
): Promise<Response<Array<Entity.Status>>> {
|
||||
let params = {}
|
||||
if (local !== null) {
|
||||
params = Object.assign(params, {
|
||||
|
@ -1099,7 +1080,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
limit: limit
|
||||
})
|
||||
}
|
||||
return this.client.get<Array<Status>>(`/api/v1/timelines/tag/${hashtag}`, params)
|
||||
return this.client.get<Array<Entity.Status>>(`/api/v1/timelines/tag/${hashtag}`, params)
|
||||
}
|
||||
|
||||
public getHomeTimeline(
|
||||
|
@ -1108,7 +1089,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
max_id?: string | null,
|
||||
since_id?: string | null,
|
||||
min_id?: string | null
|
||||
): Promise<Response<Array<Status>>> {
|
||||
): Promise<Response<Array<Entity.Status>>> {
|
||||
let params = {}
|
||||
if (local !== null) {
|
||||
params = Object.assign(params, {
|
||||
|
@ -1135,7 +1116,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
limit: limit
|
||||
})
|
||||
}
|
||||
return this.client.get<Array<Status>>('/api/v1/timelines/home', params)
|
||||
return this.client.get<Array<Entity.Status>>('/api/v1/timelines/home', params)
|
||||
}
|
||||
|
||||
public getListTimeline(
|
||||
|
@ -1144,7 +1125,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
max_id?: string | null,
|
||||
since_id?: string | null,
|
||||
min_id?: string | null
|
||||
): Promise<Response<Array<Status>>> {
|
||||
): Promise<Response<Array<Entity.Status>>> {
|
||||
let params = {}
|
||||
if (max_id) {
|
||||
params = Object.assign(params, {
|
||||
|
@ -1166,7 +1147,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
limit: limit
|
||||
})
|
||||
}
|
||||
return this.client.get<Array<Status>>(`/api/v1/timelines/list/${list_id}`, params)
|
||||
return this.client.get<Array<Entity.Status>>(`/api/v1/timelines/list/${list_id}`, params)
|
||||
}
|
||||
|
||||
// ======================================
|
||||
|
@ -1177,7 +1158,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
max_id?: string | null,
|
||||
since_id?: string | null,
|
||||
min_id?: string | null
|
||||
): Promise<Response<Array<Status>>> {
|
||||
): Promise<Response<Array<Entity.Status>>> {
|
||||
let params = {}
|
||||
if (max_id) {
|
||||
params = Object.assign(params, {
|
||||
|
@ -1199,36 +1180,36 @@ export default class Mastodon implements MegalodonInterface {
|
|||
limit: limit
|
||||
})
|
||||
}
|
||||
return this.client.get<Array<Status>>('/api/v1/conversations', params)
|
||||
return this.client.get<Array<Entity.Status>>('/api/v1/conversations', params)
|
||||
}
|
||||
|
||||
public deleteConversation(id: string): Promise<Response<{}>> {
|
||||
return this.client.del<{}>(`/api/v1/conversations/${id}`)
|
||||
}
|
||||
|
||||
public readConversation(id: string): Promise<Response<Conversation>> {
|
||||
return this.client.post<Conversation>(`/api/v1/conversations/${id}/read`)
|
||||
public readConversation(id: string): Promise<Response<Entity.Conversation>> {
|
||||
return this.client.post<Entity.Conversation>(`/api/v1/conversations/${id}/read`)
|
||||
}
|
||||
|
||||
// ======================================
|
||||
// timelines/lists
|
||||
// ======================================
|
||||
public getLists(): Promise<Response<Array<List>>> {
|
||||
return this.client.get<Array<List>>('/api/v1/lists')
|
||||
public getLists(): Promise<Response<Array<Entity.List>>> {
|
||||
return this.client.get<Array<Entity.List>>('/api/v1/lists')
|
||||
}
|
||||
|
||||
public getList(id: string): Promise<Response<List>> {
|
||||
return this.client.get<List>(`/api/v1/lists/${id}`)
|
||||
public getList(id: string): Promise<Response<Entity.List>> {
|
||||
return this.client.get<Entity.List>(`/api/v1/lists/${id}`)
|
||||
}
|
||||
|
||||
public createList(title: string): Promise<Response<List>> {
|
||||
return this.client.post<List>('/api/v1/lists', {
|
||||
public createList(title: string): Promise<Response<Entity.List>> {
|
||||
return this.client.post<Entity.List>('/api/v1/lists', {
|
||||
title: title
|
||||
})
|
||||
}
|
||||
|
||||
public updateList(id: string, title: string): Promise<Response<List>> {
|
||||
return this.client.put<List>(`/api/v1/lists/${id}`, {
|
||||
public updateList(id: string, title: string): Promise<Response<Entity.List>> {
|
||||
return this.client.put<Entity.List>(`/api/v1/lists/${id}`, {
|
||||
title: title
|
||||
})
|
||||
}
|
||||
|
@ -1242,7 +1223,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
limit?: number | null,
|
||||
max_id?: string | null,
|
||||
since_id?: string | null
|
||||
): Promise<Response<Array<Account>>> {
|
||||
): Promise<Response<Array<Entity.Account>>> {
|
||||
let params = {}
|
||||
if (limit) {
|
||||
params = Object.assign(params, {
|
||||
|
@ -1259,7 +1240,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
since_id: since_id
|
||||
})
|
||||
}
|
||||
return this.client.get<Array<Account>>(`/api/v1/lists/${id}/accounts`, params)
|
||||
return this.client.get<Array<Entity.Account>>(`/api/v1/lists/${id}/accounts`, params)
|
||||
}
|
||||
|
||||
public addAccountsToList(id: string, account_ids: Array<string>): Promise<Response<{}>> {
|
||||
|
@ -1277,13 +1258,16 @@ export default class Mastodon implements MegalodonInterface {
|
|||
// ======================================
|
||||
// timelines/markers
|
||||
// ======================================
|
||||
public getMarker(timeline: Array<'home' | 'notifications'>): Promise<Response<Marker | {}>> {
|
||||
return this.client.get<Marker | {}>('/api/v1/markers', {
|
||||
public getMarker(timeline: Array<'home' | 'notifications'>): Promise<Response<Entity.Marker | {}>> {
|
||||
return this.client.get<Entity.Marker | {}>('/api/v1/markers', {
|
||||
timeline: timeline
|
||||
})
|
||||
}
|
||||
|
||||
public saveMarker(home?: { last_read_id: string } | null, notifications?: { last_read_id: string } | null): Promise<Response<Marker>> {
|
||||
public saveMarker(
|
||||
home?: { last_read_id: string } | null,
|
||||
notifications?: { last_read_id: string } | null
|
||||
): Promise<Response<Entity.Marker>> {
|
||||
let params = {}
|
||||
if (home) {
|
||||
params = Object.assign(params, {
|
||||
|
@ -1295,7 +1279,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
notifications: notifications
|
||||
})
|
||||
}
|
||||
return this.client.post<Marker>('/api/v1/markers', params)
|
||||
return this.client.post<Entity.Marker>('/api/v1/markers', params)
|
||||
}
|
||||
|
||||
// ======================================
|
||||
|
@ -1308,7 +1292,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
min_id?: string | null,
|
||||
exclude_type?: Array<'follow' | 'favourite' | 'reblog' | 'mention' | 'poll'> | null,
|
||||
account_id?: string | null
|
||||
): Promise<Response<Array<Notification>>> {
|
||||
): Promise<Response<Array<Entity.Notification>>> {
|
||||
let params = {}
|
||||
if (limit) {
|
||||
params = Object.assign(params, {
|
||||
|
@ -1340,11 +1324,11 @@ export default class Mastodon implements MegalodonInterface {
|
|||
account_id
|
||||
})
|
||||
}
|
||||
return this.client.get<Array<Notification>>('/api/v1/notifications', params)
|
||||
return this.client.get<Array<Entity.Notification>>('/api/v1/notifications', params)
|
||||
}
|
||||
|
||||
public getNotification(id: string): Promise<Response<Notification>> {
|
||||
return this.client.get<Notification>(`/api/v1/notifications/${id}`)
|
||||
public getNotification(id: string): Promise<Response<Entity.Notification>> {
|
||||
return this.client.get<Entity.Notification>(`/api/v1/notifications/${id}`)
|
||||
}
|
||||
|
||||
public dismissNotifications(): Promise<Response<{}>> {
|
||||
|
@ -1361,7 +1345,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
public subscribePushNotification(
|
||||
subscription: { endpoint: string; keys: { p256dh: string; auth: string } },
|
||||
data?: { alerts: { follow?: boolean; favourite?: boolean; reblog?: boolean; mention?: boolean; poll?: boolean } } | null
|
||||
): Promise<Response<PushSubscription>> {
|
||||
): Promise<Response<Entity.PushSubscription>> {
|
||||
let params = {
|
||||
subscription
|
||||
}
|
||||
|
@ -1370,23 +1354,23 @@ export default class Mastodon implements MegalodonInterface {
|
|||
data
|
||||
})
|
||||
}
|
||||
return this.client.post<PushSubscription>('/api/v1/push/subscription', params)
|
||||
return this.client.post<Entity.PushSubscription>('/api/v1/push/subscription', params)
|
||||
}
|
||||
|
||||
public getPushSubscription(): Promise<Response<PushSubscription>> {
|
||||
return this.client.get<PushSubscription>('/api/v1/push/subscription')
|
||||
public getPushSubscription(): Promise<Response<Entity.PushSubscription>> {
|
||||
return this.client.get<Entity.PushSubscription>('/api/v1/push/subscription')
|
||||
}
|
||||
|
||||
public updatePushSubscription(
|
||||
data?: { alerts: { follow?: boolean; favourite?: boolean; reblog?: boolean; mention?: boolean; poll?: boolean } } | null
|
||||
): Promise<Response<PushSubscription>> {
|
||||
): Promise<Response<Entity.PushSubscription>> {
|
||||
let params = {}
|
||||
if (data) {
|
||||
params = Object.assign(params, {
|
||||
data
|
||||
})
|
||||
}
|
||||
return this.client.put<PushSubscription>('/api/v1/push/subscription', params)
|
||||
return this.client.put<Entity.PushSubscription>('/api/v1/push/subscription', params)
|
||||
}
|
||||
|
||||
public deletePushSubscription(): Promise<Response<{}>> {
|
||||
|
@ -1407,7 +1391,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
following?: boolean | null,
|
||||
account_id?: string | null,
|
||||
exclude_unreviewed?: boolean | null
|
||||
): Promise<Response<Results>> {
|
||||
): Promise<Response<Entity.Results>> {
|
||||
let params = {
|
||||
q,
|
||||
type
|
||||
|
@ -1452,22 +1436,22 @@ export default class Mastodon implements MegalodonInterface {
|
|||
exclude_unreviewed
|
||||
})
|
||||
}
|
||||
return this.client.get<Results>('/api/v2/search', params)
|
||||
return this.client.get<Entity.Results>('/api/v2/search', params)
|
||||
}
|
||||
|
||||
// ======================================
|
||||
// instance
|
||||
// ======================================
|
||||
public getInstance(): Promise<Response<Instance>> {
|
||||
return this.client.get<Instance>('/api/v1/instance')
|
||||
public getInstance(): Promise<Response<Entity.Instance>> {
|
||||
return this.client.get<Entity.Instance>('/api/v1/instance')
|
||||
}
|
||||
|
||||
public getInstancePeers(): Promise<Response<Array<string>>> {
|
||||
return this.client.get<Array<string>>('/api/v1/instance/peers')
|
||||
}
|
||||
|
||||
public getInstanceActivity(): Promise<Response<Array<Activity>>> {
|
||||
return this.client.get<Array<Activity>>('/api/v1/instance/activity')
|
||||
public getInstanceActivity(): Promise<Response<Array<Entity.Activity>>> {
|
||||
return this.client.get<Array<Entity.Activity>>('/api/v1/instance/activity')
|
||||
}
|
||||
|
||||
// ======================================
|
||||
|
@ -1478,14 +1462,14 @@ export default class Mastodon implements MegalodonInterface {
|
|||
*
|
||||
* @param limit Maximum number of results to return. Defaults to 10.
|
||||
*/
|
||||
public getInstanceTrends(limit?: number | null): Promise<Response<Array<Tag>>> {
|
||||
public getInstanceTrends(limit?: number | null): Promise<Response<Array<Entity.Tag>>> {
|
||||
let params = {}
|
||||
if (limit) {
|
||||
params = Object.assign(params, {
|
||||
limit
|
||||
})
|
||||
}
|
||||
return this.client.get<Array<Tag>>('/api/v1/trends', params)
|
||||
return this.client.get<Array<Entity.Tag>>('/api/v1/trends', params)
|
||||
}
|
||||
|
||||
// ======================================
|
||||
|
@ -1496,7 +1480,7 @@ export default class Mastodon implements MegalodonInterface {
|
|||
offset?: number | null,
|
||||
order?: 'active' | 'new' | null,
|
||||
local?: boolean | null
|
||||
): Promise<Response<Array<Account>>> {
|
||||
): Promise<Response<Array<Entity.Account>>> {
|
||||
let params = {}
|
||||
if (limit) {
|
||||
params = Object.assign(params, {
|
||||
|
@ -1518,14 +1502,14 @@ export default class Mastodon implements MegalodonInterface {
|
|||
local
|
||||
})
|
||||
}
|
||||
return this.client.get<Array<Account>>('/api/v1/directory', params)
|
||||
return this.client.get<Array<Entity.Account>>('/api/v1/directory', params)
|
||||
}
|
||||
|
||||
// ======================================
|
||||
// instance/custom_emojis
|
||||
// ======================================
|
||||
public getInstanceCustomEmojis(): Promise<Response<Array<Emoji>>> {
|
||||
return this.client.get<Array<Emoji>>('/api/v1/custom_emojis')
|
||||
public getInstanceCustomEmojis(): Promise<Response<Array<Entity.Emoji>>> {
|
||||
return this.client.get<Array<Entity.Emoji>>('/api/v1/custom_emojis')
|
||||
}
|
||||
|
||||
// ======================================
|
||||
|
|
213
src/megalodon.ts
213
src/megalodon.ts
|
@ -2,33 +2,10 @@ import StreamListener from './stream_listener'
|
|||
import WebSocket from './web_socket'
|
||||
import Response from './response'
|
||||
import OAuth from './oauth'
|
||||
import { Application } from './entities/application'
|
||||
import { Account } from './entities/account'
|
||||
import { Status } from './entities/status'
|
||||
import { List } from './entities/list'
|
||||
import { IdentityProof } from './entities/identity_proof'
|
||||
import { Relationship } from './entities/relationship'
|
||||
import { Filter } from './entities/filter'
|
||||
import { Report } from './entities/report'
|
||||
import { FeaturedTag } from './entities/featured_tag'
|
||||
import { Tag } from './entities/tag'
|
||||
import { Preferences } from './entities/preferences'
|
||||
import { Context } from './entities/context'
|
||||
import { Attachment } from './entities/attachment'
|
||||
import { Poll } from './entities/poll'
|
||||
import { ScheduledStatus } from './entities/scheduled_status'
|
||||
import { Conversation } from './entities/conversation'
|
||||
import { Marker } from './entities/marker'
|
||||
import { Notification } from './entities/notification'
|
||||
import { Results } from './entities/results'
|
||||
import { PushSubscription } from './entities/push_subscription'
|
||||
import { Token } from './entities/token'
|
||||
import { Instance } from './entities/instance'
|
||||
import { Activity } from './entities/activity'
|
||||
import { Emoji } from './entities/emoji'
|
||||
import Pleroma from './pleroma'
|
||||
import { ProxyConfig } from './proxy_config'
|
||||
import Mastodon from './mastodon'
|
||||
import Entity from './entity'
|
||||
|
||||
export interface MegalodonInterface {
|
||||
/**
|
||||
|
@ -72,7 +49,7 @@ export interface MegalodonInterface {
|
|||
*
|
||||
* @return An Application
|
||||
*/
|
||||
verifyAppCredentials(): Promise<Response<Application>>
|
||||
verifyAppCredentials(): Promise<Response<Entity.Application>>
|
||||
|
||||
// ======================================
|
||||
// apps/oauth
|
||||
|
@ -132,13 +109,13 @@ export interface MegalodonInterface {
|
|||
agreement: boolean,
|
||||
locale: string,
|
||||
reason?: string | null
|
||||
): Promise<Response<Token>>
|
||||
): Promise<Response<Entity.Token>>
|
||||
/**
|
||||
* GET /api/v1/accounts/verify_credentials
|
||||
*
|
||||
* @return Account.
|
||||
*/
|
||||
verifyAccountCredentials(): Promise<Response<Account>>
|
||||
verifyAccountCredentials(): Promise<Response<Entity.Account>>
|
||||
/**
|
||||
* PATCH /api/v1/accounts/update_credentials
|
||||
*
|
||||
|
@ -158,21 +135,21 @@ export interface MegalodonInterface {
|
|||
language?: string
|
||||
} | null,
|
||||
fields_attributes?: Array<{ name: string; value: string }>
|
||||
): Promise<Response<Account>>
|
||||
): Promise<Response<Entity.Account>>
|
||||
/**
|
||||
* GET /api/v1/accounts/:id
|
||||
*
|
||||
* @param id The account ID.
|
||||
* @return An account.
|
||||
*/
|
||||
getAccount(id: string): Promise<Response<Account>>
|
||||
getAccount(id: string): Promise<Response<Entity.Account>>
|
||||
/**
|
||||
* GET /api/v1/accounts/:id/statuses
|
||||
*
|
||||
* @param id The account ID.
|
||||
* @return Account's statuses.
|
||||
*/
|
||||
getAccountStatuses(id: string): Promise<Response<Array<Status>>>
|
||||
getAccountStatuses(id: string): Promise<Response<Array<Entity.Status>>>
|
||||
/**
|
||||
* GET /api/v1/pleroma/accounts/:id/favourites
|
||||
*
|
||||
|
@ -187,21 +164,21 @@ export interface MegalodonInterface {
|
|||
limit?: number | null,
|
||||
max_id?: string | null,
|
||||
since_id?: string | null
|
||||
): Promise<Response<Array<Status>>>
|
||||
): Promise<Response<Array<Entity.Status>>>
|
||||
/**
|
||||
* POST /api/v1/pleroma/accounts/:id/subscribe
|
||||
*
|
||||
* @param id Target account ID.
|
||||
* @return Relationship.
|
||||
*/
|
||||
subscribeAccount(id: string): Promise<Response<Relationship>>
|
||||
subscribeAccount(id: string): Promise<Response<Entity.Relationship>>
|
||||
/**
|
||||
* POST /api/v1/pleroma/accounts/:id/unsubscribe
|
||||
*
|
||||
* @param id Target account ID.
|
||||
* @return Relationship.
|
||||
*/
|
||||
unsubscribeAccount(id: string): Promise<Response<Relationship>>
|
||||
unsubscribeAccount(id: string): Promise<Response<Entity.Relationship>>
|
||||
/**
|
||||
* GET /api/v1/accounts/:id/followers
|
||||
*
|
||||
|
@ -216,7 +193,7 @@ export interface MegalodonInterface {
|
|||
limit?: number | null,
|
||||
max_id?: string | null,
|
||||
since_id?: string | null
|
||||
): Promise<Response<Array<Account>>>
|
||||
): Promise<Response<Array<Entity.Account>>>
|
||||
/**
|
||||
* GET /api/v1/accounts/:id/following
|
||||
*
|
||||
|
@ -231,21 +208,21 @@ export interface MegalodonInterface {
|
|||
limit?: number | null,
|
||||
max_id?: string | null,
|
||||
since_id?: string | null
|
||||
): Promise<Response<Array<Account>>>
|
||||
): Promise<Response<Array<Entity.Account>>>
|
||||
/**
|
||||
* GET /api/v1/accounts/:id/lists
|
||||
*
|
||||
* @param id The account ID.
|
||||
* @return The array of lists.
|
||||
*/
|
||||
getAccountLists(id: string): Promise<Response<Array<List>>>
|
||||
getAccountLists(id: string): Promise<Response<Array<Entity.List>>>
|
||||
/**
|
||||
* GET /api/v1/accounts/:id/identity_proofs
|
||||
*
|
||||
* @param id The account ID.
|
||||
* @return Array of IdentityProof
|
||||
*/
|
||||
getIdentityProof(id: string): Promise<Response<Array<IdentityProof>>>
|
||||
getIdentityProof(id: string): Promise<Response<Array<Entity.IdentityProof>>>
|
||||
/**
|
||||
* POST /api/v1/accounts/:id/follow
|
||||
*
|
||||
|
@ -253,28 +230,28 @@ export interface MegalodonInterface {
|
|||
* @param reblog Receive this account's reblogs in home timeline.
|
||||
* @return Relationship
|
||||
*/
|
||||
followAccount(id: string, reblog: boolean): Promise<Response<Relationship>>
|
||||
followAccount(id: string, reblog: boolean): Promise<Response<Entity.Relationship>>
|
||||
/**
|
||||
* POST /api/v1/accounts/:id/unfollow
|
||||
*
|
||||
* @param id The account ID.
|
||||
* @return Relationship
|
||||
*/
|
||||
unfollowAccount(id: string): Promise<Response<Relationship>>
|
||||
unfollowAccount(id: string): Promise<Response<Entity.Relationship>>
|
||||
/**
|
||||
* POST /api/v1/accounts/:id/block
|
||||
*
|
||||
* @param id The account ID.
|
||||
* @return Relationship
|
||||
*/
|
||||
blockAccount(id: string): Promise<Response<Relationship>>
|
||||
blockAccount(id: string): Promise<Response<Entity.Relationship>>
|
||||
/**
|
||||
* POST /api/v1/accounts/:id/unblock
|
||||
*
|
||||
* @param id The account ID.
|
||||
* @return RElationship
|
||||
*/
|
||||
unblockAccount(id: string): Promise<Response<Relationship>>
|
||||
unblockAccount(id: string): Promise<Response<Entity.Relationship>>
|
||||
/**
|
||||
* POST /api/v1/accounts/:id/mute
|
||||
*
|
||||
|
@ -282,35 +259,35 @@ export interface MegalodonInterface {
|
|||
* @param notifications Mute notifications in addition to statuses.
|
||||
* @return Relationship
|
||||
*/
|
||||
muteAccount(id: string, notifications: boolean): Promise<Response<Relationship>>
|
||||
muteAccount(id: string, notifications: boolean): Promise<Response<Entity.Relationship>>
|
||||
/**
|
||||
* POST /api/v1/accounts/:id/unmute
|
||||
*
|
||||
* @param id The account ID.
|
||||
* @return Relationship
|
||||
*/
|
||||
unmuteAccount(id: string): Promise<Response<Relationship>>
|
||||
unmuteAccount(id: string): Promise<Response<Entity.Relationship>>
|
||||
/**
|
||||
* POST /api/v1/accounts/:id/pin
|
||||
*
|
||||
* @param id The account ID.
|
||||
* @return Relationship
|
||||
*/
|
||||
pinAccount(id: string): Promise<Response<Relationship>>
|
||||
pinAccount(id: string): Promise<Response<Entity.Relationship>>
|
||||
/**
|
||||
* POST /api/v1/accounts/:id/unpin
|
||||
*
|
||||
* @param id The account ID.
|
||||
* @return Relationship
|
||||
*/
|
||||
unpinAccount(id: string): Promise<Response<Relationship>>
|
||||
unpinAccount(id: string): Promise<Response<Entity.Relationship>>
|
||||
/**
|
||||
* GET /api/v1/accounts/relationships
|
||||
*
|
||||
* @param ids Array of account IDs.
|
||||
* @return Relationship
|
||||
*/
|
||||
getRelationship(ids: Array<string>): Promise<Response<Relationship>>
|
||||
getRelationship(ids: Array<string>): Promise<Response<Entity.Relationship>>
|
||||
/**
|
||||
* GET /api/v1/accounts/search
|
||||
*
|
||||
|
@ -320,7 +297,12 @@ export interface MegalodonInterface {
|
|||
* @param since_id Return results newer than ID.
|
||||
* @return The array of accounts.
|
||||
*/
|
||||
searchAccount(q: string, limit?: number | null, max_id?: string | null, since_id?: string | null): Promise<Response<Array<Account>>>
|
||||
searchAccount(
|
||||
q: string,
|
||||
limit?: number | null,
|
||||
max_id?: string | null,
|
||||
since_id?: string | null
|
||||
): Promise<Response<Array<Entity.Account>>>
|
||||
// ======================================
|
||||
// accounts/bookmarks
|
||||
// ======================================
|
||||
|
@ -338,7 +320,7 @@ export interface MegalodonInterface {
|
|||
max_id?: string | null,
|
||||
since_id?: string | null,
|
||||
min_id?: string | null
|
||||
): Promise<Response<Array<Status>>>
|
||||
): Promise<Response<Array<Entity.Status>>>
|
||||
// ======================================
|
||||
// accounts/favourites
|
||||
// ======================================
|
||||
|
@ -350,7 +332,7 @@ export interface MegalodonInterface {
|
|||
* @param min_id Return results immediately newer than ID.
|
||||
* @return Array of statuses.
|
||||
*/
|
||||
getFavourites(limit?: number | null, max_id?: string | null, min_id?: string | null): Promise<Response<Array<Status>>>
|
||||
getFavourites(limit?: number | null, max_id?: string | null, min_id?: string | null): Promise<Response<Array<Entity.Status>>>
|
||||
// ======================================
|
||||
// accounts/mutes
|
||||
// ======================================
|
||||
|
@ -362,7 +344,7 @@ export interface MegalodonInterface {
|
|||
* @param min_id Return results immediately newer than ID.
|
||||
* @return Array of accounts.
|
||||
*/
|
||||
getMutes(limit?: number | null, max_id?: string | null, min_id?: string | null): Promise<Response<Array<Account>>>
|
||||
getMutes(limit?: number | null, max_id?: string | null, min_id?: string | null): Promise<Response<Array<Entity.Account>>>
|
||||
// ======================================
|
||||
// accounts/blocks
|
||||
// ======================================
|
||||
|
@ -374,7 +356,7 @@ export interface MegalodonInterface {
|
|||
* @param min_id Return results immediately newer than ID.
|
||||
* @return Array of accounts.
|
||||
*/
|
||||
getBlocks(limit?: number | null, max_id?: string | null, min_id?: string | null): Promise<Response<Array<Account>>>
|
||||
getBlocks(limit?: number | null, max_id?: string | null, min_id?: string | null): Promise<Response<Array<Entity.Account>>>
|
||||
// ======================================
|
||||
// accounts/domain_blocks
|
||||
// ======================================
|
||||
|
@ -407,14 +389,14 @@ export interface MegalodonInterface {
|
|||
*
|
||||
* @return Array of filters.
|
||||
*/
|
||||
getFilters(): Promise<Response<Array<Filter>>>
|
||||
getFilters(): Promise<Response<Array<Entity.Filter>>>
|
||||
/**
|
||||
* GET /api/v1/filters/:id
|
||||
*
|
||||
* @param id The filter ID.
|
||||
* @return Filter.
|
||||
*/
|
||||
getFilter(id: string): Promise<Response<Filter>>
|
||||
getFilter(id: string): Promise<Response<Entity.Filter>>
|
||||
/**
|
||||
* POST /api/v1/filters
|
||||
*
|
||||
|
@ -431,7 +413,7 @@ export interface MegalodonInterface {
|
|||
irreversible?: boolean | null,
|
||||
whole_word?: boolean | null,
|
||||
expires_in?: string | null
|
||||
): Promise<Response<Filter>>
|
||||
): Promise<Response<Entity.Filter>>
|
||||
/**
|
||||
* PUT /api/v1/filters/:id
|
||||
*
|
||||
|
@ -450,14 +432,14 @@ export interface MegalodonInterface {
|
|||
irreversible?: boolean | null,
|
||||
whole_word?: boolean | null,
|
||||
expires_in?: string | null
|
||||
): Promise<Response<Filter>>
|
||||
): Promise<Response<Entity.Filter>>
|
||||
/**
|
||||
* DELETE /api/v1/filters/:id
|
||||
*
|
||||
* @param id The filter ID.
|
||||
* @return Removed filter.
|
||||
*/
|
||||
deleteFilter(id: string): Promise<Response<Filter>>
|
||||
deleteFilter(id: string): Promise<Response<Entity.Filter>>
|
||||
// ======================================
|
||||
// accounts/reports
|
||||
// ======================================
|
||||
|
@ -475,7 +457,7 @@ export interface MegalodonInterface {
|
|||
status_ids?: Array<string> | null,
|
||||
comment?: string | null,
|
||||
forward?: boolean | null
|
||||
): Promise<Response<Report>>
|
||||
): Promise<Response<Entity.Report>>
|
||||
// ======================================
|
||||
// accounts/follow_requests
|
||||
// ======================================
|
||||
|
@ -485,21 +467,21 @@ export interface MegalodonInterface {
|
|||
* @param limit Maximum number of results.
|
||||
* @return Array of account.
|
||||
*/
|
||||
getFollowRequests(limit?: number): Promise<Response<Array<Account>>>
|
||||
getFollowRequests(limit?: number): Promise<Response<Array<Entity.Account>>>
|
||||
/**
|
||||
* POST /api/v1/follow_requests/:id/authorize
|
||||
*
|
||||
* @param id Target account ID.
|
||||
* @return Relationship.
|
||||
*/
|
||||
acceptFollowRequest(id: string): Promise<Response<Relationship>>
|
||||
acceptFollowRequest(id: string): Promise<Response<Entity.Relationship>>
|
||||
/**
|
||||
* POST /api/v1/follow_requests/:id/reject
|
||||
*
|
||||
* @param id Target account ID.
|
||||
* @return Relationship.
|
||||
*/
|
||||
rejectFollowRequest(id: string): Promise<Response<Relationship>>
|
||||
rejectFollowRequest(id: string): Promise<Response<Entity.Relationship>>
|
||||
// ======================================
|
||||
// accounts/endorsements
|
||||
// ======================================
|
||||
|
@ -511,7 +493,7 @@ export interface MegalodonInterface {
|
|||
* @param since_id Return results newer than ID.
|
||||
* @return Array of accounts.
|
||||
*/
|
||||
getEndorsements(limit?: number | null, max_id?: string | null, since_id?: string | null): Promise<Response<Array<Account>>>
|
||||
getEndorsements(limit?: number | null, max_id?: string | null, since_id?: string | null): Promise<Response<Array<Entity.Account>>>
|
||||
// ======================================
|
||||
// accounts/featured_tags
|
||||
// ======================================
|
||||
|
@ -520,14 +502,14 @@ export interface MegalodonInterface {
|
|||
*
|
||||
* @return Array of featured tag.
|
||||
*/
|
||||
getFeaturedTags(): Promise<Response<Array<FeaturedTag>>>
|
||||
getFeaturedTags(): Promise<Response<Array<Entity.FeaturedTag>>>
|
||||
/**
|
||||
* POST /api/v1/featured_tags
|
||||
*
|
||||
* @param name Target hashtag name.
|
||||
* @return FeaturedTag.
|
||||
*/
|
||||
createFeaturedTag(name: string): Promise<Response<FeaturedTag>>
|
||||
createFeaturedTag(name: string): Promise<Response<Entity.FeaturedTag>>
|
||||
/**
|
||||
* DELETE /api/v1/featured_tags/:id
|
||||
*
|
||||
|
@ -540,7 +522,7 @@ export interface MegalodonInterface {
|
|||
*
|
||||
* @return Array of tag.
|
||||
*/
|
||||
getSuggestedTags(): Promise<Response<Array<Tag>>>
|
||||
getSuggestedTags(): Promise<Response<Array<Entity.Tag>>>
|
||||
// ======================================
|
||||
// accounts/preferences
|
||||
// ======================================
|
||||
|
@ -549,7 +531,7 @@ export interface MegalodonInterface {
|
|||
*
|
||||
* @return Preferences.
|
||||
*/
|
||||
getPreferences(): Promise<Response<Preferences>>
|
||||
getPreferences(): Promise<Response<Entity.Preferences>>
|
||||
// ======================================
|
||||
// accounts/suggestions
|
||||
// ======================================
|
||||
|
@ -559,7 +541,7 @@ export interface MegalodonInterface {
|
|||
* @param limit Maximum number of results.
|
||||
* @return Array of accounts.
|
||||
*/
|
||||
getSuggestions(limit?: number): Promise<Response<Array<Account>>>
|
||||
getSuggestions(limit?: number): Promise<Response<Array<Entity.Account>>>
|
||||
// ======================================
|
||||
// statuses
|
||||
// ======================================
|
||||
|
@ -587,21 +569,21 @@ export interface MegalodonInterface {
|
|||
visibility?: 'public' | 'unlisted' | 'private' | 'direct' | null,
|
||||
scheduled_at?: string | null,
|
||||
language?: string | null
|
||||
): Promise<Response<Status>>
|
||||
): Promise<Response<Entity.Status>>
|
||||
/**
|
||||
* GET /api/v1/statuses/:id
|
||||
*
|
||||
* @param id The target status id.
|
||||
* @return Status
|
||||
*/
|
||||
getStatus(id: string): Promise<Response<Status>>
|
||||
getStatus(id: string): Promise<Response<Entity.Status>>
|
||||
/**
|
||||
* DELETE /api/v1/statuses/:id
|
||||
*
|
||||
* @param id The target status id.
|
||||
* @return Status
|
||||
*/
|
||||
deleteStatus(id: string): Promise<Response<Status>>
|
||||
deleteStatus(id: string): Promise<Response<Entity.Status>>
|
||||
/**
|
||||
* GET /api/v1/statuses/:id/context
|
||||
*
|
||||
|
@ -609,90 +591,90 @@ export interface MegalodonInterface {
|
|||
* @param id The target status id.
|
||||
* @return Context
|
||||
*/
|
||||
getStatusContext(id: string): Promise<Response<Context>>
|
||||
getStatusContext(id: string): Promise<Response<Entity.Context>>
|
||||
/**
|
||||
* GET /api/v1/statuses/:id/reblogged_by
|
||||
*
|
||||
* @param id The target status id.
|
||||
* @return Array of accounts.
|
||||
*/
|
||||
getStatusRebloggedBy(id: string): Promise<Response<Array<Account>>>
|
||||
getStatusRebloggedBy(id: string): Promise<Response<Array<Entity.Account>>>
|
||||
/**
|
||||
* GET /api/v1/statuses/:id/favourited_by
|
||||
*
|
||||
* @param id The target status id.
|
||||
* @return Array of accounts.
|
||||
*/
|
||||
getStatusFavouritedBy(id: string): Promise<Response<Array<Account>>>
|
||||
getStatusFavouritedBy(id: string): Promise<Response<Array<Entity.Account>>>
|
||||
/**
|
||||
* POST /api/v1/statuses/:id/favourite
|
||||
*
|
||||
* @param id The target status id.
|
||||
* @return Status.
|
||||
*/
|
||||
favouriteStatus(id: string): Promise<Response<Status>>
|
||||
favouriteStatus(id: string): Promise<Response<Entity.Status>>
|
||||
/**
|
||||
* POST /api/v1/statuses/:id/unfavourite
|
||||
*
|
||||
* @param id The target status id.
|
||||
* @return Status.
|
||||
*/
|
||||
unfavouriteStatus(id: string): Promise<Response<Status>>
|
||||
unfavouriteStatus(id: string): Promise<Response<Entity.Status>>
|
||||
/**
|
||||
* POST /api/v1/statuses/:id/reblog
|
||||
*
|
||||
* @param id The target status id.
|
||||
* @return Status.
|
||||
*/
|
||||
reblogStatus(id: string): Promise<Response<Status>>
|
||||
reblogStatus(id: string): Promise<Response<Entity.Status>>
|
||||
/**
|
||||
* POST /api/v1/statuses/:id/unreblog
|
||||
*
|
||||
* @param id The target status id.
|
||||
* @return Status.
|
||||
*/
|
||||
unreblogStatus(id: string): Promise<Response<Status>>
|
||||
unreblogStatus(id: string): Promise<Response<Entity.Status>>
|
||||
/**
|
||||
* POST /api/v1/statuses/:id/bookmark
|
||||
*
|
||||
* @param id The target status id.
|
||||
* @return Status.
|
||||
*/
|
||||
bookmarkStatus(id: string): Promise<Response<Status>>
|
||||
bookmarkStatus(id: string): Promise<Response<Entity.Status>>
|
||||
/**
|
||||
* POST /api/v1/statuses/:id/unbookmark
|
||||
*
|
||||
* @param id The target status id.
|
||||
* @return Status.
|
||||
*/
|
||||
unbookmarkStatus(id: string): Promise<Response<Status>>
|
||||
unbookmarkStatus(id: string): Promise<Response<Entity.Status>>
|
||||
/**
|
||||
* POST /api/v1/statuses/:id/mute
|
||||
*
|
||||
* @param id The target status id.
|
||||
* @return Status
|
||||
*/
|
||||
muteStatus(id: string): Promise<Response<Status>>
|
||||
muteStatus(id: string): Promise<Response<Entity.Status>>
|
||||
/**
|
||||
* POST /api/v1/statuses/:id/unmute
|
||||
*
|
||||
* @param id The target status id.
|
||||
* @return Status
|
||||
*/
|
||||
unmuteStatus(id: string): Promise<Response<Status>>
|
||||
unmuteStatus(id: string): Promise<Response<Entity.Status>>
|
||||
/**
|
||||
* POST /api/v1/statuses/:id/pin
|
||||
* @param id The target status id.
|
||||
* @return Status
|
||||
*/
|
||||
pinStatus(id: string): Promise<Response<Status>>
|
||||
pinStatus(id: string): Promise<Response<Entity.Status>>
|
||||
/**
|
||||
* POST /api/v1/statuses/:id/unpin
|
||||
*
|
||||
* @param id The target status id.
|
||||
* @return Status
|
||||
*/
|
||||
unpinStatus(id: string): Promise<Response<Status>>
|
||||
unpinStatus(id: string): Promise<Response<Entity.Status>>
|
||||
// ======================================
|
||||
// statuses/media
|
||||
// ======================================
|
||||
|
@ -704,7 +686,7 @@ export interface MegalodonInterface {
|
|||
* @param focus Two floating points (x,y), comma-delimited, ranging from -1.0 to 1.0.
|
||||
* @return Attachment
|
||||
*/
|
||||
uploadMedia(file: any, description?: string | null, focus?: string | null): Promise<Response<Attachment>>
|
||||
uploadMedia(file: any, description?: string | null, focus?: string | null): Promise<Response<Entity.Attachment>>
|
||||
/**
|
||||
* PUT /api/v1/media/:id
|
||||
*
|
||||
|
@ -714,7 +696,7 @@ export interface MegalodonInterface {
|
|||
* @param focus Two floating points (x,y), comma-delimited, ranging from -1.0 to 1.0.
|
||||
* @return Attachment
|
||||
*/
|
||||
updateMedia(id: string, file?: any, description?: string | null, focus?: string | null): Promise<Response<Attachment>>
|
||||
updateMedia(id: string, file?: any, description?: string | null, focus?: string | null): Promise<Response<Entity.Attachment>>
|
||||
// ======================================
|
||||
// statuses/polls
|
||||
// ======================================
|
||||
|
@ -724,7 +706,7 @@ export interface MegalodonInterface {
|
|||
* @param id Target poll ID.
|
||||
* @return Poll
|
||||
*/
|
||||
getPoll(id: string): Promise<Response<Poll>>
|
||||
getPoll(id: string): Promise<Response<Entity.Poll>>
|
||||
/**
|
||||
* POST /api/v1/polls/:id/votes
|
||||
*
|
||||
|
@ -732,7 +714,7 @@ export interface MegalodonInterface {
|
|||
* @param choices Array of own votes containing index for each option (starting from 0).
|
||||
* @return Poll
|
||||
*/
|
||||
votePoll(id: string, choices: Array<number>): Promise<Response<Poll>>
|
||||
votePoll(id: string, choices: Array<number>): Promise<Response<Entity.Poll>>
|
||||
// ======================================
|
||||
// statuses/scheduled_statuses
|
||||
// ======================================
|
||||
|
@ -750,14 +732,14 @@ export interface MegalodonInterface {
|
|||
max_id?: string | null,
|
||||
since_id?: string | null,
|
||||
min_id?: string | null
|
||||
): Promise<Response<Array<ScheduledStatus>>>
|
||||
): Promise<Response<Array<Entity.ScheduledStatus>>>
|
||||
/**
|
||||
* GET /api/v1/scheduled_statuses/:id
|
||||
*
|
||||
* @param id Target status ID.
|
||||
* @return ScheduledStatus.
|
||||
*/
|
||||
getScheduledStatus(id: string): Promise<Response<ScheduledStatus>>
|
||||
getScheduledStatus(id: string): Promise<Response<Entity.ScheduledStatus>>
|
||||
/**
|
||||
* PUT /api/v1/scheduled_statuses/:id
|
||||
*
|
||||
|
@ -765,7 +747,7 @@ export interface MegalodonInterface {
|
|||
* @param scheduled_at ISO 8601 Datetime at which the status will be published.
|
||||
* @return ScheduledStatus.
|
||||
*/
|
||||
scheduleStatus(id: string, scheduled_at?: string | null): Promise<Response<ScheduledStatus>>
|
||||
scheduleStatus(id: string, scheduled_at?: string | null): Promise<Response<Entity.ScheduledStatus>>
|
||||
/**
|
||||
* DELETE /api/v1/scheduled_statuses/:id
|
||||
*
|
||||
|
@ -793,7 +775,7 @@ export interface MegalodonInterface {
|
|||
max_id?: string | null,
|
||||
since_id?: string | null,
|
||||
min_id?: string | null
|
||||
): Promise<Response<Array<Status>>>
|
||||
): Promise<Response<Array<Entity.Status>>>
|
||||
/**
|
||||
* GET /api/v1/timelines/tag/:hashtag
|
||||
*
|
||||
|
@ -814,7 +796,7 @@ export interface MegalodonInterface {
|
|||
max_id?: string | null,
|
||||
since_id?: string | null,
|
||||
min_id?: string | null
|
||||
): Promise<Response<Array<Status>>>
|
||||
): Promise<Response<Array<Entity.Status>>>
|
||||
/**
|
||||
* GET /api/v1/timelines/home
|
||||
*
|
||||
|
@ -831,7 +813,7 @@ export interface MegalodonInterface {
|
|||
max_id?: string | null,
|
||||
since_id?: string | null,
|
||||
min_id?: string | null
|
||||
): Promise<Response<Array<Status>>>
|
||||
): Promise<Response<Array<Entity.Status>>>
|
||||
/**
|
||||
* GET /api/v1/timelines/list/:list_id
|
||||
*
|
||||
|
@ -848,7 +830,7 @@ export interface MegalodonInterface {
|
|||
max_id?: string | null,
|
||||
since_id?: string | null,
|
||||
min_id?: string | null
|
||||
): Promise<Response<Array<Status>>>
|
||||
): Promise<Response<Array<Entity.Status>>>
|
||||
// ======================================
|
||||
// timelines/conversations
|
||||
// ======================================
|
||||
|
@ -866,7 +848,7 @@ export interface MegalodonInterface {
|
|||
max_id?: string | null,
|
||||
since_id?: string | null,
|
||||
min_id?: string | null
|
||||
): Promise<Response<Array<Status>>>
|
||||
): Promise<Response<Array<Entity.Status>>>
|
||||
/**
|
||||
* DELETE /api/v1/conversations/:id
|
||||
*
|
||||
|
@ -879,7 +861,7 @@ export interface MegalodonInterface {
|
|||
* @param id Target conversation ID.
|
||||
* @return Conversation.
|
||||
*/
|
||||
readConversation(id: string): Promise<Response<Conversation>>
|
||||
readConversation(id: string): Promise<Response<Entity.Conversation>>
|
||||
// ======================================
|
||||
// timelines/lists
|
||||
// ======================================
|
||||
|
@ -888,21 +870,21 @@ export interface MegalodonInterface {
|
|||
*
|
||||
* @return Array of lists.
|
||||
*/
|
||||
getLists(): Promise<Response<Array<List>>>
|
||||
getLists(): Promise<Response<Array<Entity.List>>>
|
||||
/**
|
||||
* GET /api/v1/lists/:id
|
||||
*
|
||||
* @param id Target list ID.
|
||||
* @return List.
|
||||
*/
|
||||
getList(id: string): Promise<Response<List>>
|
||||
getList(id: string): Promise<Response<Entity.List>>
|
||||
/**
|
||||
* POST /api/v1/lists
|
||||
*
|
||||
* @param title List name.
|
||||
* @return List.
|
||||
*/
|
||||
createList(title: string): Promise<Response<List>>
|
||||
createList(title: string): Promise<Response<Entity.List>>
|
||||
/**
|
||||
* PUT /api/v1/lists/:id
|
||||
*
|
||||
|
@ -910,7 +892,7 @@ export interface MegalodonInterface {
|
|||
* @param title New list name.
|
||||
* @return List.
|
||||
*/
|
||||
updateList(id: string, title: string): Promise<Response<List>>
|
||||
updateList(id: string, title: string): Promise<Response<Entity.List>>
|
||||
/**
|
||||
* DELETE /api/v1/lists/:id
|
||||
*
|
||||
|
@ -926,7 +908,12 @@ export interface MegalodonInterface {
|
|||
* @param min_id Return results immediately newer than ID.
|
||||
* @return Array of accounts.
|
||||
*/
|
||||
getAccountsInList(id: string, limit?: number | null, max_id?: string | null, since_id?: string | null): Promise<Response<Array<Account>>>
|
||||
getAccountsInList(
|
||||
id: string,
|
||||
limit?: number | null,
|
||||
max_id?: string | null,
|
||||
since_id?: string | null
|
||||
): Promise<Response<Array<Entity.Account>>>
|
||||
/**
|
||||
* POST /api/v1/lists/:id/accounts
|
||||
*
|
||||
|
@ -950,7 +937,7 @@ export interface MegalodonInterface {
|
|||
* @param timelines Array of timeline names, String enum anyOf home, notifications.
|
||||
* @return Marker or empty object.
|
||||
*/
|
||||
getMarker(timeline: Array<'home' | 'notifications'>): Promise<Response<Marker | {}>>
|
||||
getMarker(timeline: Array<'home' | 'notifications'>): Promise<Response<Entity.Marker | {}>>
|
||||
/**
|
||||
* POST /api/v1/markers
|
||||
*
|
||||
|
@ -958,7 +945,7 @@ export interface MegalodonInterface {
|
|||
* @param notifications Marker position of the last read notification ID in notifications.
|
||||
* @return Marker.
|
||||
*/
|
||||
saveMarker(home?: { last_read_id: string } | null, notifications?: { last_read_id: string } | null): Promise<Response<Marker>>
|
||||
saveMarker(home?: { last_read_id: string } | null, notifications?: { last_read_id: string } | null): Promise<Response<Entity.Marker>>
|
||||
// ======================================
|
||||
// notifications
|
||||
// ======================================
|
||||
|
@ -980,14 +967,14 @@ export interface MegalodonInterface {
|
|||
min_id?: string | null,
|
||||
exclude_type?: Array<'follow' | 'favourite' | 'reblog' | 'mention' | 'poll'> | null,
|
||||
account_id?: string | null
|
||||
): Promise<Response<Array<Notification>>>
|
||||
): Promise<Response<Array<Entity.Notification>>>
|
||||
/**
|
||||
* GET /api/v1/notifications/:id
|
||||
*
|
||||
* @param id Target notification ID.
|
||||
* @return Notification.
|
||||
*/
|
||||
getNotification(id: string): Promise<Response<Notification>>
|
||||
getNotification(id: string): Promise<Response<Entity.Notification>>
|
||||
/**
|
||||
* POST /api/v1/notifications/clear
|
||||
*/
|
||||
|
@ -1017,13 +1004,13 @@ export interface MegalodonInterface {
|
|||
subscribePushNotification(
|
||||
subscription: { endpoint: string; keys: { p256dh: string; auth: string } },
|
||||
data?: { alerts: { follow?: boolean; favourite?: boolean; reblog?: boolean; mention?: boolean; poll?: boolean } } | null
|
||||
): Promise<Response<PushSubscription>>
|
||||
): Promise<Response<Entity.PushSubscription>>
|
||||
/**
|
||||
* GET /api/v1/push/subscription
|
||||
*
|
||||
* @return PushSubscription.
|
||||
*/
|
||||
getPushSubscription(): Promise<Response<PushSubscription>>
|
||||
getPushSubscription(): Promise<Response<Entity.PushSubscription>>
|
||||
/**
|
||||
* PUT /api/v1/push/subscription
|
||||
*
|
||||
|
@ -1036,7 +1023,7 @@ export interface MegalodonInterface {
|
|||
*/
|
||||
updatePushSubscription(
|
||||
data?: { alerts: { follow?: boolean; favourite?: boolean; reblog?: boolean; mention?: boolean; poll?: boolean } } | null
|
||||
): Promise<Response<PushSubscription>>
|
||||
): Promise<Response<Entity.PushSubscription>>
|
||||
/**
|
||||
* DELETE /api/v1/push/subscription
|
||||
*/
|
||||
|
@ -1069,7 +1056,7 @@ export interface MegalodonInterface {
|
|||
following?: boolean | null,
|
||||
account_id?: string | null,
|
||||
exclude_unreviewed?: boolean | null
|
||||
): Promise<Response<Results>>
|
||||
): Promise<Response<Entity.Results>>
|
||||
|
||||
// ======================================
|
||||
// instance
|
||||
|
@ -1077,7 +1064,7 @@ export interface MegalodonInterface {
|
|||
/**
|
||||
* GET /api/v1/instance
|
||||
*/
|
||||
getInstance(): Promise<Response<Instance>>
|
||||
getInstance(): Promise<Response<Entity.Instance>>
|
||||
|
||||
/**
|
||||
* GET /api/v1/instance/peers
|
||||
|
@ -1087,7 +1074,7 @@ export interface MegalodonInterface {
|
|||
/**
|
||||
* GET /api/v1/instance/activity
|
||||
*/
|
||||
getInstanceActivity(): Promise<Response<Array<Activity>>>
|
||||
getInstanceActivity(): Promise<Response<Array<Entity.Activity>>>
|
||||
|
||||
// ======================================
|
||||
// instance/trends
|
||||
|
@ -1097,7 +1084,7 @@ export interface MegalodonInterface {
|
|||
*
|
||||
* @param limit Maximum number of results to return. Defaults to 10.
|
||||
*/
|
||||
getInstanceTrends(limit?: number | null): Promise<Response<Array<Tag>>>
|
||||
getInstanceTrends(limit?: number | null): Promise<Response<Array<Entity.Tag>>>
|
||||
|
||||
// ======================================
|
||||
// instance/directory
|
||||
|
@ -1116,7 +1103,7 @@ export interface MegalodonInterface {
|
|||
offset?: number | null,
|
||||
order?: 'active' | 'new' | null,
|
||||
local?: boolean | null
|
||||
): Promise<Response<Array<Account>>>
|
||||
): Promise<Response<Array<Entity.Account>>>
|
||||
|
||||
// ======================================
|
||||
// instance/custom_emojis
|
||||
|
@ -1126,7 +1113,7 @@ export interface MegalodonInterface {
|
|||
*
|
||||
* @return Array of emojis.
|
||||
*/
|
||||
getInstanceCustomEmojis(): Promise<Response<Array<Emoji>>>
|
||||
getInstanceCustomEmojis(): Promise<Response<Array<Entity.Emoji>>>
|
||||
|
||||
// ======================================
|
||||
// HTTP Streaming
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import { EventEmitter } from 'events'
|
||||
import { Status } from './entities/status'
|
||||
import { Notification } from './entities/notification'
|
||||
import { Conversation } from './entities/conversation'
|
||||
import Entity from './entity'
|
||||
|
||||
/**
|
||||
* Parser
|
||||
|
@ -64,13 +62,13 @@ export class Parser extends EventEmitter {
|
|||
}
|
||||
switch (event) {
|
||||
case 'update':
|
||||
this.emit('update', jsonObj as Status)
|
||||
this.emit('update', jsonObj as Entity.Status)
|
||||
break
|
||||
case 'notification':
|
||||
this.emit('notification', jsonObj as Notification)
|
||||
this.emit('notification', jsonObj as Entity.Notification)
|
||||
break
|
||||
case 'conversation':
|
||||
this.emit('conversation', jsonObj as Conversation)
|
||||
this.emit('conversation', jsonObj as Entity.Conversation)
|
||||
break
|
||||
case 'delete':
|
||||
// When delete, data is an ID of the deleted status
|
||||
|
|
|
@ -2,8 +2,7 @@ import { MegalodonInterface, NoImplementedError } from './megalodon'
|
|||
import Mastodon from './mastodon'
|
||||
import StreamListener from './stream_listener'
|
||||
import Response from './response'
|
||||
import { Status } from './entities/status'
|
||||
import { Relationship } from './entities/relationship'
|
||||
import Entity from './entity'
|
||||
|
||||
export default class Pleroma extends Mastodon implements MegalodonInterface {
|
||||
// ======================================
|
||||
|
@ -14,7 +13,7 @@ export default class Pleroma extends Mastodon implements MegalodonInterface {
|
|||
limit?: number | null,
|
||||
max_id?: string | null,
|
||||
since_id?: string | null
|
||||
): Promise<Response<Array<Status>>> {
|
||||
): Promise<Response<Array<Entity.Status>>> {
|
||||
let params = {}
|
||||
if (limit) {
|
||||
params = Object.assign(params, {
|
||||
|
@ -31,15 +30,15 @@ export default class Pleroma extends Mastodon implements MegalodonInterface {
|
|||
since_id: since_id
|
||||
})
|
||||
}
|
||||
return this.client.get<Array<Status>>(`/api/v1/pleroma/accounts/${id}/favourites`, params)
|
||||
return this.client.get<Array<Entity.Status>>(`/api/v1/pleroma/accounts/${id}/favourites`, params)
|
||||
}
|
||||
|
||||
public subscribeAccount(id: string): Promise<Response<Relationship>> {
|
||||
return this.client.post<Relationship>(`/api/v1/pleroma/accounts/${id}/subscribe`)
|
||||
public subscribeAccount(id: string): Promise<Response<Entity.Relationship>> {
|
||||
return this.client.post<Entity.Relationship>(`/api/v1/pleroma/accounts/${id}/subscribe`)
|
||||
}
|
||||
|
||||
public unsubscribeAccount(id: string): Promise<Response<Relationship>> {
|
||||
return this.client.post<Relationship>(`/api/v1/pleroma/accounts/${id}/unsubscribe`)
|
||||
public unsubscribeAccount(id: string): Promise<Response<Entity.Relationship>> {
|
||||
return this.client.post<Entity.Relationship>(`/api/v1/pleroma/accounts/${id}/unsubscribe`)
|
||||
}
|
||||
|
||||
// ======================================
|
||||
|
|
|
@ -2,10 +2,8 @@ import { EventEmitter } from 'events'
|
|||
import axios, { CancelTokenSource, AxiosRequestConfig } from 'axios'
|
||||
import httpAdapter from 'axios/lib/adapters/http'
|
||||
import { Parser } from './parser'
|
||||
import { Status } from './entities/status'
|
||||
import { Notification } from './entities/notification'
|
||||
import { Conversation } from './entities/conversation'
|
||||
import proxyAgent, { ProxyConfig } from './proxy_config'
|
||||
import Entity from './entity'
|
||||
|
||||
const STATUS_CODES_TO_ABORT_ON: Array<number> = [400, 401, 403, 404, 406, 410, 422]
|
||||
|
||||
|
@ -162,13 +160,13 @@ export default class StreamListener extends EventEmitter {
|
|||
* Set up parser when receive some data.
|
||||
**/
|
||||
private _setupParser() {
|
||||
this.parser.on('update', (status: Status) => {
|
||||
this.parser.on('update', (status: Entity.Status) => {
|
||||
this.emit('update', status)
|
||||
})
|
||||
this.parser.on('notification', (notification: Notification) => {
|
||||
this.parser.on('notification', (notification: Entity.Notification) => {
|
||||
this.emit('notification', notification)
|
||||
})
|
||||
this.parser.on('conversation', (conversation: Conversation) => {
|
||||
this.parser.on('conversation', (conversation: Entity.Conversation) => {
|
||||
this.emit('conversation', conversation)
|
||||
})
|
||||
this.parser.on('delete', (id: string) => {
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
import WS from 'ws'
|
||||
import moment, { Moment } from 'moment'
|
||||
import { EventEmitter } from 'events'
|
||||
import { Status } from './entities/status'
|
||||
import { Notification } from './entities/notification'
|
||||
import { Conversation } from './entities/conversation'
|
||||
import proxyAgent, { ProxyConfig } from './proxy_config'
|
||||
import Entity from './entity'
|
||||
|
||||
/**
|
||||
* WebSocket
|
||||
|
@ -233,16 +231,16 @@ export default class WebSocket extends EventEmitter {
|
|||
* Set up parser when receive message.
|
||||
*/
|
||||
private _setupParser() {
|
||||
this.parser.on('update', (status: Status) => {
|
||||
this.parser.on('update', (status: Entity.Status) => {
|
||||
this.emit('update', status)
|
||||
})
|
||||
this.parser.on('notification', (notification: Notification) => {
|
||||
this.parser.on('notification', (notification: Entity.Notification) => {
|
||||
this.emit('notification', notification)
|
||||
})
|
||||
this.parser.on('delete', (id: string) => {
|
||||
this.emit('delete', id)
|
||||
})
|
||||
this.parser.on('conversation', (conversation: Conversation) => {
|
||||
this.parser.on('conversation', (conversation: Entity.Conversation) => {
|
||||
this.emit('conversation', conversation)
|
||||
})
|
||||
this.parser.on('error', (err: Error) => {
|
||||
|
@ -314,13 +312,13 @@ export class Parser extends EventEmitter {
|
|||
|
||||
switch (event) {
|
||||
case 'update':
|
||||
this.emit('update', mes as Status)
|
||||
this.emit('update', mes as Entity.Status)
|
||||
break
|
||||
case 'notification':
|
||||
this.emit('notification', mes as Notification)
|
||||
this.emit('notification', mes as Entity.Notification)
|
||||
break
|
||||
case 'conversation':
|
||||
this.emit('conversation', mes as Conversation)
|
||||
this.emit('conversation', mes as Entity.Conversation)
|
||||
break
|
||||
case 'delete':
|
||||
this.emit('delete', payload)
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
import MastodonAPI from '@/mastodon/api_client'
|
||||
import { Account } from '@/entities/account'
|
||||
import { Status } from '@/entities/status'
|
||||
import { Application } from '@/entities/application'
|
||||
import Entity from '@/entity'
|
||||
import Response from '@/response'
|
||||
import axios, { AxiosResponse } from 'axios'
|
||||
|
||||
jest.mock('axios')
|
||||
|
||||
const account: Account = {
|
||||
const account: Entity.Account = {
|
||||
id: '1',
|
||||
username: 'h3poteto',
|
||||
acct: 'h3poteto@pleroma.io',
|
||||
|
@ -29,7 +27,7 @@ const account: Account = {
|
|||
bot: false
|
||||
}
|
||||
|
||||
const status: Status = {
|
||||
const status: Entity.Status = {
|
||||
id: '1',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
|
@ -56,7 +54,7 @@ const status: Status = {
|
|||
poll: null,
|
||||
application: {
|
||||
name: 'Web'
|
||||
} as Application,
|
||||
} as Entity.Application,
|
||||
language: null,
|
||||
pinned: null
|
||||
}
|
||||
|
@ -68,7 +66,7 @@ const status: Status = {
|
|||
|
||||
describe('get', () => {
|
||||
const client = new MastodonAPI.Client('testToken', 'https://pleroma.io/api/v1')
|
||||
const mockResponse: AxiosResponse<Array<Status>> = {
|
||||
const mockResponse: AxiosResponse<Array<Entity.Status>> = {
|
||||
data: [status],
|
||||
status: 200,
|
||||
statusText: '200OK',
|
||||
|
@ -77,14 +75,14 @@ describe('get', () => {
|
|||
}
|
||||
it('should be responsed', async () => {
|
||||
;(axios.get as any).mockResolvedValue(mockResponse)
|
||||
const response: Response<Array<Status>> = await client.get<Array<Status>>('/timelines/home')
|
||||
const response: Response<Array<Entity.Status>> = await client.get<Array<Entity.Status>>('/timelines/home')
|
||||
expect(response.data).toEqual([status])
|
||||
})
|
||||
})
|
||||
|
||||
describe('put', () => {
|
||||
const client = new MastodonAPI.Client('testToken', 'https://pleroma.io/api/v1')
|
||||
const mockResponse: AxiosResponse<Account> = {
|
||||
const mockResponse: AxiosResponse<Entity.Account> = {
|
||||
data: account,
|
||||
status: 200,
|
||||
statusText: '200OK',
|
||||
|
@ -93,7 +91,7 @@ describe('put', () => {
|
|||
}
|
||||
it('should be responsed', async () => {
|
||||
;(axios.put as any).mockResolvedValue(mockResponse)
|
||||
const response: Response<Account> = await client.put<Account>('/accounts/update_credentials', {
|
||||
const response: Response<Entity.Account> = await client.put<Entity.Account>('/accounts/update_credentials', {
|
||||
display_name: 'hoge'
|
||||
})
|
||||
expect(response.data).toEqual(account)
|
||||
|
@ -102,7 +100,7 @@ describe('put', () => {
|
|||
|
||||
describe('patch', () => {
|
||||
const client = new MastodonAPI.Client('testToken', 'https://pleroma.io/api/v1')
|
||||
const mockResponse: AxiosResponse<Account> = {
|
||||
const mockResponse: AxiosResponse<Entity.Account> = {
|
||||
data: account,
|
||||
status: 200,
|
||||
statusText: '200OK',
|
||||
|
@ -111,7 +109,7 @@ describe('patch', () => {
|
|||
}
|
||||
it('should be responsed', async () => {
|
||||
;(axios.patch as any).mockResolvedValue(mockResponse)
|
||||
const response: Response<Account> = await client.patch<Account>('/accounts/update_credentials', {
|
||||
const response: Response<Entity.Account> = await client.patch<Entity.Account>('/accounts/update_credentials', {
|
||||
display_name: 'hoge'
|
||||
})
|
||||
expect(response.data).toEqual(account)
|
||||
|
@ -120,7 +118,7 @@ describe('patch', () => {
|
|||
|
||||
describe('post', () => {
|
||||
const client = new MastodonAPI.Client('testToken', 'https://pleroma.io/api/v1')
|
||||
const mockResponse: AxiosResponse<Status> = {
|
||||
const mockResponse: AxiosResponse<Entity.Status> = {
|
||||
data: status,
|
||||
status: 200,
|
||||
statusText: '200OK',
|
||||
|
@ -129,7 +127,7 @@ describe('post', () => {
|
|||
}
|
||||
it('should be responsed', async () => {
|
||||
;(axios.post as any).mockResolvedValue(mockResponse)
|
||||
const response: Response<Status> = await client.post<Status>('/statuses', {
|
||||
const response: Response<Entity.Status> = await client.post<Entity.Status>('/statuses', {
|
||||
status: 'hoge'
|
||||
})
|
||||
expect(response.data).toEqual(status)
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
import { Parser } from '@/parser'
|
||||
import { Account } from '@/entities/account'
|
||||
import { Status } from '@/entities/status'
|
||||
import { Application } from '@/entities/application'
|
||||
import { Notification } from '@/entities/notification'
|
||||
import { Conversation } from '@/entities/conversation'
|
||||
import Entity from '@/entity'
|
||||
|
||||
const account: Account = {
|
||||
const account: Entity.Account = {
|
||||
id: '1',
|
||||
username: 'h3poteto',
|
||||
acct: 'h3poteto@pleroma.io',
|
||||
|
@ -27,7 +23,7 @@ const account: Account = {
|
|||
bot: false
|
||||
}
|
||||
|
||||
const status: Status = {
|
||||
const status: Entity.Status = {
|
||||
id: '1',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
|
@ -54,12 +50,12 @@ const status: Status = {
|
|||
poll: null,
|
||||
application: {
|
||||
name: 'Web'
|
||||
} as Application,
|
||||
} as Entity.Application,
|
||||
language: null,
|
||||
pinned: null
|
||||
}
|
||||
|
||||
const notification: Notification = {
|
||||
const notification: Entity.Notification = {
|
||||
id: '1',
|
||||
account: account,
|
||||
status: status,
|
||||
|
@ -67,7 +63,7 @@ const notification: Notification = {
|
|||
created_at: '2019-04-01T17:01:32'
|
||||
}
|
||||
|
||||
const conversation: Conversation = {
|
||||
const conversation: Entity.Conversation = {
|
||||
id: '1',
|
||||
accounts: [account],
|
||||
last_status: status,
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
import { Parser } from '@/web_socket'
|
||||
import { Account } from '@/entities/account'
|
||||
import { Status } from '@/entities/status'
|
||||
import { Application } from '@/entities/application'
|
||||
import { Notification } from '@/entities/notification'
|
||||
import { Conversation } from '@/entities/conversation'
|
||||
import Entity from '@/entity'
|
||||
|
||||
const account: Account = {
|
||||
const account: Entity.Account = {
|
||||
id: '1',
|
||||
username: 'h3poteto',
|
||||
acct: 'h3poteto@pleroma.io',
|
||||
|
@ -26,7 +22,7 @@ const account: Account = {
|
|||
fields: null,
|
||||
bot: false
|
||||
}
|
||||
const status: Status = {
|
||||
const status: Entity.Status = {
|
||||
id: '1',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
|
@ -53,12 +49,12 @@ const status: Status = {
|
|||
poll: null,
|
||||
application: {
|
||||
name: 'Web'
|
||||
} as Application,
|
||||
} as Entity.Application,
|
||||
language: null,
|
||||
pinned: null
|
||||
}
|
||||
|
||||
const notification: Notification = {
|
||||
const notification: Entity.Notification = {
|
||||
id: '1',
|
||||
account: account,
|
||||
status: status,
|
||||
|
@ -66,7 +62,7 @@ const notification: Notification = {
|
|||
created_at: '2019-04-01T17:01:32'
|
||||
}
|
||||
|
||||
const conversation: Conversation = {
|
||||
const conversation: Entity.Conversation = {
|
||||
id: '1',
|
||||
accounts: [account],
|
||||
last_status: status,
|
||||
|
|
Loading…
Reference in a new issue