import { normalizePipelineLocator, pickAuthInput, request } from '../core.ts' import { asRecord, slimPipeline } from '../shape.ts' /** * Fetch one GitLab pipeline by project + id, or by pipeline URL. * * @example * import getGitlabPipeline from 'kody:@kody/gitlab/pipelines/get' * const pipeline = await getGitlabPipeline({ * project: 'example-group/example-project', * pipelineId: 88, * }) */ export default async function getGitlabPipeline(params: Record = {}) { const auth = pickAuthInput(params) const { projectId, projectPath, pipelineId } = normalizePipelineLocator(params) const response = await request>({ ...auth, path: `/projects/${projectId}/pipelines/${pipelineId}`, throwOnError: true, }) return { ...slimPipeline(asRecord(response.data)), projectPath, auth: response.auth, } }