Refactor API (#4770)

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Update description.ts

* wip
This commit is contained in:
syuilo
2019-04-23 22:35:26 +09:00
committed by GitHub
parent f31f986d66
commit 0463c6bb0f
105 changed files with 1622 additions and 808 deletions

View File

@ -4,12 +4,13 @@ import define from '../../define';
import { Apps } from '../../../../models';
import { genId } from '../../../../misc/gen-id';
import { unique } from '../../../../prelude/array';
import { types, bool } from '../../../../misc/schema';
export const meta = {
tags: ['app'],
requireCredential: false,
desc: {
'ja-JP': 'アプリを作成します。',
'en-US': 'Create a application.'
@ -50,29 +51,12 @@ export const meta = {
}
},
},
res: {
type: 'object',
properties: {
id: {
type: 'string',
description: 'アプリケーションのID'
},
name: {
type: 'string',
description: 'アプリケーションの名前'
},
callbackUrl: {
type: 'string',
nullable: true,
description: 'コールバックするURL'
},
secret: {
type: 'string',
description: 'アプリケーションのシークレットキー'
}
}
}
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'App',
},
};
export default define(meta, async (ps, user) => {

View File

@ -3,6 +3,7 @@ import { ID } from '../../../../misc/cafy-id';
import define from '../../define';
import { ApiError } from '../../error';
import { Apps } from '../../../../models';
import { types, bool } from '../../../../misc/schema';
export const meta = {
tags: ['app'],
@ -13,6 +14,12 @@ export const meta = {
},
},
res: {
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'App',
},
errors: {
noSuchApp: {
message: 'No such app.',

View File

@ -5,12 +5,13 @@ import define from '../../../define';
import { ApiError } from '../../../error';
import { Apps, AuthSessions } from '../../../../../models';
import { genId } from '../../../../../misc/gen-id';
import { types, bool } from '../../../../../misc/schema';
export const meta = {
tags: ['auth'],
requireCredential: false,
desc: {
'ja-JP': 'アプリを認証するためのトークンを作成します。',
'en-US': 'Generate a token for authorize application.'
@ -27,14 +28,18 @@ export const meta = {
},
res: {
type: 'object',
type: types.object,
optional: bool.false, nullable: bool.false,
properties: {
token: {
type: 'string',
type: types.string,
optional: bool.false, nullable: bool.false,
description: 'セッションのトークン'
},
url: {
type: 'string',
type: types.string,
optional: bool.false, nullable: bool.false,
format: 'url',
description: 'セッションのURL'
},
}

View File

@ -3,6 +3,7 @@ import define from '../../../define';
import { ApiError } from '../../../error';
import { Apps, AuthSessions, AccessTokens, Users } from '../../../../../models';
import { ensure } from '../../../../../prelude/ensure';
import { types, bool } from '../../../../../misc/schema';
export const meta = {
tags: ['auth'],
@ -28,15 +29,19 @@ export const meta = {
},
res: {
type: 'object',
type: types.object,
optional: bool.false, nullable: bool.false,
properties: {
accessToken: {
type: 'string',
type: types.string,
optional: bool.false, nullable: bool.false,
description: 'ユーザーのアクセストークン',
},
user: {
type: 'User',
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'User',
description: '認証したユーザー'
},
}

View File

@ -3,6 +3,7 @@ import { ID } from '../../../../misc/cafy-id';
import define from '../../define';
import { Blockings } from '../../../../models';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@ -32,9 +33,12 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'Blocking',
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'Blocking',
}
},
};

View File

@ -1,6 +1,7 @@
import define from '../define';
import fetchMeta from '../../../misc/fetch-meta';
import { DriveFiles } from '../../../models';
import { types, bool } from '../../../misc/schema';
export const meta = {
desc: {
@ -15,13 +16,16 @@ export const meta = {
kind: 'read:drive',
res: {
type: 'object',
type: types.object,
optional: bool.false, nullable: bool.false,
properties: {
capacity: {
type: 'number'
type: types.number,
optional: bool.false, nullable: bool.false,
},
usage: {
type: 'number'
type: types.number,
optional: bool.false, nullable: bool.false,
}
}
}

View File

@ -3,6 +3,7 @@ import { ID } from '../../../../misc/cafy-id';
import define from '../../define';
import { DriveFiles } from '../../../../models';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@ -41,10 +42,13 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'DriveFile',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'DriveFile',
}
},
};

View File

@ -3,6 +3,7 @@ import { ID } from '../../../../../misc/cafy-id';
import define from '../../../define';
import { ApiError } from '../../../error';
import { DriveFiles } from '../../../../../models';
import { types, bool } from '../../../../../misc/schema';
export const meta = {
stability: 'stable',
@ -29,10 +30,13 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'Note',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'Note',
}
},
errors: {

View File

@ -1,6 +1,7 @@
import $ from 'cafy';
import define from '../../../define';
import { DriveFiles } from '../../../../../models';
import { types, bool } from '../../../../../misc/schema';
export const meta = {
desc: {
@ -24,7 +25,13 @@ export const meta = {
},
res: {
type: 'DriveFile',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'DriveFile',
}
},
};

View File

@ -6,6 +6,7 @@ import define from '../../../define';
import { apiLogger } from '../../../logger';
import { ApiError } from '../../../error';
import { DriveFiles } from '../../../../../models';
import { types, bool } from '../../../../../misc/schema';
export const meta = {
desc: {
@ -56,7 +57,9 @@ export const meta = {
},
res: {
type: 'DriveFile',
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'DriveFile',
},
errors: {
@ -87,7 +90,7 @@ export default define(meta, async (ps, user, app, file, cleanup) => {
try {
// Create file
const driveFile = await create(user, file.path, name, null, ps.folderId, ps.force, false, null, null, ps.isSensitive);
return DriveFiles.pack(driveFile, { self: true });
return await DriveFiles.pack(driveFile, { self: true });
} catch (e) {
apiLogger.error(e);
throw new ApiError();

View File

@ -2,6 +2,7 @@ import $ from 'cafy';
import { ID } from '../../../../../misc/cafy-id';
import define from '../../../define';
import { DriveFiles } from '../../../../../models';
import { types, bool } from '../../../../../misc/schema';
export const meta = {
requireCredential: true,
@ -22,7 +23,17 @@ export const meta = {
'ja-JP': 'フォルダID'
}
},
}
},
res: {
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'DriveFile',
}
},
};
export default define(meta, async (ps, user) => {

View File

@ -4,6 +4,7 @@ import define from '../../../define';
import { ApiError } from '../../../error';
import { DriveFile } from '../../../../../models/entities/drive-file';
import { DriveFiles } from '../../../../../models';
import { types, bool } from '../../../../../misc/schema';
export const meta = {
stability: 'stable',
@ -38,7 +39,9 @@ export const meta = {
},
res: {
type: 'DriveFile',
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'DriveFile',
},
errors: {

View File

@ -3,6 +3,7 @@ import { ID } from '../../../../misc/cafy-id';
import define from '../../define';
import { DriveFolders } from '../../../../models';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@ -37,10 +38,13 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'DriveFolder',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'DriveFolder',
}
},
};

View File

@ -2,6 +2,7 @@ import $ from 'cafy';
import { ID } from '../../../../../misc/cafy-id';
import define from '../../../define';
import { DriveFolders } from '../../../../../models';
import { types, bool } from '../../../../../misc/schema';
export const meta = {
tags: ['drive'],
@ -25,10 +26,13 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'DriveFolder',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'DriveFolder',
}
},
};

View File

@ -3,6 +3,7 @@ import { ID } from '../../../../../misc/cafy-id';
import define from '../../../define';
import { ApiError } from '../../../error';
import { DriveFolders } from '../../../../../models';
import { types, bool } from '../../../../../misc/schema';
export const meta = {
stability: 'stable',
@ -29,7 +30,9 @@ export const meta = {
},
res: {
type: 'DriveFolder',
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'DriveFolder',
},
errors: {

View File

@ -3,6 +3,7 @@ import { ID } from '../../../../misc/cafy-id';
import define from '../../define';
import { DriveFiles } from '../../../../models';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { types, bool } from '../../../../misc/schema';
export const meta = {
tags: ['drive'],
@ -31,10 +32,13 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'DriveFile',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'DriveFile',
}
},
};

View File

@ -1,6 +1,7 @@
import $ from 'cafy';
import define from '../../define';
import { Hashtags } from '../../../../models';
import { types, bool } from '../../../../misc/schema';
export const meta = {
tags: ['hashtags'],
@ -47,9 +48,12 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'Hashtag'
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'Hashtag',
}
},
};

View File

@ -1,6 +1,7 @@
import $ from 'cafy';
import define from '../../define';
import { Hashtags } from '../../../../models';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@ -37,9 +38,11 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'string'
type: types.string,
optional: bool.false, nullable: bool.false,
}
},
};

View File

@ -1,6 +1,7 @@
import $ from 'cafy';
import define from '../../define';
import { Users } from '../../../../models';
import { types, bool } from '../../../../misc/schema';
export const meta = {
requireCredential: false,
@ -47,9 +48,12 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'User'
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'User',
}
},
};

