mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-25 23:44:01 +02:00
wip
This commit is contained in:
162
packages/misskey-js/src/endpoints.ts
Normal file
162
packages/misskey-js/src/endpoints.ts
Normal file
@@ -0,0 +1,162 @@
|
||||
import { localUsernameSchema, passwordSchema } from "./schema/user";
|
||||
|
||||
export type RolePolicies = {
|
||||
gtlAvailable: boolean;
|
||||
ltlAvailable: boolean;
|
||||
canPublicNote: boolean;
|
||||
canInvite: boolean;
|
||||
canManageCustomEmojis: boolean;
|
||||
canSearchNotes: boolean;
|
||||
canHideAds: boolean;
|
||||
driveCapacityMb: number;
|
||||
pinLimit: number;
|
||||
antennaLimit: number;
|
||||
wordMuteLimit: number;
|
||||
webhookLimit: number;
|
||||
clipLimit: number;
|
||||
noteEachClipsLimit: number;
|
||||
userListLimit: number;
|
||||
userEachUserListsLimit: number;
|
||||
rateLimitFactor: number;
|
||||
};
|
||||
|
||||
export interface IEndpointMeta {
|
||||
readonly stability?: 'deprecated' | 'experimental' | 'stable';
|
||||
|
||||
readonly tags?: ReadonlyArray<string>;
|
||||
|
||||
readonly errors?: {
|
||||
readonly [key: string]: {
|
||||
readonly message: string;
|
||||
readonly code: string;
|
||||
readonly id: string;
|
||||
};
|
||||
};
|
||||
|
||||
readonly defines: { req: Schema | undefined; res: Schema | undefined; }[];
|
||||
|
||||
/**
|
||||
* このエンドポイントにリクエストするのにユーザー情報が必須か否か
|
||||
* 省略した場合は false として解釈されます。
|
||||
*/
|
||||
readonly requireCredential?: boolean;
|
||||
|
||||
/**
|
||||
* isModeratorなロールを必要とするか
|
||||
*/
|
||||
readonly requireModerator?: boolean;
|
||||
|
||||
/**
|
||||
* isAdministratorなロールを必要とするか
|
||||
*/
|
||||
readonly requireAdmin?: boolean;
|
||||
|
||||
readonly requireRolePolicy?: keyof RolePolicies;
|
||||
|
||||
/**
|
||||
* 引っ越し済みのユーザーによるリクエストを禁止するか
|
||||
* 省略した場合は false として解釈されます。
|
||||
*/
|
||||
readonly prohibitMoved?: boolean;
|
||||
|
||||
/**
|
||||
* エンドポイントのリミテーションに関するやつ
|
||||
* 省略した場合はリミテーションは無いものとして解釈されます。
|
||||
*/
|
||||
readonly limit?: {
|
||||
|
||||
/**
|
||||
* 複数のエンドポイントでリミットを共有したい場合に指定するキー
|
||||
*/
|
||||
readonly key?: string;
|
||||
|
||||
/**
|
||||
* リミットを適用する期間(ms)
|
||||
* このプロパティを設定する場合、max プロパティも設定する必要があります。
|
||||
*/
|
||||
readonly duration?: number;
|
||||
|
||||
/**
|
||||
* durationで指定した期間内にいくつまでリクエストできるのか
|
||||
* このプロパティを設定する場合、duration プロパティも設定する必要があります。
|
||||
*/
|
||||
readonly max?: number;
|
||||
|
||||
/**
|
||||
* 最低でもどれくらいの間隔を開けてリクエストしなければならないか(ms)
|
||||
*/
|
||||
readonly minInterval?: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* ファイルの添付を必要とするか否か
|
||||
* 省略した場合は false として解釈されます。
|
||||
*/
|
||||
readonly requireFile?: boolean;
|
||||
|
||||
/**
|
||||
* サードパーティアプリからはリクエストすることができないか否か
|
||||
* 省略した場合は false として解釈されます。
|
||||
*/
|
||||
readonly secure?: boolean;
|
||||
|
||||
/**
|
||||
* エンドポイントの種類
|
||||
* パーミッションの実現に利用されます。
|
||||
*/
|
||||
readonly kind?: string;
|
||||
|
||||
readonly description?: string;
|
||||
|
||||
/**
|
||||
* GETでのリクエストを許容するか否か
|
||||
*/
|
||||
readonly allowGet?: boolean;
|
||||
|
||||
/**
|
||||
* 正常応答をキャッシュ (Cache-Control: public) する秒数
|
||||
*/
|
||||
readonly cacheSec?: number;
|
||||
}
|
||||
|
||||
export const endpoints = {
|
||||
"admin/accounts/create": {
|
||||
tags: ['admin'],
|
||||
defines: [{
|
||||
req: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
username: localUsernameSchema,
|
||||
password: passwordSchema,
|
||||
},
|
||||
required: ['username', 'password'],
|
||||
},
|
||||
res: {
|
||||
type: 'object',
|
||||
ref: 'User',
|
||||
properties: {
|
||||
token: {
|
||||
type: 'string',
|
||||
},
|
||||
required: ['token'],
|
||||
},
|
||||
},
|
||||
}],
|
||||
},
|
||||
"admin/accounts/delete": {
|
||||
tags: ['admin'],
|
||||
|
||||
requireCredential: true,
|
||||
requireAdmin: true,
|
||||
defines: [{
|
||||
req: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
userId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['userId'],
|
||||
},
|
||||
res: undefined,
|
||||
}],
|
||||
},
|
||||
} as const;
|
||||
Reference in New Issue
Block a user