# @ts-racers/gitlab-fetch

> library to get groups, projects, pipelines and commits from gitlab

Latest version **1.0.0** (published 2023-01-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ts-racers/gitlab-fetch
pnpm add @ts-racers/gitlab-fetch
yarn add @ts-racers/gitlab-fetch
bun add @ts-racers/gitlab-fetch
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2023-01-03 |
| First published | 2023-01-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 1 |
| Unpacked size | 236.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Franco Bálsamo |
| Maintainers | vicmans, fjbalsamo |
| Keywords | gilab, api, v4, gql |

## Links

- npm: https://www.npmjs.com/package/@ts-racers/gitlab-fetch
- Repository: https://github.com/fjbalsamo/gitlab-fetch
- Homepage: https://github.com/fjbalsamo/gitlab-fetch#readme
- Issues: https://github.com/fjbalsamo/gitlab-fetch/issues
- npm.io page: https://npm.io/package/@ts-racers/gitlab-fetch

## Dependencies (1)

- [axios](https://npm.io/package/axios.md) ^1.2.1

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2023-01-03

## README

# Gitlab Fetch

library to get groups, projects, pipelines and commits from gitlab

## Install

```bash
npm install @ts-racers/gitlab-fetch # or yarn add @ts-racers/gitlab-fetch
```

## Usage

### Groups

```typescript
import { GitlabFetch } from '@ts-racers/gitlab-fetch';

const { groups } = new GitlabFetch('gitlab-token');

(async () => {
  // get one group
  const myGroup = await groups.getOne('my-group');
  console.log(myGroup);
  /*
  {
    id: number; 
    avatarUrl?: string
    description: string;
    name: string;
    fullName: string;
    path: string;
  } | undefined
  */

  // get one group and yours subgroups
  const descendantGroups = await groups.descendantGroups({
    fullPath: 'my-group',
    includeParentDescendants: true, // default is false
  });
  console.log(descendantGroups);
  /*
  {
     group: {id: number; ... }
     subgroups: Array<{id: number; ... }>
  } | undefined
  */
})();
```

### Projects

```typescript
import { GitlabFetch } from '@ts-racers/gitlab-fetch';

const { projects } = new GitlabFetch('gitlab-token');

(async () => {
  // get one group
  const myProjects = await projects.projectsByGroup({
    fullPath: 'my-group',
    includeSubGroups: true, // default is false
  });
  console.log(myProjects);
  /*
  {
    group: {id: number, ... },
    projects: Array<{
      id: number;
      name: string;
      fullPath: string;
      path: string;
      webUrl: string;
      sshUrlToRepo: string;
      httpUrlToRepo: string;
      description: null | string;
      avatarUrl?: string;
      languages: {
        names: string[];
        percentages: Array<{
          name: string;
          share: number;
        }>;
      };
      createdAt: Date;
      lastActivityAt: Date;
      defaultBranch: string;
      pipelineCounts: {
        finished: number;
        pending: number;
        running: number;
        all: number;
      };
      topics: string[];
    }>
  } | undefined
  */

  // get one group and yours subgroups
  const descendantGroups = await groups.descendantGroups({
    fullPath: 'my-group',
    includeParentDescendants: true, // default is false
  });
  console.log(descendantGroups);
  /*
  {
     group: {id: number; ... }
     subgroups: Array<{id: number; ... }>
  } | undefined
  */
})();
```

### Pipelines and Jobs

```typescript
import { GitlabFetch } from '@ts-racers/gitlab-fetch';

const { pipelines } = new GitlabFetch(
  'gitlab-token'
);

(async () => {
  // get pipelines and jobs
  const pipesAndJobs = await pipelines.pipelinesAndJobs({
    fullPath: 'path/of/my/gitlab-project',
    updatedAfter: new Date(), // default is undefined
  });
  console.log(pipesAndJobs);
  /*
  {
    pipelines: Array<{
      project_fullPath: string;
      id: number;
      coverage: number;
      createdAt: Date;
      startedAt: Date;
      finishedAt: Date;
      ref: string;
      refPath: string;
      beforeSha: string;
      sha: string;
      status: string;
      duration: number;
      queuedDuration: number;
      commit: {
        authorName: string;
        authoredDate: Date;
        sha: string;
        webUrl: string;
      };
    }>
    jobs: Array<{
      pipeline_id: number;
      project_fullPath: string;
      name: string;
      refName: string;
      coverage: number;
      queuedDuration: number;
      duration: number;
      id: number;
      stage_name: string;
      createdByTag: boolean;
      status: string;
      createdAt: Date;
      startedAt?: Date;
      finishedAt?: Date;
    }>
  }
  */
```

### Merge Requests

```typescript
import { GitlabFetch } from '@ts-racers/gitlab-fetch';

const { mergeRequests } = new GitlabFetch(
  'gitlab-token'
);

(async () => {
  // get merge requests commits
  const mergeRequestsCommits = await mergeRequests.mergeRequestsCommits({
    fullPath: 'path/of/my/gitlab-project',
    targetBranches: ["master", "main"],
    updatedAfter: new Date(), // default is undefined
  });
  console.log(mergeRequestsCommits);
  /*
  [
    {
      project_fullPath: string;
      id: number;
      sourceBranch: string;
      targetBranch: string;
      mergedAt: Date;
      createdAt: Date;
      approved: boolean;
      approvedBy: Array<{ name: string; username: string }>;
      author: { name: string; username: string };
      commits: Array<{
        sha: string;
        shortId: string;
        title: string;
        authorName: string;
        authorEmail: string;
        authoredDate: Date;
        description: string;
      }>;
    }
  ]
  */
```

---
_Source: https://npm.io/package/@ts-racers/gitlab-fetch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
