import { BaseResource } from '@gitbeaker/requester-utils'; import { RequestHelper, endpoint } from '../infrastructure'; import type { GitlabAPIResponse, OneOrNoneOf, PaginationRequestOptions, PaginationTypes, ShowExpanded, Sudo, } from '../infrastructure'; import type { ProjectSchema } from './Projects'; import type { IssueSchema } from './Issues'; import type { MergeRequestSchema } from './MergeRequests'; import type { MilestoneSchema } from '../templates/ResourceMilestones'; import type { SimpleSnippetSchema } from './Snippets'; import type { CommitSchema } from './Commits'; import type { NoteSchema } from '../templates/ResourceNotes'; import type { SimpleUserSchema } from './Users'; export interface BlobSchema extends Record { id: number; basename: string; data: string; path: string; filename: string; ref: string; startline: number; project_id: number; } export interface SearchCommitSchema extends CommitSchema { projectId: string | number; } export type SearchScopes = | 'projects' | 'issues' | 'merge_requests' | 'milestones' | 'snippet_titles' | 'wiki_blobs' | 'commits' | 'blobs' | 'notes' | 'users'; export type AllSearchOptions = { orderBy?: 'created_at'; state?: 'issues' | 'merge_requests'; confidential?: boolean; }; export class Search extends BaseResource { all( scope: 'users', search: string, options?: OneOrNoneOf<{ projectId: string | number; groupId: string | number }> & AllSearchOptions & Sudo & ShowExpanded & PaginationRequestOptions

, ): Promise>; all( scope: 'notes', search: string, options?: OneOrNoneOf<{ projectId: string | number; groupId: string | number }> & AllSearchOptions & Sudo & ShowExpanded & PaginationRequestOptions

, ): Promise>; all( scope: 'blobs', search: string, options?: OneOrNoneOf<{ projectId: string | number; groupId: string | number }> & AllSearchOptions & Sudo & ShowExpanded & PaginationRequestOptions

, ): Promise>; all( scope: 'commits', search: string, options?: OneOrNoneOf<{ projectId: string | number; groupId: string | number }> & AllSearchOptions & Sudo & ShowExpanded & PaginationRequestOptions

, ): Promise>; all( scope: 'wiki_blobs', search: string, options?: OneOrNoneOf<{ projectId: string | number; groupId: string | number }> & AllSearchOptions & Sudo & ShowExpanded & PaginationRequestOptions

, ): Promise>; all( scope: 'snippet_titles', search: string, options?: OneOrNoneOf<{ projectId: string | number; groupId: string | number }> & AllSearchOptions & Sudo & ShowExpanded & PaginationRequestOptions

, ): Promise>; all( scope: 'milestones', search: string, options?: OneOrNoneOf<{ projectId: string | number; groupId: string | number }> & AllSearchOptions & Sudo & ShowExpanded & PaginationRequestOptions

, ): Promise>; all( scope: 'merge_requests', search: string, options?: OneOrNoneOf<{ projectId: string | number; groupId: string | number }> & AllSearchOptions & Sudo & ShowExpanded & PaginationRequestOptions

, ): Promise>; all( scope: 'issues', search: string, options?: OneOrNoneOf<{ projectId: string | number; groupId: string | number }> & AllSearchOptions & Sudo & ShowExpanded & PaginationRequestOptions

, ): Promise>; all( scope: 'projects', search: string, options?: OneOrNoneOf<{ projectId: string | number; groupId: string | number }> & AllSearchOptions & Sudo & ShowExpanded & PaginationRequestOptions

, ): Promise>; all( scope: SearchScopes, search: string, options?: OneOrNoneOf<{ projectId: string | number; groupId: string | number }> & AllSearchOptions & Sudo & ShowExpanded & PaginationRequestOptions

, ): any { const { projectId, groupId, ...opts } = options || {}; let url: string; if (projectId) url = endpoint`projects/${projectId}/`; else if (groupId) url = endpoint`groups/${groupId}/`; else url = ''; return RequestHelper.get()(this, `${url}search`, { scope, search, ...opts, }); } }