View File

@ -1,5 +1,6 @@
import define from '../define';
import { Users } from '../../../models';
import { types, bool } from '../../../misc/schema';
export const meta = {
stability: 'stable',
@ -15,8 +16,10 @@ export const meta = {
params: {},
res: {
type: 'User',
}
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'User',
},
};
export default define(meta, async (ps, user, app) => {

View File

@ -4,6 +4,7 @@ import { readNotification } from '../../common/read-notification';
import define from '../../define';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { Notifications, Followings, Mutings } from '../../../../models';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@ -53,10 +54,13 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'Notification',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'Notification',
}
},
};

View File

@ -3,6 +3,7 @@ import define from '../../define';
import { MessagingMessage } from '../../../../models/entities/messaging-message';
import { MessagingMessages, Mutings } from '../../../../models';
import { Brackets } from 'typeorm';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@ -24,10 +25,13 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'MessagingMessage',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'MessagingMessage',
}
},
};

View File

@ -6,6 +6,7 @@ import { ApiError } from '../../error';
import { getUser } from '../../common/getters';
import { MessagingMessages } from '../../../../models';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@ -48,10 +49,13 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'MessagingMessage',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'MessagingMessage',
}
},
errors: {

View File

@ -9,6 +9,7 @@ import { getUser } from '../../../common/getters';
import { MessagingMessages, DriveFiles, Mutings } from '../../../../../models';
import { MessagingMessage } from '../../../../../models/entities/messaging-message';
import { genId } from '../../../../../misc/gen-id';
import { types, bool } from '../../../../../misc/schema';
export const meta = {
desc: {
@ -41,7 +42,9 @@ export const meta = {
},
res: {
type: 'MessagingMessage',
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'MessagingMessage',
},
errors: {

View File

@ -5,6 +5,7 @@ import define from '../define';
import fetchMeta from '../../../misc/fetch-meta';
import * as pkg from '../../../../package.json';
import { Emojis } from '../../../models';
import { types, bool } from '../../../misc/schema';
export const meta = {
stability: 'stable',
@ -26,32 +27,40 @@ export const meta = {
},
res: {
type: 'object',
type: types.object,
optional: bool.false, nullable: bool.false,
properties: {
version: {
type: 'string',
type: types.string,
optional: bool.false, nullable: bool.false,
description: 'The version of Misskey of this instance.',
example: pkg.version
},
name: {
type: 'string',
type: types.string,
optional: bool.false, nullable: bool.false,
description: 'The name of this instance.',
},
description: {
type: 'string',
type: types.string,
optional: bool.false, nullable: bool.false,
description: 'The description of this instance.',
},
announcements: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'object',
type: types.object,
optional: bool.false, nullable: bool.false,
properties: {
title: {
type: 'string',
type: types.string,
optional: bool.false, nullable: bool.false,
description: 'The title of the announcement.',
},
text: {
type: 'string',
type: types.string,
optional: bool.false, nullable: bool.false,
description: 'The text of the announcement. (can be HTML)',
},
}
@ -59,19 +68,23 @@ export const meta = {
description: 'The announcements of this instance.',
},
disableRegistration: {
type: 'boolean',
type: types.boolean,
optional: bool.false, nullable: bool.false,
description: 'Whether disabled open registration.',
},
disableLocalTimeline: {
type: 'boolean',
type: types.boolean,
optional: bool.false, nullable: bool.false,
description: 'Whether disabled LTL and STL.',
},
disableGlobalTimeline: {
type: 'boolean',
type: types.boolean,
optional: bool.false, nullable: bool.false,
description: 'Whether disabled GTL.',
},
enableEmojiReaction: {
type: 'boolean',
type: types.boolean,
optional: bool.false, nullable: bool.false,
description: 'Whether enabled emoji reaction.',
},
}

View File

@ -3,6 +3,7 @@ import { ID } from '../../../../misc/cafy-id';
import define from '../../define';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { Mutings } from '../../../../models';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@ -32,9 +33,12 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'Muting',
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'Muting',
}
},
};

View File

@ -3,6 +3,7 @@ import { ID } from '../../../misc/cafy-id';
import define from '../define';
import { makePaginationQuery } from '../common/make-pagination-query';
import { Notes } from '../../../models';
import { types, bool } from '../../../misc/schema';
export const meta = {
desc: {
@ -62,9 +63,12 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'Note',
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'Note',
}
},
};

View File

@ -6,6 +6,7 @@ import { generateVisibilityQuery } from '../../common/generate-visibility-query'
import { generateMuteQuery } from '../../common/generate-mute-query';
import { Brackets } from 'typeorm';
import { Notes } from '../../../../models';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@ -41,10 +42,13 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'Note',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'Note',
}
},
};

