refs #125 Divide misskey entities under misskey API
This commit is contained in:
parent
65b7b7d3ca
commit
4e189bc04e
|
@ -96,8 +96,8 @@ export default class Misskey {
|
|||
"secret": "string"
|
||||
}
|
||||
*/
|
||||
return MisskeyAPI.Client.post<MisskeyAPI.App>('/api/app/create', params, this.baseUrl, this.proxyConfig).then(
|
||||
(res: Response<MisskeyAPI.App>) => {
|
||||
return MisskeyAPI.Client.post<MisskeyAPI.Entity.App>('/api/app/create', params, this.baseUrl, this.proxyConfig).then(
|
||||
(res: Response<MisskeyAPI.Entity.App>) => {
|
||||
const appData: OAuth.AppDataFromServer = {
|
||||
id: res.data.id,
|
||||
name: res.data.name,
|
||||
|
@ -114,10 +114,10 @@ export default class Misskey {
|
|||
/**
|
||||
* POST /api/auth/session/generate
|
||||
*/
|
||||
public async generateAuthUrlAndToken(clientSecret: string): Promise<MisskeyAPI.Session> {
|
||||
return MisskeyAPI.Client.post<MisskeyAPI.Session>('/api/auth/session/generate', {
|
||||
public async generateAuthUrlAndToken(clientSecret: string): Promise<MisskeyAPI.Entity.Session> {
|
||||
return MisskeyAPI.Client.post<MisskeyAPI.Entity.Session>('/api/auth/session/generate', {
|
||||
appSecret: clientSecret
|
||||
}).then((res: Response<MisskeyAPI.Session>) => res.data)
|
||||
}).then((res: Response<MisskeyAPI.Entity.Session>) => res.data)
|
||||
}
|
||||
|
||||
// ======================================
|
||||
|
@ -147,7 +147,7 @@ export default class Misskey {
|
|||
session_token: string,
|
||||
_redirect_uri: string
|
||||
): Promise<OAuth.TokenData> {
|
||||
return MisskeyAPI.Client.post<MisskeyAPI.UserKey>('/api/auth/session/userkey', {
|
||||
return MisskeyAPI.Client.post<MisskeyAPI.Entity.UserKey>('/api/auth/session/userkey', {
|
||||
appSecret: client_secret,
|
||||
token: session_token
|
||||
}).then(res => {
|
||||
|
|
|
@ -2,8 +2,16 @@ import axios, { AxiosResponse, CancelTokenSource, AxiosRequestConfig } from 'axi
|
|||
import { DEFAULT_UA } from '@/default'
|
||||
import proxyAgent, { ProxyConfig } from '@/proxy_config'
|
||||
import Response from '@/response'
|
||||
import MisskeyEntity from './entity'
|
||||
|
||||
namespace MisskeyAPI {
|
||||
export namespace Entity {
|
||||
export type App = MisskeyEntity.App
|
||||
export type User = MisskeyEntity.User
|
||||
export type UserKey = MisskeyEntity.UserKey
|
||||
export type Session = MisskeyEntity.Session
|
||||
}
|
||||
|
||||
export const DEFAULT_SCOPE = [
|
||||
'read:account',
|
||||
'write:account',
|
||||
|
@ -128,23 +136,6 @@ namespace MisskeyAPI {
|
|||
return this.cancelTokenSource.cancel('Request is canceled by user')
|
||||
}
|
||||
}
|
||||
|
||||
export type App = {
|
||||
id: string
|
||||
name: string
|
||||
callbackUrl: string
|
||||
permission: Array<string>
|
||||
secret: string
|
||||
}
|
||||
|
||||
export type Session = {
|
||||
token: string
|
||||
url: string
|
||||
}
|
||||
|
||||
export type UserKey = {
|
||||
accessToken: string
|
||||
}
|
||||
}
|
||||
|
||||
export default MisskeyAPI
|
||||
|
|
9
src/misskey/entities/app.ts
Normal file
9
src/misskey/entities/app.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
namespace Entity {
|
||||
export type App = {
|
||||
id: string
|
||||
name: string
|
||||
callbackUrl: string
|
||||
permission: Array<string>
|
||||
secret: string
|
||||
}
|
||||
}
|
6
src/misskey/entities/session.ts
Normal file
6
src/misskey/entities/session.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
namespace Entity {
|
||||
export type Session = {
|
||||
token: string
|
||||
url: string
|
||||
}
|
||||
}
|
18
src/misskey/entities/user.ts
Normal file
18
src/misskey/entities/user.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
namespace Entity {
|
||||
export type User = {
|
||||
id: string
|
||||
username: string
|
||||
name: string
|
||||
host: string
|
||||
description: string
|
||||
createdAt: string
|
||||
followersCount: number
|
||||
followingCount: number
|
||||
notesCount: number
|
||||
isBot: boolean
|
||||
isCat: boolean
|
||||
isAdmim: boolean
|
||||
isVerified: boolean
|
||||
isLocked: boolean
|
||||
}
|
||||
}
|
8
src/misskey/entities/userkey.ts
Normal file
8
src/misskey/entities/userkey.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
/// <reference path="user.ts" />
|
||||
|
||||
namespace Entity {
|
||||
export type UserKey = {
|
||||
accessToken: string
|
||||
user: User
|
||||
}
|
||||
}
|
6
src/misskey/entity.ts
Normal file
6
src/misskey/entity.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
/// <reference path="entities/app.ts" />
|
||||
/// <reference path="entities/user.ts" />
|
||||
/// <reference path="entities/userkey.ts" />
|
||||
/// <reference path="entities/session.ts" />
|
||||
|
||||
export default Entity
|
Loading…
Reference in a new issue