import { BaseResource } from '@gitbeaker/requester-utils'; import { RequestHelper } from '../infrastructure'; import type { GitlabAPIResponse, PaginationRequestOptions, PaginationTypes, ShowExpanded, Sudo, } from '../infrastructure'; export interface TopicSchema extends Record { id: number; name: string; description: string; total_projects_count: number; avatar_url: string; } export class Topics extends BaseResource { all( options?: { search?: string; withoutProjects?: boolean } & PaginationRequestOptions

& Sudo & ShowExpanded, ): Promise> { return RequestHelper.get()(this, 'topics', options); } create( name: string, { avatar, ...options }: { avatar?: { content: Blob; filename: string }; description?: string } & Sudo & ShowExpanded = {}, ): Promise> { const opts: Record = { name, ...options, }; if (avatar) { opts.isForm = true; opts.file = [avatar.content, avatar.filename]; } return RequestHelper.post()(this, 'topics', opts); } edit( topicId: number, { avatar, ...options }: { name?: string; title?: string; avatar?: { content: Blob; filename: string }; description?: string; } & Sudo & ShowExpanded = {}, ): Promise> { const opts: Record = { ...options }; if (avatar) { opts.isForm = true; opts.file = [avatar.content, avatar.filename]; } return RequestHelper.put()(this, `topics/${topicId}`, opts); } merge( sourceTopicId: number, targetTopicId: number, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.post()(this, `topics/merge`, { sourceTopicId, targetTopicId, ...options, }); } remove( topicId: number, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.del()(this, `topics/${topicId}`, options); } show( topicId: number, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.get()(this, `topics/${topicId}`, options); } }