View File

@ -5,6 +5,7 @@ import { ApiError } from '../../error';
import { getNote } from '../../common/getters';
import { Note } from '../../../../models/entities/note';
import { Notes } from '../../../../models';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@ -37,10 +38,13 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'Note',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'Note',
}
},
errors: {

View File

@ -10,6 +10,7 @@ import { User } from '../../../../models/entities/user';
import { Users, DriveFiles, Notes } from '../../../../models';
import { DriveFile } from '../../../../models/entities/drive-file';
import { Note } from '../../../../models/entities/note';
import { types, bool } from '../../../../misc/schema';
let maxNoteTextLength = 1000;
@ -174,10 +175,13 @@ export const meta = {
},
res: {
type: 'object',
type: types.object,
optional: bool.false, nullable: bool.false,
properties: {
createdNote: {
type: 'Note',
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'Note',
description: '作成した投稿'
}
}

View File

@ -2,6 +2,7 @@ import $ from 'cafy';
import define from '../../define';
import { generateMuteQuery } from '../../common/generate-mute-query';
import { Notes } from '../../../../models';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@ -24,10 +25,13 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'Note',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'Note',
}
},
};

View File

@ -7,6 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query';
import { Notes } from '../../../../models';
import { generateMuteQuery } from '../../common/generate-mute-query';
import { activeUsersChart } from '../../../../services/chart';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@ -46,10 +47,13 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'Note',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'Note',
}
},
errors: {

View File

@ -9,6 +9,7 @@ import { Brackets } from 'typeorm';
import { generateVisibilityQuery } from '../../common/generate-visibility-query';
import { generateMuteQuery } from '../../common/generate-mute-query';
import { activeUsersChart } from '../../../../services/chart';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@ -89,10 +90,13 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'Note',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'Note',
}
},
errors: {

View File

@ -9,6 +9,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query';
import { generateVisibilityQuery } from '../../common/generate-visibility-query';
import { activeUsersChart } from '../../../../services/chart';
import { Brackets } from 'typeorm';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@ -63,10 +64,13 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'Note',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'Note',
}
},
errors: {

View File

@ -7,6 +7,7 @@ import { generateVisibilityQuery } from '../../common/generate-visibility-query'
import { generateMuteQuery } from '../../common/generate-mute-query';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { Brackets } from 'typeorm';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@ -43,10 +44,13 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'Note',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'Note',
}
},
};

