feat: add GitLab API

This commit is contained in:
Karl-Philipp Wulfert
2018-11-29 12:08:06 +01:00
commit 54d212963c
13 changed files with 3427 additions and 0 deletions

241
src/types.ts Normal file
View File

@@ -0,0 +1,241 @@
/*
* Copyright (C) 2018 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* GitLab label
*/
export interface Label {
color: string;
description?: string;
name: string;
}
/**
* GitLab commit
*/
export interface GitLabCommit {
author_email: string;
author_name: string;
authored_date: string;
committed_date: string;
committer_email: string;
committer_name: string;
id: string;
message: string;
parent_ids: string[];
}
/**
* GitLab tag
*/
export interface Tag {
commit: GitLabCommit;
message: string | null;
name: string;
release: null;
}
/**
* GitLab namespace
*/
export interface GitLabNamespace {
full_path: string;
id: number;
kind: string;
name: string;
path: string;
}
/**
* GitLab project
*/
export interface Project {
archived: boolean;
avatar_url: string;
container_registry_enabled: boolean;
created_at: string;
creator_id: number;
default_branch: string;
description: string;
forks_count: number;
http_url_to_repo: string;
id: number;
issues_enabled: boolean;
jobs_enabled: boolean;
last_activity_at: string;
lfs_enabled: boolean;
merge_requests_enabled: boolean;
name: string;
name_with_namespace: string;
namespace: GitLabNamespace;
only_allow_merge_if_all_discussions_are_resolved: boolean;
only_allow_merge_if_pipeline_succeeds: boolean;
open_issues_count: number;
path: string;
path_with_namespace: string;
public_jobs: boolean;
request_access_enabled: boolean;
shared_runners_enabled: boolean;
shared_with_groups: any[];
snippets_enabled: boolean;
ssh_url_to_repo: string;
star_count: number;
tag_list: string[];
visibility: string;
web_url: string;
wiki_enabled: boolean;
}
/**
* GitLab tree file
*/
export interface TreeFile {
id: string;
mode: string;
name: string;
path: string;
type: string;
}
/**
* A member of a group or a project
*/
export interface Member extends GitLabUser {
access_level: AccessLevel;
expires_at: string;
}
/**
* Available GitLab access levels
*/
export enum AccessLevel {
Guest = 10,
Reporter = 20,
Developer = 30,
Maintainer = 40,
Owner = 50,
}
/**
* A GitLab milestone
*/
export interface Milestone {
created_at: string;
description: string | null;
due_date: string;
id: number;
iid: number;
project_id: number;
start_date: string;
state: string;
title: string;
updated_at: string;
}
/**
* A GitLab branch
*/
export interface Branch {
commit: GitLabCommit;
developers_can_merge: boolean;
developers_can_push: boolean;
merged: boolean;
name: string;
protected: boolean;
}
/**
* A GitLab user
*/
export interface GitLabUser {
avatar_url: string;
id: number;
name: string;
state: string;
username: string;
web_url: string;
}
/**
* A GitLab issue
*/
export interface Issue extends GitLabThingWithTimeStats {
assignee: GitLabUser;
assignees: GitLabUser[];
author: GitLabUser;
closed_at: string | null;
confidential: boolean;
created_at: string;
description: string | null;
discussion_locked: boolean | null;
downvotes: number;
due_date: string | null;
id: number;
iid: number;
labels: string[];
milestone: Milestone | null;
project_id: number;
state: string;
title: string;
updated_at: string;
upvotes: number;
user_notes_count: number;
web_url: string;
}
/**
* A GitLab merge request
*/
export interface MergeRequest extends GitLabThingWithTimeStats {
assignee: GitLabUser;
author: GitLabUser;
created_at: string;
description: string | null;
discussion_locked: boolean | null;
downvotes: number;
force_remove_source_branch: boolean;
id: number;
iid: number;
labels: Label[];
merge_commit_sha: string;
merge_status: string;
merge_when_pipeline_succeeds: boolean;
milestone: Milestone;
project_id: number;
sha: string;
should_remove_source_branch: boolean;
source_branch: string;
source_project_id: number;
state: string;
target_branch: string;
target_project_id: number;
title: string;
updated_at: string;
upvotes: number;
user_notes_count: number;
web_url: string;
work_in_progress: boolean;
}
/**
* A GitLab thing with time stats
*/
export interface GitLabThingWithTimeStats {
time_stats: {
human_time_estimate: number | null;
human_total_time_spent: number | null;
time_estimate: number;
total_time_spent: number;
};
}