refactor: APIエンドポイントファイルの定義を良い感じにする (#8154)

* Fix API Schema Error

* Delete SimpleSchema/SimpleObj
and Move schemas to dedicated files

* Userのスキーマを分割してみる

* define packMany type

* add ,

* Ensure enum schema and Make "as const" put once

* test?

* Revert "test?"

This reverts commit 97dc9bfa70851bfb7d1cf38e883f8df20fb78b79.

* Revert "Fix API Schema Error"

This reverts commit 21b6176d974ed8e3eb73723ad21a105c5d297323.

* ✌️

* clean up

* test?

* wip

* wip

* better schema def

* ✌️

* fix

* add minLength property

* wip

* wip

* wip

* anyOf/oneOf/allOfに対応? ~ relation.ts

* refactor!

* Define MinimumSchema

* wip

* wip

* anyOf/oneOf/allOfが動作するようにUnionSchemaTypeを修正

* anyOf/oneOf/allOfが動作するようにUnionSchemaTypeを修正

* Update packages/backend/src/misc/schema.ts

Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com>

* fix

* array oneOfをより正確な型に

* array oneOfをより正確な型に

* wip

* ✌️

* なんかもういろいろ

* remove

* very good schema

* api schema

* wip

* refactor: awaitAllの型定義を変えてみる

* fix

* specify types in awaitAll

* specify types in awaitAll

* ✌️

* wip

* ...

* ✌️

* AllowDateはやめておく

* 不必要なoptional: false, nullable: falseを廃止

* Packedが展開されないように

* 続packed

* wip

* define note type

* wip

* UserDetailedをMeDetailedかUserDetailedNotMeかを区別できるように

* wip

* wip

* wip specify user type of other schemas

* ok

* convertSchemaToOpenApiSchemaを改修

* convertSchemaToOpenApiSchemaを改修

* Fix

* fix

* ✌️

* wip

* 分割代入ではなくallOfで定義するように

Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
This commit is contained in:
tamaina
2022-01-18 22:27:10 +09:00
committed by GitHub
parent a8fad1b61c
commit efb0ffc4ec
358 changed files with 3623 additions and 3417 deletions

View File

@ -3,7 +3,7 @@ import { dirname } from 'path';
import { Context } from 'cafy';
import * as path from 'path';
import * as glob from 'glob';
import { SimpleSchema } from '@/misc/simple-schema';
import { Schema } from '@/misc/schema';
//const _filename = fileURLToPath(import.meta.url);
const _filename = __filename;
@ -18,87 +18,87 @@ export type Param = {
};
export interface IEndpointMeta {
stability?: string; //'deprecated' | 'experimental' | 'stable';
readonly stability?: 'deprecated' | 'experimental' | 'stable';
tags?: string[];
readonly tags?: ReadonlyArray<string>;
params?: {
[key: string]: Param;
readonly params?: {
readonly [key: string]: Param;
};
errors?: {
[key: string]: {
message: string;
code: string;
id: string;
readonly errors?: {
readonly [key: string]: {
readonly message: string;
readonly code: string;
readonly id: string;
};
};
res?: SimpleSchema;
readonly res?: Schema;
/**
* このエンドポイントにリクエストするのにユーザー情報が必須か否か
* 省略した場合は false として解釈されます。
*/
requireCredential?: boolean;
readonly requireCredential?: boolean;
/**
* 管理者のみ使えるエンドポイントか否か
*/
requireAdmin?: boolean;
readonly requireAdmin?: boolean;
/**
* 管理者またはモデレーターのみ使えるエンドポイントか否か
*/
requireModerator?: boolean;
readonly requireModerator?: boolean;
/**
* エンドポイントのリミテーションに関するやつ
* 省略した場合はリミテーションは無いものとして解釈されます。
* また、withCredential が false の場合はリミテーションを行うことはできません。
*/
limit?: {
readonly limit?: {
/**
* 複数のエンドポイントでリミットを共有したい場合に指定するキー
*/
key?: string;
readonly key?: string;
/**
* リミットを適用する期間(ms)
* このプロパティを設定する場合、max プロパティも設定する必要があります。
*/
duration?: number;
readonly duration?: number;
/**
* durationで指定した期間内にいくつまでリクエストできるのか
* このプロパティを設定する場合、duration プロパティも設定する必要があります。
*/
max?: number;
readonly max?: number;
/**
* 最低でもどれくらいの間隔を開けてリクエストしなければならないか(ms)
*/
minInterval?: number;
readonly minInterval?: number;
};
/**
* ファイルの添付を必要とするか否か
* 省略した場合は false として解釈されます。
*/
requireFile?: boolean;
readonly requireFile?: boolean;
/**
* サードパーティアプリからはリクエストすることができないか否か
* 省略した場合は false として解釈されます。
*/
secure?: boolean;
readonly secure?: boolean;
/**
* エンドポイントの種類
* パーミッションの実現に利用されます。
*/
kind?: string;
readonly kind?: string;
}
export interface IEndpoint {

View File

@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -49,66 +49,66 @@ export const meta = {
},
res: {
type: 'array' as const,
optional: false as const, nullable: false as const,
type: 'array',
optional: false, nullable: false,
items: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
properties: {
id: {
type: 'string' as const,
nullable: false as const, optional: false as const,
type: 'string',
nullable: false, optional: false,
format: 'id',
example: 'xxxxxxxxxx',
},
createdAt: {
type: 'string' as const,
nullable: false as const, optional: false as const,
type: 'string',
nullable: false, optional: false,
format: 'date-time',
},
comment: {
type: 'string' as const,
nullable: false as const, optional: false as const,
type: 'string',
nullable: false, optional: false,
},
resolved: {
type: 'boolean' as const,
nullable: false as const, optional: false as const,
type: 'boolean',
nullable: false, optional: false,
example: false,
},
reporterId: {
type: 'string' as const,
nullable: false as const, optional: false as const,
type: 'string',
nullable: false, optional: false,
format: 'id',
},
targetUserId: {
type: 'string' as const,
nullable: false as const, optional: false as const,
type: 'string',
nullable: false, optional: false,
format: 'id',
},
assigneeId: {
type: 'string' as const,
nullable: true as const, optional: false as const,
type: 'string',
nullable: true, optional: false,
format: 'id',
},
reporter: {
type: 'object' as const,
nullable: false as const, optional: false as const,
type: 'object',
nullable: false, optional: false,
ref: 'User',
},
targetUser: {
type: 'object' as const,
nullable: false as const, optional: false as const,
type: 'object',
nullable: false, optional: false,
ref: 'User',
},
assignee: {
type: 'object' as const,
nullable: true as const, optional: true as const,
type: 'object',
nullable: true, optional: true,
ref: 'User',
},
},
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -16,17 +16,17 @@ export const meta = {
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
ref: 'User',
properties: {
token: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
},
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, _me) => {

View File

@ -9,7 +9,7 @@ import { ID } from '@/misc/cafy-id';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -17,7 +17,7 @@ export const meta = {
validator: $.type(ID),
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -6,7 +6,7 @@ import { genId } from '@/misc/gen-id';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -32,7 +32,7 @@ export const meta = {
validator: $.str.min(1),
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -7,7 +7,7 @@ import { ApiError } from '../../../error';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -23,7 +23,7 @@ export const meta = {
id: 'ccac9863-3a03-416e-b899-8a64041118b1',
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../../common/make-pagination-query';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -24,7 +24,7 @@ export const meta = {
validator: $.optional.type(ID),
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -7,7 +7,7 @@ import { ApiError } from '../../../error';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -44,7 +44,7 @@ export const meta = {
id: 'b7aa1727-1354-47bc-a182-3a9c3973d300',
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -6,7 +6,7 @@ import { genId } from '@/misc/gen-id';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -22,40 +22,40 @@ export const meta = {
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
properties: {
id: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
format: 'id',
example: 'xxxxxxxxxx',
},
createdAt: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
format: 'date-time',
},
updatedAt: {
type: 'string' as const,
optional: false as const, nullable: true as const,
type: 'string',
optional: false, nullable: true,
format: 'date-time',
},
title: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
},
text: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
},
imageUrl: {
type: 'string' as const,
optional: false as const, nullable: true as const,
type: 'string',
optional: false, nullable: true,
},
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -7,7 +7,7 @@ import { ApiError } from '../../../error';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -23,7 +23,7 @@ export const meta = {
id: 'ecad8040-a276-4e85-bda9-015a708d291e',
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../../common/make-pagination-query';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -26,48 +26,48 @@ export const meta = {
},
res: {
type: 'array' as const,
optional: false as const, nullable: false as const,
type: 'array',
optional: false, nullable: false,
items: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
properties: {
id: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
format: 'id',
example: 'xxxxxxxxxx',
},
createdAt: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
format: 'date-time',
},
updatedAt: {
type: 'string' as const,
optional: false as const, nullable: true as const,
type: 'string',
optional: false, nullable: true,
format: 'date-time',
},
text: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
},
title: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
},
imageUrl: {
type: 'string' as const,
optional: false as const, nullable: true as const,
type: 'string',
optional: false, nullable: true,
},
reads: {
type: 'number' as const,
optional: false as const, nullable: false as const,
type: 'number',
optional: false, nullable: false,
},
},
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -7,7 +7,7 @@ import { ApiError } from '../../../error';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -32,7 +32,7 @@ export const meta = {
id: 'd3aae5a7-6372-4cb4-b61c-f511ffc2d7cc',
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -7,7 +7,7 @@ import { ID } from '@/misc/cafy-id';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -15,7 +15,7 @@ export const meta = {
validator: $.type(ID),
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -1,14 +0,0 @@
import define from '../../define';
import { Logs } from '@/models/index';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireModerator: true,
};
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {
await Logs.clear(); // TRUNCATE
});

View File

@ -4,9 +4,9 @@ import { createCleanRemoteFilesJob } from '@/queue/index';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -6,9 +6,9 @@ import { DriveFiles } from '@/models/index';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -7,7 +7,7 @@ import { ID } from '@/misc/cafy-id';
export const meta = {
tags: ['admin'],
requireCredential: false as const,
requireCredential: false,
requireModerator: true,
params: {
@ -44,15 +44,15 @@ export const meta = {
},
res: {
type: 'array' as const,
optional: false as const, nullable: false as const,
type: 'array',
optional: false, nullable: false,
items: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
ref: 'DriveFile',
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -7,7 +7,7 @@ import { DriveFiles } from '@/models/index';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -29,137 +29,137 @@ export const meta = {
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
properties: {
id: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
format: 'id',
example: 'xxxxxxxxxx',
},
createdAt: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
format: 'date-time',
},
userId: {
type: 'string' as const,
optional: false as const, nullable: true as const,
type: 'string',
optional: false, nullable: true,
format: 'id',
example: 'xxxxxxxxxx',
},
userHost: {
type: 'string' as const,
optional: false as const, nullable: true as const,
type: 'string',
optional: false, nullable: true,
},
md5: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
format: 'md5',
example: '15eca7fba0480996e2245f5185bf39f2',
},
name: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
example: 'lenna.jpg',
},
type: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
example: 'image/jpeg',
},
size: {
type: 'number' as const,
optional: false as const, nullable: false as const,
type: 'number',
optional: false, nullable: false,
example: 51469,
},
comment: {
type: 'string' as const,
optional: false as const, nullable: true as const,
type: 'string',
optional: false, nullable: true,
},
blurhash: {
type: 'string' as const,
optional: false as const, nullable: true as const,
type: 'string',
optional: false, nullable: true,
},
properties: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
properties: {
width: {
type: 'number' as const,
optional: false as const, nullable: false as const,
type: 'number',
optional: false, nullable: false,
example: 1280,
},
height: {
type: 'number' as const,
optional: false as const, nullable: false as const,
type: 'number',
optional: false, nullable: false,
example: 720,
},
avgColor: {
type: 'string' as const,
optional: true as const, nullable: false as const,
type: 'string',
optional: true, nullable: false,
example: 'rgb(40,65,87)',
},
},
},
storedInternal: {
type: 'boolean' as const,
optional: false as const, nullable: true as const,
type: 'boolean',
optional: false, nullable: true,
example: true,
},
url: {
type: 'string' as const,
optional: false as const, nullable: true as const,
type: 'string',
optional: false, nullable: true,
format: 'url',
},
thumbnailUrl: {
type: 'string' as const,
optional: false as const, nullable: true as const,
type: 'string',
optional: false, nullable: true,
format: 'url',
},
webpublicUrl: {
type: 'string' as const,
optional: false as const, nullable: true as const,
type: 'string',
optional: false, nullable: true,
format: 'url',
},
accessKey: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
},
thumbnailAccessKey: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
},
webpublicAccessKey: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
},
uri: {
type: 'string' as const,
optional: false as const, nullable: true as const,
type: 'string',
optional: false, nullable: true,
},
src: {
type: 'string' as const,
optional: false as const, nullable: true as const,
type: 'string',
optional: false, nullable: true,
},
folderId: {
type: 'string' as const,
optional: false as const, nullable: true as const,
type: 'string',
optional: false, nullable: true,
format: 'id',
example: 'xxxxxxxxxx',
},
isSensitive: {
type: 'boolean' as const,
optional: false as const, nullable: false as const,
type: 'boolean',
optional: false, nullable: false,
},
isLink: {
type: 'boolean' as const,
optional: false as const, nullable: false as const,
type: 'boolean',
optional: false, nullable: false,
},
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -8,7 +8,7 @@ import { ApiError } from '../../../error';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -20,7 +20,7 @@ export const meta = {
validator: $.arr($.str),
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -12,7 +12,7 @@ import { publishBroadcastStream } from '@/services/stream';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -28,7 +28,7 @@ export const meta = {
id: 'fc46b5a4-6b92-4c33-ac66-b806659bb5cf',
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -12,7 +12,7 @@ import { publishBroadcastStream } from '@/services/stream';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -30,17 +30,17 @@ export const meta = {
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
properties: {
id: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
format: 'id',
},
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -9,7 +9,7 @@ import { ApiError } from '../../../error';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -17,7 +17,7 @@ export const meta = {
validator: $.arr($.type(ID)),
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -9,7 +9,7 @@ import { ApiError } from '../../../error';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -25,7 +25,7 @@ export const meta = {
id: 'be83669b-773a-44b7-b1f8-e5e5170ac3c2',
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -6,14 +6,14 @@ import { ID } from '@/misc/cafy-id';
export const meta = {
secure: true,
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
fileId: {
validator: $.type(ID),
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, user) => {

View File

@ -8,7 +8,7 @@ import { ID } from '@/misc/cafy-id';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -37,45 +37,45 @@ export const meta = {
},
res: {
type: 'array' as const,
optional: false as const, nullable: false as const,
type: 'array',
optional: false, nullable: false,
items: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
properties: {
id: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
format: 'id',
},
aliases: {
type: 'array' as const,
optional: false as const, nullable: false as const,
type: 'array',
optional: false, nullable: false,
items: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
},
},
name: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
},
category: {
type: 'string' as const,
optional: false as const, nullable: true as const,
type: 'string',
optional: false, nullable: true,
},
host: {
type: 'string' as const,
optional: false as const, nullable: true as const,
type: 'string',
optional: false, nullable: true,
},
url: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
},
},
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -8,7 +8,7 @@ import { Emoji } from '@/models/entities/emoji';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -32,45 +32,45 @@ export const meta = {
},
res: {
type: 'array' as const,
optional: false as const, nullable: false as const,
type: 'array',
optional: false, nullable: false,
items: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
properties: {
id: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
format: 'id',
},
aliases: {
type: 'array' as const,
optional: false as const, nullable: false as const,
type: 'array',
optional: false, nullable: false,
items: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
},
},
name: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
},
category: {
type: 'string' as const,
optional: false as const, nullable: true as const,
type: 'string',
optional: false, nullable: true,
},
host: {
type: 'string' as const,
optional: false as const, nullable: true as const,
type: 'string',
optional: false, nullable: true,
},
url: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
},
},
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -8,7 +8,7 @@ import { ApiError } from '../../../error';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -20,7 +20,7 @@ export const meta = {
validator: $.arr($.str),
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -8,7 +8,7 @@ import { ApiError } from '../../../error';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -20,7 +20,7 @@ export const meta = {
validator: $.arr($.str),
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -8,7 +8,7 @@ import { ApiError } from '../../../error';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -20,7 +20,7 @@ export const meta = {
validator: $.optional.nullable.str,
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -8,7 +8,7 @@ import { ApiError } from '../../../error';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -36,7 +36,7 @@ export const meta = {
id: '684dec9d-a8c2-4364-9aa8-456c49cb1dc8',
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -6,7 +6,7 @@ import { DriveFiles } from '@/models/index';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -14,7 +14,7 @@ export const meta = {
validator: $.str,
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -7,7 +7,7 @@ import { fetchInstanceMetadata } from '@/services/fetch-instance-metadata';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -15,7 +15,7 @@ export const meta = {
validator: $.str,
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -6,7 +6,7 @@ import { Followings, Users } from '@/models/index';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -14,7 +14,7 @@ export const meta = {
validator: $.str,
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -6,7 +6,7 @@ import { toPuny } from '@/misc/convert-host';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -18,7 +18,7 @@ export const meta = {
validator: $.bool,
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -2,14 +2,14 @@ import define from '../../define';
import { getConnection } from 'typeorm';
export const meta = {
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
tags: ['admin'],
params: {
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async () => {

View File

@ -2,7 +2,7 @@ import define from '../../define';
import { getConnection } from 'typeorm';
export const meta = {
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
tags: ['admin'],
@ -11,8 +11,8 @@ export const meta = {
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
example: {
migrations: {
count: 66,
@ -20,7 +20,7 @@ export const meta = {
},
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async () => {

View File

@ -6,25 +6,25 @@ import { genId } from '@/misc/gen-id';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
properties: {
code: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
example: '2ERUA5VR',
maxLength: 8,
minLength: 8,
},
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async () => {

View File

@ -6,7 +6,7 @@ import { Users } from '@/models/index';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireAdmin: true,
params: {
@ -14,7 +14,7 @@ export const meta = {
validator: $.type(ID),
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -6,7 +6,7 @@ import { Users } from '@/models/index';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireAdmin: true,
params: {
@ -14,7 +14,7 @@ export const meta = {
validator: $.type(ID),
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -8,7 +8,7 @@ import { PromoNotes } from '@/models/index';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -34,7 +34,7 @@ export const meta = {
id: 'ae427aa2-7a41-484f-a18c-2c1104051604',
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, user) => {

View File

@ -5,11 +5,11 @@ import { insertModerationLog } from '@/services/insert-moderation-log';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -5,25 +5,25 @@ import define from '../../../define';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
},
res: {
type: 'array' as const,
optional: false as const, nullable: false as const,
type: 'array',
optional: false, nullable: false,
items: {
type: 'array' as const,
optional: false as const, nullable: false as const,
type: 'array',
optional: false, nullable: false,
items: {
anyOf: [
{
type: 'string' as const,
type: 'string',
},
{
type: 'number' as const,
type: 'number',
},
],
},
@ -33,7 +33,7 @@ export const meta = {
12,
]],
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -5,25 +5,25 @@ import { inboxQueue } from '@/queue/queues';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
},
res: {
type: 'array' as const,
optional: false as const, nullable: false as const,
type: 'array',
optional: false, nullable: false,
items: {
type: 'array' as const,
optional: false as const, nullable: false as const,
type: 'array',
optional: false, nullable: false,
items: {
anyOf: [
{
type: 'string' as const,
type: 'string',
},
{
type: 'number' as const,
type: 'number',
},
],
},
@ -33,7 +33,7 @@ export const meta = {
12,
]],
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -5,7 +5,7 @@ import define from '../../../define';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -24,37 +24,37 @@ export const meta = {
},
res: {
type: 'array' as const,
optional: false as const, nullable: false as const,
type: 'array',
optional: false, nullable: false,
items: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
properties: {
id: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
format: 'id',
},
data: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
},
attempts: {
type: 'number' as const,
optional: false as const, nullable: false as const,
type: 'number',
optional: false, nullable: false,
},
maxAttempts: {
type: 'number' as const,
optional: false as const, nullable: false as const,
type: 'number',
optional: false, nullable: false,
},
timestamp: {
type: 'number' as const,
optional: false as const, nullable: false as const,
type: 'number',
optional: false, nullable: false,
},
},
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -4,30 +4,34 @@ import define from '../../../define';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
properties: {
deliver: {
optional: false, nullable: false,
ref: 'QueueCount',
},
inbox: {
optional: false, nullable: false,
ref: 'QueueCount',
},
db: {
optional: false, nullable: false,
ref: 'QueueCount',
},
objectStorage: {
optional: false, nullable: false,
ref: 'QueueCount',
},
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -7,8 +7,8 @@ import { ApiError } from '../../../error';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireModerator: true as const,
requireCredential: true,
requireModerator: true,
params: {
inbox: {
@ -25,22 +25,22 @@ export const meta = {
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
properties: {
id: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
format: 'id',
},
inbox: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
format: 'url',
},
status: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
default: 'requesting',
enum: [
'requesting',
@ -50,7 +50,7 @@ export const meta = {
},
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, user) => {

View File

@ -4,32 +4,32 @@ import { listRelay } from '@/services/relay';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireModerator: true as const,
requireCredential: true,
requireModerator: true,
params: {
},
res: {
type: 'array' as const,
optional: false as const, nullable: false as const,
type: 'array',
optional: false, nullable: false,
items: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
properties: {
id: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
format: 'id',
},
inbox: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
format: 'url',
},
status: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
default: 'requesting',
enum: [
'requesting',
@ -40,7 +40,7 @@ export const meta = {
},
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, user) => {

View File

@ -5,15 +5,15 @@ import { removeRelay } from '@/services/relay';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireModerator: true as const,
requireCredential: true,
requireModerator: true,
params: {
inbox: {
validator: $.str,
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, user) => {

View File

@ -8,7 +8,7 @@ import { Users, UserProfiles } from '@/models/index';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -18,18 +18,18 @@ export const meta = {
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
properties: {
password: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
minLength: 8,
maxLength: 8,
},
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -6,7 +6,7 @@ import { AbuseUserReports } from '@/models/index';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -14,7 +14,7 @@ export const meta = {
validator: $.type(ID),
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -5,9 +5,9 @@ import { insertModerationLog } from '@/services/insert-moderation-log';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -5,7 +5,7 @@ import { sendEmail } from '@/services/send-email';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -19,7 +19,7 @@ export const meta = {
validator: $.str,
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -5,7 +5,7 @@ import define from '../../define';
import { redisClient } from '../../../../db/redis';
export const meta = {
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
tags: ['admin', 'meta'],
@ -14,81 +14,81 @@ export const meta = {
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
properties: {
machine: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
},
os: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
example: 'linux',
},
node: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
},
psql: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
},
cpu: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
properties: {
model: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
},
cores: {
type: 'number' as const,
optional: false as const, nullable: false as const,
type: 'number',
optional: false, nullable: false,
},
},
},
mem: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
properties: {
total: {
type: 'number' as const,
optional: false as const, nullable: false as const,
type: 'number',
optional: false, nullable: false,
format: 'bytes',
},
},
},
fs: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
properties: {
total: {
type: 'number' as const,
optional: false as const, nullable: false as const,
type: 'number',
optional: false, nullable: false,
format: 'bytes',
},
used: {
type: 'number' as const,
optional: false as const, nullable: false as const,
type: 'number',
optional: false, nullable: false,
format: 'bytes',
},
},
},
net: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
properties: {
interface: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
example: 'eth0',
},
},
},
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async () => {

View File

@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -26,44 +26,44 @@ export const meta = {
},
res: {
type: 'array' as const,
optional: false as const, nullable: false as const,
type: 'array',
optional: false, nullable: false,
items: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
properties: {
id: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
format: 'id',
},
createdAt: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
format: 'date-time',
},
type: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
},
info: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
},
userId: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
format: 'id',
},
user: {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'User',
type: 'object',
optional: false, nullable: false,
ref: 'UserDetailed',
},
},
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -6,7 +6,7 @@ import { Users } from '@/models/index';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -16,148 +16,148 @@ export const meta = {
},
res: {
type: 'object' as const,
nullable: false as const, optional: false as const,
type: 'object',
nullable: false, optional: false,
properties: {
id: {
type: 'string' as const,
nullable: false as const, optional: false as const,
type: 'string',
nullable: false, optional: false,
format: 'id',
},
createdAt: {
type: 'string' as const,
nullable: false as const, optional: false as const,
type: 'string',
nullable: false, optional: false,
format: 'date-time',
},
updatedAt: {
type: 'string' as const,
nullable: true as const, optional: false as const,
type: 'string',
nullable: true, optional: false,
format: 'date-time',
},
lastFetchedAt: {
type: 'string' as const,
nullable: true as const, optional: false as const,
type: 'string',
nullable: true, optional: false,
},
username: {
type: 'string' as const,
nullable: false as const, optional: false as const,
type: 'string',
nullable: false, optional: false,
},
name: {
type: 'string' as const,
nullable: false as const, optional: false as const,
type: 'string',
nullable: true, optional: false,
},
folowersCount: {
type: 'number' as const,
nullable: false as const, optional: false as const,
type: 'number',
nullable: false, optional: true,
},
followingCount: {
type: 'number' as const,
nullable: false as const, optional: false as const,
type: 'number',
nullable: false, optional: false,
},
notesCount: {
type: 'number' as const,
nullable: false as const, optional: false as const,
type: 'number',
nullable: false, optional: false,
},
avatarId: {
type: 'string' as const,
nullable: true as const, optional: false as const,
type: 'string',
nullable: true, optional: false,
},
bannerId: {
type: 'string' as const,
nullable: true as const, optional: false as const,
type: 'string',
nullable: true, optional: false,
},
tags: {
type: 'array' as const,
nullable: false as const, optional: false as const,
type: 'array',
nullable: false, optional: false,
items: {
type: 'string' as const,
nullable: false as const, optional: false as const,
type: 'string',
nullable: false, optional: false,
},
},
avatarUrl: {
type: 'string' as const,
nullable: true as const, optional: false as const,
type: 'string',
nullable: true, optional: false,
format: 'url',
},
bannerUrl: {
type: 'string' as const,
nullable: true as const, optional: false as const,
type: 'string',
nullable: true, optional: false,
format: 'url',
},
avatarBlurhash: {
type: 'any' as const,
nullable: true as const, optional: false as const,
type: 'any',
nullable: true, optional: false,
default: null,
},
bannerBlurhash: {
type: 'any' as const,
nullable: true as const, optional: false as const,
type: 'any',
nullable: true, optional: false,
default: null,
},
isSuspended: {
type: 'boolean' as const,
nullable: false as const, optional: false as const,
type: 'boolean',
nullable: false, optional: false,
},
isSilenced: {
type: 'boolean' as const,
nullable: false as const, optional: false as const,
type: 'boolean',
nullable: false, optional: false,
},
isLocked: {
type: 'boolean' as const,
nullable: false as const, optional: false as const,
type: 'boolean',
nullable: false, optional: false,
},
isBot: {
type: 'boolean' as const,
nullable: false as const, optional: false as const,
type: 'boolean',
nullable: false, optional: false,
},
isCat: {
type: 'boolean' as const,
nullable: false as const, optional: false as const,
type: 'boolean',
nullable: false, optional: false,
},
isAdmin: {
type: 'boolean' as const,
nullable: false as const, optional: false as const,
type: 'boolean',
nullable: false, optional: false,
},
isModerator: {
type: 'boolean' as const,
nullable: false as const, optional: false as const,
type: 'boolean',
nullable: false, optional: false,
},
emojis: {
type: 'array' as const,
nullable: false as const, optional: false as const,
type: 'array',
nullable: false, optional: false,
items: {
type: 'string' as const,
nullable: false as const, optional: false as const,
type: 'string',
nullable: false, optional: false,
},
},
host: {
type: 'string' as const,
nullable: true as const, optional: false as const,
type: 'string',
nullable: true, optional: false,
},
inbox: {
type: 'string' as const,
nullable: true as const, optional: false as const,
type: 'string',
nullable: true, optional: false,
},
sharedInbox: {
type: 'string' as const,
nullable: true as const, optional: false as const,
type: 'string',
nullable: true, optional: false,
},
featured: {
type: 'string' as const,
nullable: true as const, optional: false as const,
type: 'string',
nullable: true, optional: false,
},
uri: {
type: 'string' as const,
nullable: true as const, optional: false as const,
type: 'string',
nullable: true, optional: false,
},
token: {
type: 'string' as const,
nullable: false as const, optional: false as const,
type: 'string',
nullable: true, optional: false,
default: '<MASKED>',
},
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -5,7 +5,7 @@ import { Users } from '@/models/index';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -64,15 +64,15 @@ export const meta = {
},
res: {
type: 'array' as const,
nullable: false as const, optional: false as const,
type: 'array',
nullable: false, optional: false,
items: {
type: 'object' as const,
nullable: false as const, optional: false as const,
ref: 'User',
type: 'object',
nullable: false, optional: false,
ref: 'UserDetailed',
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -7,7 +7,7 @@ import { insertModerationLog } from '@/services/insert-moderation-log';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -15,7 +15,7 @@ export const meta = {
validator: $.type(ID),
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -11,7 +11,7 @@ import { publishUserEvent } from '@/services/stream';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -19,7 +19,7 @@ export const meta = {
validator: $.type(ID),
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -7,7 +7,7 @@ import { insertModerationLog } from '@/services/insert-moderation-log';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -15,7 +15,7 @@ export const meta = {
validator: $.type(ID),
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -8,7 +8,7 @@ import { doPostUnsuspend } from '@/services/unsuspend-user';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -16,7 +16,7 @@ export const meta = {
validator: $.type(ID),
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -9,7 +9,7 @@ import { ID } from '@/misc/cafy-id';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireAdmin: true,
params: {
@ -297,7 +297,7 @@ export const meta = {
validator: $.optional.bool,
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -6,7 +6,7 @@ import { insertModerationLog } from '@/services/insert-moderation-log';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireCredential: true,
requireModerator: true,
params: {
@ -17,7 +17,7 @@ export const meta = {
validator: $.bool,
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -7,7 +7,7 @@ import { makePaginationQuery } from '../common/make-pagination-query';
export const meta = {
tags: ['meta'],
requireCredential: false as const,
requireCredential: false,
params: {
limit: {
@ -30,48 +30,48 @@ export const meta = {
},
res: {
type: 'array' as const,
optional: false as const, nullable: false as const,
type: 'array',
optional: false, nullable: false,
items: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
properties: {
id: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
format: 'id',
example: 'xxxxxxxxxx',
},
createdAt: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
format: 'date-time',
},
updatedAt: {
type: 'string' as const,
optional: false as const, nullable: true as const,
type: 'string',
optional: false, nullable: true,
format: 'date-time',
},
text: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
},
title: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
},
imageUrl: {
type: 'string' as const,
optional: false as const, nullable: true as const,
type: 'string',
optional: false, nullable: true,
},
isRead: {
type: 'boolean' as const,
optional: false as const, nullable: false as const,
type: 'boolean',
optional: true, nullable: false,
},
},
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, user) => {

View File

@ -9,7 +9,7 @@ import { publishInternalEvent } from '@/services/stream';
export const meta = {
tags: ['antennas'],
requireCredential: true as const,
requireCredential: true,
kind: 'write:account',
@ -74,11 +74,11 @@ export const meta = {
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
ref: 'Antenna',
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, user) => {

View File

@ -8,7 +8,7 @@ import { publishInternalEvent } from '@/services/stream';
export const meta = {
tags: ['antennas'],
requireCredential: true as const,
requireCredential: true,
kind: 'write:account',
@ -25,7 +25,7 @@ export const meta = {
id: 'b34dcf9d-348f-44bb-99d0-6c9314cfe2df',
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, user) => {

View File

@ -4,20 +4,20 @@ import { Antennas } from '@/models/index';
export const meta = {
tags: ['antennas', 'account'],
requireCredential: true as const,
requireCredential: true,
kind: 'read:account',
res: {
type: 'array' as const,
optional: false as const, nullable: false as const,
type: 'array',
optional: false, nullable: false,
items: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
ref: 'Antenna',
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -12,7 +12,7 @@ import { generateBlockedUserQuery } from '../../common/generate-block-query';
export const meta = {
tags: ['antennas', 'account', 'notes'],
requireCredential: true as const,
requireCredential: true,
kind: 'read:account',
@ -52,15 +52,15 @@ export const meta = {
},
res: {
type: 'array' as const,
optional: false as const, nullable: false as const,
type: 'array',
optional: false, nullable: false,
items: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
ref: 'Note',
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, user) => {

View File

@ -7,7 +7,7 @@ import { Antennas } from '@/models/index';
export const meta = {
tags: ['antennas', 'account'],
requireCredential: true as const,
requireCredential: true,
kind: 'read:account',
@ -26,11 +26,11 @@ export const meta = {
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
ref: 'Antenna',
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -8,7 +8,7 @@ import { publishInternalEvent } from '@/services/stream';
export const meta = {
tags: ['antennas'],
requireCredential: true as const,
requireCredential: true,
kind: 'write:account',
@ -83,11 +83,11 @@ export const meta = {
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
ref: 'Antenna',
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, user) => {

View File

@ -7,7 +7,7 @@ import ms from 'ms';
export const meta = {
tags: ['federation'],
requireCredential: true as const,
requireCredential: true,
limit: {
duration: ms('1hour'),
@ -24,10 +24,10 @@ export const meta = {
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -12,11 +12,12 @@ import { User } from '@/models/entities/user';
import { fetchMeta } from '@/misc/fetch-meta';
import { isActor, isPost, getApId } from '@/remote/activitypub/type';
import ms from 'ms';
import { SchemaType } from '@/misc/schema';
export const meta = {
tags: ['federation'],
requireCredential: true as const,
requireCredential: true,
limit: {
duration: ms('1hour'),
@ -38,21 +39,41 @@ export const meta = {
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
properties: {
type: {
type: 'string' as const,
optional: false as const, nullable: false as const,
enum: ['User', 'Note'],
optional: false, nullable: false,
oneOf: [
{
type: 'object',
properties: {
type: {
type: 'string',
optional: false, nullable: false,
enum: ['User'],
},
object: {
type: 'object',
optional: false, nullable: false,
ref: 'UserDetailedNotMe',
}
}
},
object: {
type: 'object' as const,
optional: false as const, nullable: false as const,
},
},
{
type: 'object',
properties: {
type: {
type: 'string',
optional: false, nullable: false,
enum: ['Note'],
},
object: {
type: 'object',
optional: false, nullable: false,
ref: 'Note',
}
}
}
],
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {
@ -67,7 +88,7 @@ export default define(meta, async (ps) => {
/***
* URIからUserかNoteを解決する
*/
async function fetchAny(uri: string) {
async function fetchAny(uri: string): Promise<SchemaType<typeof meta['res']> | null> {
// URIがこのサーバーを指しているなら、ローカルユーザーIDとしてDBからフェッチ
if (uri.startsWith(config.url + '/')) {
const parts = uri.split('/');
@ -96,8 +117,8 @@ async function fetchAny(uri: string) {
}
// ブロックしてたら中断
const meta = await fetchMeta();
if (meta.blockedHosts.includes(extractDbHost(uri))) return null;
const fetchedMeta = await fetchMeta();
if (fetchedMeta.blockedHosts.includes(extractDbHost(uri))) return null;
// URI(AP Object id)としてDB検索
{
@ -172,7 +193,7 @@ async function fetchAny(uri: string) {
return null;
}
async function mergePack(user: User | null | undefined, note: Note | null | undefined) {
async function mergePack(user: User | null | undefined, note: Note | null | undefined): Promise<SchemaType<typeof meta.res> | null> {
if (user != null) {
return {
type: 'User',

View File

@ -8,7 +8,7 @@ import { secureRndstr } from '@/misc/secure-rndstr';
export const meta = {
tags: ['app'],
requireCredential: false as const,
requireCredential: false,
params: {
name: {
@ -31,11 +31,11 @@ export const meta = {
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
ref: 'App',
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, user) => {

View File

@ -13,12 +13,6 @@ export const meta = {
},
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'App',
},
errors: {
noSuchApp: {
message: 'No such app.',
@ -28,11 +22,11 @@ export const meta = {
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
ref: 'App',
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, user, token) => {

View File

@ -9,7 +9,7 @@ import { secureRndstr } from '@/misc/secure-rndstr';
export const meta = {
tags: ['auth'],
requireCredential: true as const,
requireCredential: true,
secure: true,
@ -26,7 +26,7 @@ export const meta = {
id: '9c72d8de-391a-43c1-9d06-08d29efde8df',
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, user) => {

View File

@ -9,7 +9,7 @@ import { genId } from '@/misc/gen-id';
export const meta = {
tags: ['auth'],
requireCredential: false as const,
requireCredential: false,
params: {
appSecret: {
@ -18,16 +18,16 @@ export const meta = {
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
properties: {
token: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
},
url: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
format: 'url',
},
},
@ -40,7 +40,7 @@ export const meta = {
id: '92f93e63-428e-4f2f-a5a4-39e1407fe998',
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -6,7 +6,7 @@ import { AuthSessions } from '@/models/index';
export const meta = {
tags: ['auth'],
requireCredential: false as const,
requireCredential: false,
params: {
token: {
@ -23,26 +23,26 @@ export const meta = {
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
properties: {
id: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
format: 'id',
},
app: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
ref: 'App',
},
token: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
},
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, user) => {

View File

@ -6,7 +6,7 @@ import { Apps, AuthSessions, AccessTokens, Users } from '@/models/index';
export const meta = {
tags: ['auth'],
requireCredential: false as const,
requireCredential: false,
params: {
appSecret: {
@ -19,18 +19,18 @@ export const meta = {
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
properties: {
accessToken: {
type: 'string' as const,
optional: false as const, nullable: false as const,
type: 'string',
optional: false, nullable: false,
},
user: {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'User',
type: 'object',
optional: false, nullable: false,
ref: 'UserDetailedNotMe',
},
},
},
@ -54,7 +54,7 @@ export const meta = {
id: '8c8a4145-02cc-4cca-8e66-29ba60445a8e',
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -15,7 +15,7 @@ export const meta = {
max: 100,
},
requireCredential: true as const,
requireCredential: true,
kind: 'write:blocks',
@ -46,11 +46,11 @@ export const meta = {
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'User',
type: 'object',
optional: false, nullable: false,
ref: 'UserDetailedNotMe',
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, user) => {

View File

@ -15,7 +15,7 @@ export const meta = {
max: 100,
},
requireCredential: true as const,
requireCredential: true,
kind: 'write:blocks',
@ -46,11 +46,11 @@ export const meta = {
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'User',
type: 'object',
optional: false, nullable: false,
ref: 'UserDetailedNotMe',
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, user) => {

View File

@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query';
export const meta = {
tags: ['account'],
requireCredential: true as const,
requireCredential: true,
kind: 'read:blocks',
@ -27,15 +27,15 @@ export const meta = {
},
res: {
type: 'array' as const,
optional: false as const, nullable: false as const,
type: 'array',
optional: false, nullable: false,
items: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
ref: 'Blocking',
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -9,7 +9,7 @@ import { ID } from '@/misc/cafy-id';
export const meta = {
tags: ['channels'],
requireCredential: true as const,
requireCredential: true,
kind: 'write:channels',
@ -28,8 +28,8 @@ export const meta = {
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
ref: 'Channel',
},
@ -40,7 +40,7 @@ export const meta = {
id: 'cd1e9f3e-5a12-4ab4-96f6-5d0a2cc32050',
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, user) => {

View File

@ -4,18 +4,18 @@ import { Channels } from '@/models/index';
export const meta = {
tags: ['channels'],
requireCredential: false as const,
requireCredential: false,
res: {
type: 'array' as const,
optional: false as const, nullable: false as const,
type: 'array',
optional: false, nullable: false,
items: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
ref: 'Channel',
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -9,7 +9,7 @@ import { publishUserEvent } from '@/services/stream';
export const meta = {
tags: ['channels'],
requireCredential: true as const,
requireCredential: true,
kind: 'write:channels',
@ -26,7 +26,7 @@ export const meta = {
id: 'c0031718-d573-4e85-928e-10039f1fbb68',
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, user) => {

View File

@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query';
export const meta = {
tags: ['channels', 'account'],
requireCredential: true as const,
requireCredential: true,
kind: 'read:channels',
@ -27,15 +27,15 @@ export const meta = {
},
res: {
type: 'array' as const,
optional: false as const, nullable: false as const,
type: 'array',
optional: false, nullable: false,
items: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
ref: 'Channel',
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query';
export const meta = {
tags: ['channels', 'account'],
requireCredential: true as const,
requireCredential: true,
kind: 'read:channels',
@ -27,15 +27,15 @@ export const meta = {
},
res: {
type: 'array' as const,
optional: false as const, nullable: false as const,
type: 'array',
optional: false, nullable: false,
items: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
ref: 'Channel',
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -7,7 +7,7 @@ import { Channels } from '@/models/index';
export const meta = {
tags: ['channels'],
requireCredential: false as const,
requireCredential: false,
params: {
channelId: {
@ -16,8 +16,8 @@ export const meta = {
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
ref: 'Channel',
},
@ -28,7 +28,7 @@ export const meta = {
id: '6f6c314b-7486-4897-8966-c04a66a02923',
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -9,7 +9,7 @@ import { activeUsersChart } from '@/services/chart/index';
export const meta = {
tags: ['notes', 'channels'],
requireCredential: false as const,
requireCredential: false,
params: {
channelId: {
@ -39,11 +39,11 @@ export const meta = {
},
res: {
type: 'array' as const,
optional: false as const, nullable: false as const,
type: 'array',
optional: false, nullable: false,
items: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
ref: 'Note',
},
},
@ -55,7 +55,7 @@ export const meta = {
id: '4d0eeeba-a02c-4c3c-9966-ef60d38d2e7f',
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, user) => {

View File

@ -8,7 +8,7 @@ import { publishUserEvent } from '@/services/stream';
export const meta = {
tags: ['channels'],
requireCredential: true as const,
requireCredential: true,
kind: 'write:channels',
@ -25,7 +25,7 @@ export const meta = {
id: '19959ee9-0153-4c51-bbd9-a98c49dc59d6',
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, user) => {

View File

@ -7,7 +7,7 @@ import { Channels, DriveFiles } from '@/models/index';
export const meta = {
tags: ['channels'],
requireCredential: true as const,
requireCredential: true,
kind: 'write:channels',
@ -30,8 +30,8 @@ export const meta = {
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
type: 'object',
optional: false, nullable: false,
ref: 'Channel',
},
@ -54,7 +54,7 @@ export const meta = {
id: 'e86c14a4-0da2-4032-8df3-e737a04c7f3b',
},
},
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {

View File

@ -23,7 +23,7 @@ export const meta = {
},
res: convertLog(activeUsersChart.schema),
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -23,7 +23,7 @@ export const meta = {
},
res: convertLog(driveChart.schema),
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -23,7 +23,7 @@ export const meta = {
},
res: convertLog(federationChart.schema),
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -27,7 +27,7 @@ export const meta = {
},
res: convertLog(hashtagChart.schema),
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -27,7 +27,7 @@ export const meta = {
},
res: convertLog(instanceChart.schema),
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -23,7 +23,7 @@ export const meta = {
},
res: convertLog(networkChart.schema),
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -23,7 +23,7 @@ export const meta = {
},
res: convertLog(notesChart.schema),
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -28,7 +28,7 @@ export const meta = {
},
res: convertLog(perUserDriveChart.schema),
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -28,7 +28,7 @@ export const meta = {
},
res: convertLog(perUserFollowingChart.schema),
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -28,7 +28,7 @@ export const meta = {
},
res: convertLog(perUserNotesChart.schema),
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

View File

@ -28,7 +28,7 @@ export const meta = {
},
res: convertLog(perUserReactionsChart.schema),
};
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps) => {

Some files were not shown because too many files have changed in this diff Show More