View File

@ -4,6 +4,7 @@ import define from '../../define';
import { getNote } from '../../common/getters';
import { ApiError } from '../../error';
import { NoteReactions } from '../../../../models';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@ -44,9 +45,12 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'Reaction'
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'NoteReaction',
}
},

View File

@ -7,6 +7,7 @@ import { generateVisibilityQuery } from '../../common/generate-visibility-query'
import { generateMuteQuery } from '../../common/generate-mute-query';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { Notes } from '../../../../models';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@ -42,10 +43,13 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'Note',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'Note',
}
},
errors: {

View File

@ -5,6 +5,7 @@ import { Notes } from '../../../../models';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { generateVisibilityQuery } from '../../common/generate-visibility-query';
import { generateMuteQuery } from '../../common/generate-mute-query';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@ -46,10 +47,13 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'Note',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'Note',
}
},
};

View File

@ -6,6 +6,7 @@ import { Notes } from '../../../../models';
import { generateMuteQuery } from '../../common/generate-mute-query';
import { generateVisibilityQuery } from '../../common/generate-visibility-query';
import { Brackets } from 'typeorm';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@ -81,10 +82,13 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'Note',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'Note',
}
},
};

View File

@ -4,6 +4,7 @@ import define from '../../define';
import { ApiError } from '../../error';
import { Notes } from '../../../../models';
import { In } from 'typeorm';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@ -32,10 +33,13 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'Note',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'Note',
}
},
errors: {

View File

@ -4,6 +4,7 @@ import define from '../../define';
import { getNote } from '../../common/getters';
import { ApiError } from '../../error';
import { Notes } from '../../../../models';
import { types, bool } from '../../../../misc/schema';
export const meta = {
stability: 'stable',
@ -28,7 +29,9 @@ export const meta = {
},
res: {
type: 'Note',
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'Note',
},
errors: {

View File

@ -7,6 +7,7 @@ import { generateVisibilityQuery } from '../../common/generate-visibility-query'
import { generateMuteQuery } from '../../common/generate-mute-query';
import { activeUsersChart } from '../../../../services/chart';
import { Brackets } from 'typeorm';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@ -88,10 +89,13 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'Note',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'Note',
}
},
};

