diff --git a/packages/backend/src/server/api/endpoints/admin/show-users.ts b/packages/backend/src/server/api/endpoints/admin/show-users.ts index 426973f28..0e6f21896 100644 --- a/packages/backend/src/server/api/endpoints/admin/show-users.ts +++ b/packages/backend/src/server/api/endpoints/admin/show-users.ts @@ -6,45 +6,10 @@ import { UserEntityService } from '@/core/entities/UserEntityService.js'; import { sqlLikeEscape } from '@/misc/sql-like-escape.js'; import { RoleService } from '@/core/RoleService.js'; -export const meta = { - tags: ['admin'], - - requireCredential: true, - requireModerator: true, - - res: { - type: 'array', - nullable: false, optional: false, - items: { - type: 'object', - nullable: false, optional: false, - ref: 'UserDetailed', - }, - }, -} as const; - -export const paramDef = { - type: 'object', - properties: { - limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 }, - offset: { type: 'integer', default: 0 }, - sort: { type: 'string', enum: ['+follower', '-follower', '+createdAt', '-createdAt', '+updatedAt', '-updatedAt', '+lastActiveDate', '-lastActiveDate'] }, - state: { type: 'string', enum: ['all', 'alive', 'available', 'admin', 'moderator', 'adminOrModerator', 'suspended'], default: 'all' }, - origin: { type: 'string', enum: ['combined', 'local', 'remote'], default: 'combined' }, - username: { type: 'string', nullable: true, default: null }, - hostname: { - type: 'string', - nullable: true, - default: null, - description: 'The local host is represented with `null`.', - }, - }, - required: [], -} as const; - // eslint-disable-next-line import/no-default-export @Injectable() -export default class extends Endpoint { +export default class extends Endpoint<'admin/show-users'> { + name = 'admin/show-users' as const; constructor( @Inject(DI.usersRepository) private usersRepository: UsersRepository, @@ -52,7 +17,7 @@ export default class extends Endpoint { private userEntityService: UserEntityService, private roleService: RoleService, ) { - super(meta, paramDef, async (ps, me) => { + super(async (ps, me) => { const query = this.usersRepository.createQueryBuilder('user'); switch (ps.state) { diff --git a/packages/misskey-js/src/endpoints.ts b/packages/misskey-js/src/endpoints.ts index b60256856..d62cf6d22 100644 --- a/packages/misskey-js/src/endpoints.ts +++ b/packages/misskey-js/src/endpoints.ts @@ -1588,7 +1588,7 @@ export const endpoints = { properties: { reportId: { type: 'string', format: 'misskey:id' }, forward: { type: 'boolean', default: false }, - }, + } satisfies Record, required: ['reportId'], }, res: undefined, @@ -1639,7 +1639,7 @@ export const endpoints = { limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 }, sinceId: { type: 'string', format: 'misskey:id' }, untilId: { type: 'string', format: 'misskey:id' }, - }, + } satisfies Record, required: [], }, res: { @@ -1725,7 +1725,7 @@ export const endpoints = { $ref: 'https://misskey-hub.net/api/schemas/Role', } }, - }, + } satisfies Record, required: [ 'email', 'emailVerified', @@ -1752,6 +1752,38 @@ export const endpoints = { } }], }, + 'admin/show-users': { + tags: ['admin'], + + requireCredential: true, + requireModerator: true, + + defines: [{ + req: { + type: 'object', + properties: { + limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 }, + offset: { type: 'integer', default: 0 }, + sort: { type: 'string', enum: ['+follower', '-follower', '+createdAt', '-createdAt', '+updatedAt', '-updatedAt', '+lastActiveDate', '-lastActiveDate'] }, + state: { type: 'string', enum: ['all', 'alive', 'available', 'admin', 'moderator', 'adminOrModerator', 'suspended'], default: 'all' }, + origin: { type: 'string', enum: ['combined', 'local', 'remote'], default: 'combined' }, + username: { type: ['string', 'null'], default: null }, + hostname: { + type: ['string', 'null'], + default: null, + description: 'The local host is represented with `null`.', + }, + } satisfies Record, + required: [], + }, + res: { + type: 'array', + items: { + $ref: 'https://misskey-hub.net/api/schemas/UserDetailed', + }, + } + }], + } } as const satisfies { [x: string]: IEndpointMeta; }; /** diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6755c7a16..1ffd58672 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -630,7 +630,7 @@ importers: version: 29.5.0 schema-type: specifier: github:misskey-dev/schema-type - version: github.com/misskey-dev/schema-type/d4ff8d1c43883a0facacc9ec47ec50aa239828bc(typescript@5.0.4) + version: github.com/misskey-dev/schema-type/65413af4ef676dafb5d06ebc04dce39c74b3a8f9(typescript@5.0.4) packages/frontend: dependencies: @@ -1030,7 +1030,7 @@ importers: version: 4.4.0 schema-type: specifier: github:misskey-dev/schema-type - version: github.com/misskey-dev/schema-type/d4ff8d1c43883a0facacc9ec47ec50aa239828bc(typescript@5.0.4) + version: github.com/misskey-dev/schema-type/65413af4ef676dafb5d06ebc04dce39c74b3a8f9(typescript@5.0.4) ts-essentials: specifier: ^9.3.2 version: 9.3.2(typescript@5.0.4) @@ -20557,9 +20557,9 @@ packages: version: 0.0.0 dev: false - github.com/misskey-dev/schema-type/d4ff8d1c43883a0facacc9ec47ec50aa239828bc(typescript@5.0.4): - resolution: {tarball: https://codeload.github.com/misskey-dev/schema-type/tar.gz/d4ff8d1c43883a0facacc9ec47ec50aa239828bc} - id: github.com/misskey-dev/schema-type/d4ff8d1c43883a0facacc9ec47ec50aa239828bc + github.com/misskey-dev/schema-type/65413af4ef676dafb5d06ebc04dce39c74b3a8f9(typescript@5.0.4): + resolution: {tarball: https://codeload.github.com/misskey-dev/schema-type/tar.gz/65413af4ef676dafb5d06ebc04dce39c74b3a8f9} + id: github.com/misskey-dev/schema-type/65413af4ef676dafb5d06ebc04dce39c74b3a8f9 name: schema-type version: 1.0.0 dependencies: