Sharkey/packages/misskey-js/src/endpoints.ts

163 lines
4.2 KiB
TypeScript
Raw Normal View History

2023-05-02 19:51:41 +03:00
import { localUsernameSchema, passwordSchema } from "./schemas/user";
2023-05-02 15:05:17 +03:00
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;