View File

@ -6,6 +6,7 @@ import { UserLists, UserListJoinings, Notes } from '../../../../models';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { generateVisibilityQuery } from '../../common/generate-visibility-query';
import { activeUsersChart } from '../../../../services/chart';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@ -94,10 +95,13 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'Note',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'Note',
}
},
errors: {

View File

@ -1,6 +1,7 @@
import define from '../define';
import { Notes, Users } from '../../../models';
import { federationChart, driveChart } from '../../../services/chart';
import { bool, types } from '../../../misc/schema';
export const meta = {
requireCredential: false,
@ -15,26 +16,32 @@ export const meta = {
},
res: {
type: 'object',
type: types.object,
optional: bool.false, nullable: bool.false,
properties: {
notesCount: {
type: 'number',
type: types.number,
optional: bool.false, nullable: bool.false,
description: 'The count of all (local/remote) notes of this instance.',
},
originalNotesCount: {
type: 'number',
type: types.number,
optional: bool.false, nullable: bool.false,
description: 'The count of all local notes of this instance.',
},
usersCount: {
type: 'number',
type: types.number,
optional: bool.false, nullable: bool.false,
description: 'The count of all (local/remote) accounts of this instance.',
},
originalUsersCount: {
type: 'number',
type: types.number,
optional: bool.false, nullable: bool.false,
description: 'The count of all local accounts of this instance.',
},
instances: {
type: 'number',
type: types.number,
optional: bool.false, nullable: bool.false,
description: 'The count of federated instances.',
},
}
@ -42,7 +49,14 @@ export const meta = {
};
export default define(meta, async () => {
const [notesCount, originalNotesCount, usersCount, originalUsersCount, instances, driveUsageLocal, driveUsageRemote] = await Promise.all([
const [notesCount,
originalNotesCount,
usersCount,
originalUsersCount,
instances,
driveUsageLocal,
driveUsageRemote
] = await Promise.all([
Notes.count(),
Notes.count({ userHost: null }),
Users.count(),
@ -53,6 +67,12 @@ export default define(meta, async () => {
]);
return {
notesCount, originalNotesCount, usersCount, originalUsersCount, instances, driveUsageLocal, driveUsageRemote
notesCount,
originalNotesCount,
usersCount,
originalUsersCount,
instances,
driveUsageLocal,
driveUsageRemote
};
});

View File

@ -2,6 +2,7 @@ import $ from 'cafy';
import define from '../define';
import { Users } from '../../../models';
import { generateMuteQueryForUsers } from '../common/generate-mute-query';
import { types, bool } from '../../../misc/schema';
export const meta = {
tags: ['users'],
@ -53,9 +54,12 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'User',
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'User',
}
},
};

View File

@ -5,6 +5,7 @@ import { ApiError } from '../../error';
import { Users, Followings } from '../../../../models';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { toPunyNullable } from '../../../../misc/convert-host';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@ -48,10 +49,13 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'Following',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'Following',
}
},
errors: {

View File

@ -5,6 +5,7 @@ import { ApiError } from '../../error';
import { Users, Followings } from '../../../../models';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { toPunyNullable } from '../../../../misc/convert-host';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@ -48,10 +49,13 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'Following',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'Following',
}
},
errors: {

View File

@ -6,6 +6,7 @@ import { ApiError } from '../../error';
import { getUser } from '../../common/getters';
import { Not, In } from 'typeorm';
import { Notes, Users } from '../../../../models';
import { types, bool } from '../../../../misc/schema';
export const meta = {
tags: ['users'],
@ -28,9 +29,12 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'User',
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'User',
}
},

View File

@ -3,6 +3,7 @@ import define from '../../../define';
import { UserLists } from '../../../../../models';
import { genId } from '../../../../../misc/gen-id';
import { UserList } from '../../../../../models/entities/user-list';
import { types, bool } from '../../../../../misc/schema';
export const meta = {
desc: {
@ -17,10 +18,16 @@ export const meta = {
kind: 'write:account',
params: {
title: {
name: {
validator: $.str.range(1, 100)
}
}
},
res: {
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'UserList',
},
};
export default define(meta, async (ps, user) => {
@ -28,7 +35,7 @@ export default define(meta, async (ps, user) => {
id: genId(),
createdAt: new Date(),
userId: user.id,
name: ps.title,
name: ps.name,
} as UserList);
return await UserLists.pack(userList);

View File

@ -1,5 +1,6 @@
import define from '../../../define';
import { UserLists } from '../../../../../models';
import { types, bool } from '../../../../../misc/schema';
export const meta = {
desc: {
@ -13,10 +14,13 @@ export const meta = {
kind: 'read:account',
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'UserList',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'UserList',
}
},
};

View File

@ -3,6 +3,7 @@ import { ID } from '../../../../../misc/cafy-id';
import define from '../../../define';
import { ApiError } from '../../../error';
import { UserLists } from '../../../../../models';
import { types, bool } from '../../../../../misc/schema';
export const meta = {
desc: {
@ -23,7 +24,9 @@ export const meta = {
},
res: {
type: 'UserList'
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'UserList',
},
errors: {

View File

@ -8,6 +8,7 @@ import { generateVisibilityQuery } from '../../common/generate-visibility-query'
import { Notes } from '../../../../models';
import { generateMuteQuery } from '../../common/generate-mute-query';
import { Brackets } from 'typeorm';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@ -119,10 +120,13 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'Note',
},
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'Note',
}
},
errors: {

View File

@ -3,6 +3,7 @@ import $ from 'cafy';
import define from '../../define';
import { Users, Followings } from '../../../../models';
import { generateMuteQueryForUsers } from '../../common/generate-mute-query';
import { types, bool } from '../../../../misc/schema';
export const meta = {
desc: {
@ -28,9 +29,12 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'User',
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'User',
}
},
};

View File

@ -2,6 +2,7 @@ import $ from 'cafy';
import define from '../../define';
import { Users } from '../../../../models';
import { User } from '../../../../models/entities/user';
import { bool, types } from '../../../../misc/schema';
export const meta = {
desc: {
@ -54,9 +55,12 @@ export const meta = {
},
res: {
type: 'array',
type: types.array,
optional: bool.false, nullable: bool.false,
items: {
type: 'User',
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'User',
}
},
};

View File

@ -6,6 +6,7 @@ import { ApiError } from '../../error';
import { ID } from '../../../../misc/cafy-id';
import { Users } from '../../../../models';
import { In } from 'typeorm';
import { bool, types } from '../../../../misc/schema';
export const meta = {
desc: {
@ -42,7 +43,9 @@ export const meta = {
},
res: {
type: 'User',
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'User',
},
errors: {