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

294 lines
6.9 KiB
TypeScript
Raw Normal View History

2023-05-02 19:51:41 +03:00
import { localUsernameSchema, passwordSchema } from "./schemas/user";
2023-05-04 13:56:24 +03:00
import type { JSONSchema7 } from 'schema-type';
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;
};
};
2023-05-02 20:31:17 +03:00
readonly defines: ReadonlyArray<{ req: JSONSchema7 | undefined; res: JSONSchema7 | undefined; }>;
2023-05-02 15:05:17 +03:00
/**
*
* 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: {
2023-05-15 11:59:30 +03:00
allOf: [{
$ref: 'https://misskey-hub.net/api/schemas/MeDetailed',
}, {
type: 'object',
properties: {
token: {
type: 'string',
},
},
required: ['token'],
}],
2023-05-02 15:05:17 +03:00
},
}],
},
"admin/accounts/delete": {
tags: ['admin'],
requireCredential: true,
requireAdmin: true,
defines: [{
req: {
type: 'object',
properties: {
userId: { type: 'string', format: 'misskey:id' },
},
required: ['userId'],
},
res: undefined,
}],
},
2023-05-12 10:54:50 +03:00
"admin/ad/create": {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
defines: [{
req: {
type: 'object',
properties: {
url: { type: 'string', minLength: 1 },
memo: { type: 'string' },
place: { type: 'string' },
priority: { type: 'string' },
ratio: { type: 'integer' },
expiresAt: { type: 'integer' },
startsAt: { type: 'integer' },
imageUrl: { type: 'string', minLength: 1 },
},
required: ['url', 'memo', 'place', 'priority', 'ratio', 'expiresAt', 'startsAt', 'imageUrl'],
},
res: undefined,
}]
},
"admin/ad/delete": {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
errors: {
noSuchAd: {
message: 'No such ad.',
code: 'NO_SUCH_AD',
id: 'ccac9863-3a03-416e-b899-8a64041118b1',
},
},
defines: [{
req: {
type: 'object',
properties: {
id: { type: 'string', format: 'misskey:id' },
},
required: ['id'],
},
res: undefined,
}],
},
"admin/ad/list": {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
defines: [{
req: {
type: 'object',
properties: {
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
sinceId: { type: 'string', format: 'misskey:id' },
untilId: { type: 'string', format: 'misskey:id' },
},
required: [],
},
res: {
type: 'array',
2023-05-15 11:45:38 +03:00
items: {
$ref: 'https://misskey-hub.net/api/schemas/Ad',
},
2023-05-12 10:54:50 +03:00
},
}],
},
2023-05-15 11:30:52 +03:00
"admin/ad/update": {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
errors: {
noSuchAd: {
message: 'No such ad.',
code: 'NO_SUCH_AD',
id: 'b7aa1727-1354-47bc-a182-3a9c3973d300',
},
},
defines: [{
req: {
type: 'object',
properties: {
id: { type: 'string', format: 'misskey:id' },
memo: { type: 'string' },
url: { type: 'string', minLength: 1 },
imageUrl: { type: 'string', minLength: 1 },
place: { type: 'string' },
priority: { type: 'string' },
ratio: { type: 'integer' },
expiresAt: { type: 'integer' },
startsAt: { type: 'integer' },
},
required: ['id', 'memo', 'url', 'imageUrl', 'place', 'priority', 'ratio', 'expiresAt', 'startsAt'],
},
res: undefined,
}],
},
2023-05-15 11:59:30 +03:00
"admin/announcements/create": {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
defines: [{
req: {
type: 'object',
properties: {
title: { type: 'string', minLength: 1 },
text: { type: 'string', minLength: 1 },
imageUrl: { type: 'string', nullable: true, minLength: 1 },
},
required: ['title', 'text', 'imageUrl'],
},
res: {
$ref: 'https://misskey-hub.net/api/schemas/Announcement',
}
}],
},
2023-05-02 20:31:17 +03:00
} as const satisfies { [x: string]: IEndpointMeta; };