import { BaseResource } from '@gitbeaker/requester-utils'; import { RequestHelper, endpoint } from '../infrastructure'; import type { GitlabAPIResponse, MappedOmit, PaginationRequestOptions, PaginationTypes, ShowExpanded, Sudo, } from '../infrastructure'; import type { TodoSchema } from './TodoLists'; import type { SimpleUserSchema } from './Users'; import type { GroupSchema } from './Groups'; import type { SimpleLabelSchema } from '../templates/ResourceLabels'; export interface EpicSchema extends Record { id: number; iid: number; group_id: number; parent_id: number; parent_iid: number; title: string; description: string; state: string; confidential: string; web_url: string; references: { short: string; relative: string; full: string; }; author: MappedOmit; start_date?: string; start_date_is_fixed: boolean; start_date_fixed?: string; start_date_from_inherited_source?: string; due_date: string; due_date_is_fixed: boolean; due_date_fixed?: string; due_date_from_inherited_source: string; created_at: string; updated_at: string; closed_at: string; labels: string[] | SimpleLabelSchema[]; upvotes: number; downvotes: number; _links: { self: string; epic_issues: string; group: string; }; } export interface EpicSchemaWithExpandedLabels extends EpicSchema { labels: SimpleLabelSchema[]; } export interface EpicSchemaWithBasicLabels extends EpicSchema { labels: string[]; } export interface EpicTodoSchema extends TodoSchema { group: Pick; target_type: 'Epic'; target: EpicSchema; } export type AllEpicsOptions = { authorId?: number; authorUsername?: string; labels?: string; withLabelsDetails?: boolean; orderBy?: 'created_at' | 'updated_at' | 'title'; sort?: string; search?: string; state?: string; createdAfter?: string; createdBefore?: string; updatedAfter?: string; updatedBefore?: string; includeAncestorGroups?: boolean; includeDescendantGroups?: boolean; myReactionEmoji?: string; not?: Record; }; export type CreateEpicOptions = { labels?: string; description?: string; color?: string; confidential?: boolean; createdAt?: string; startDateIsFixed?: boolean; startDateFixed?: string; dueDateIsFixed?: boolean; dueDateFixed?: string; parentId?: number | string; }; export type EditEpicOptions = { addLabels?: string; confidential?: boolean; description?: string; dueDateFixed?: string; dueDateIsFixed?: boolean; labels?: string; parentId?: number | string; removeLabels?: string; startDateFixed?: string; startDateIsFixed?: boolean; stateEvent?: string; title?: string; updatedAt?: string; color?: string; }; export class Epics extends BaseResource { all( groupId: string | number, options: AllEpicsOptions & PaginationRequestOptions

& Sudo & ShowExpanded & { withLabelsDetails: true }, ): Promise>; all( groupId: string | number, options?: AllEpicsOptions & PaginationRequestOptions

& Sudo & ShowExpanded & { withLabelsDetails?: false }, ): Promise>; all( groupId: string | number, options?: AllEpicsOptions & PaginationRequestOptions

& Sudo & ShowExpanded, ): Promise> { return RequestHelper.get()(this, endpoint`groups/${groupId}/epics`, options); } create( groupId: string | number, title: string, options?: CreateEpicOptions & Sudo & ShowExpanded, ): Promise> { return RequestHelper.post()(this, endpoint`groups/${groupId}/epics`, { title, ...options, }); } createTodo( groupId: string | number, epicIId: number, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.post()( this, endpoint`groups/${groupId}/epics/${epicIId}/todos`, options, ); } edit( groupId: string | number, epicIId: number, options?: EditEpicOptions & Sudo & ShowExpanded, ): Promise, C, E, void>> { return RequestHelper.put>()( this, endpoint`groups/${groupId}/epics/${epicIId}`, options, ); } remove( groupId: string | number, epicIId: number, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.del()(this, endpoint`groups/${groupId}/epics/${epicIId}`, options); } show( groupId: string | number, epicIId: number, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.get()( this, endpoint`groups/${groupId}/epics/${epicIId}`, options, ); } }