mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 16:42:56 +00:00
refactor: split api into api, api-cli & api-plugin
This commit is contained in:
@@ -39,7 +39,6 @@ export * from './types.js';
|
||||
|
||||
/**
|
||||
* Sleep for a number of milliseconds
|
||||
*
|
||||
* @param ms Number of milliseconds to wait
|
||||
*/
|
||||
export async function sleep(ms: number): Promise<void> {
|
||||
@@ -105,7 +104,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Instantiate new GitLab API
|
||||
*
|
||||
* @param rootUrl Root URL of the GitLab API
|
||||
* @param privateToken Private token for the GitLab API
|
||||
*/
|
||||
@@ -116,7 +114,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Add member to a group or a project
|
||||
*
|
||||
* @param scope MembershipScope of the ID
|
||||
* @param id ID of the group or project
|
||||
* @param userId ID of the user
|
||||
@@ -139,7 +136,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Create an issue in GitLab
|
||||
*
|
||||
* @param projectId ID of the project to create the issue in
|
||||
* @param title Title of the issue
|
||||
* @param description Description of the issue (can contain slash commands)
|
||||
@@ -156,7 +152,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Create a new label
|
||||
*
|
||||
* @param projectId ID of the project to create the label in
|
||||
* @param name Name of the label to create
|
||||
* @param description Description of the label to create
|
||||
@@ -185,7 +180,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Create a milestone in a project
|
||||
*
|
||||
* @param projectId Project ID to create milestone in
|
||||
* @param title Title of the milestone to create
|
||||
*/
|
||||
@@ -197,7 +191,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Create a note (comment) in an issue/merge request
|
||||
*
|
||||
* @param projectId Project ID, the issue belongs to
|
||||
* @param scope Scope of the note
|
||||
* @param iid IID of the issue/merge request to create the note in
|
||||
@@ -214,7 +207,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Delete a label
|
||||
*
|
||||
* @param projectId ID of the project to delete the label from
|
||||
* @param name Name of the label to delete
|
||||
*/
|
||||
@@ -226,7 +218,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Delete a member from a group or a project
|
||||
*
|
||||
* @param scope MembershipScope of the ID
|
||||
* @param id ID of the group or project
|
||||
* @param userId ID of the user
|
||||
@@ -237,7 +228,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Edit an existing label
|
||||
*
|
||||
* @param projectId ID of the project to edit the label in
|
||||
* @param name Name of the label to edit
|
||||
* @param newValues New values for the label
|
||||
@@ -260,7 +250,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Edit member in a group or a project
|
||||
*
|
||||
* @param scope MembershipScope of the ID
|
||||
* @param id ID of the group or project
|
||||
* @param userId ID of the user
|
||||
@@ -283,7 +272,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Get branches for a project
|
||||
*
|
||||
* @param projectId Project ID to get branches for
|
||||
*/
|
||||
public async getBranchesForProject(projectId: number): Promise<Branch[]> {
|
||||
@@ -292,7 +280,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Get a file from GitLab
|
||||
*
|
||||
* @param projectId ID of the project the file belongs to
|
||||
* @param filePath Path to the file - url encoded
|
||||
* @param commitish Commitish of the file
|
||||
@@ -307,7 +294,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Get a list of files
|
||||
*
|
||||
* @param projectId ID of the project
|
||||
*/
|
||||
public async getFileList(projectId: number): Promise<TreeFile[]> {
|
||||
@@ -316,7 +302,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Get issues
|
||||
*
|
||||
* @param options Options to get issues
|
||||
*/
|
||||
public async getIssues(options: ApiGetIssuesOptions = {}): Promise<Issue[]> {
|
||||
@@ -348,7 +333,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Get labels of a project
|
||||
*
|
||||
* @param projectId ID of the project to get the labels for
|
||||
*/
|
||||
public async getLabels(projectId: number): Promise<Label[]> {
|
||||
@@ -357,7 +341,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Get members of a group or a project
|
||||
*
|
||||
* @param scope MembershipScope of the ID
|
||||
* @param id ID of the group or project
|
||||
*/
|
||||
@@ -367,7 +350,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Get a merge request approval
|
||||
*
|
||||
* @param projectId ID of the project the merge request belongs to
|
||||
* @param mergeRequestIid IID of the merge request
|
||||
*/
|
||||
@@ -382,7 +364,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Get discussions of a merge request
|
||||
*
|
||||
* @param projectId ID of the project the merge request belongs to
|
||||
* @param mergeRequestIid IID of the merge request
|
||||
*/
|
||||
@@ -394,7 +375,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Get merge requests of a group or a project
|
||||
*
|
||||
* @param scope MembershipScope of the ID
|
||||
* @param id ID of the group or project
|
||||
* @param state State to filter the merge requests by
|
||||
@@ -416,7 +396,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Get milestones for a project
|
||||
*
|
||||
* @param projectId Project ID to get milestones for
|
||||
*/
|
||||
public async getMilestonesForProject(projectId: number): Promise<Milestone[]> {
|
||||
@@ -425,7 +404,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Get notes for issue
|
||||
*
|
||||
* @param projectId Project ID of issue to get notes for
|
||||
* @param issue Issue to get notes for
|
||||
*/
|
||||
@@ -435,7 +413,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Get projects for a group
|
||||
*
|
||||
* @param groupId Group ID to get projects for
|
||||
*/
|
||||
public async getProjectsForGroup(groupId: number): Promise<Project[]> {
|
||||
@@ -444,7 +421,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Get sub groups of a group
|
||||
*
|
||||
* @param groupId Group ID to get subgroups for
|
||||
*/
|
||||
public async getSubGroupsForGroup(groupId: number): Promise<Group[]> {
|
||||
@@ -453,7 +429,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Get tags of a project
|
||||
*
|
||||
* @param projectId ID of the project to get the tags for
|
||||
*/
|
||||
public async getTags(projectId: number): Promise<Tag[]> {
|
||||
@@ -462,13 +437,12 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Query a GitLab API URL
|
||||
*
|
||||
* @param url GitLab API URL to query
|
||||
* @param options HTTP method/verb
|
||||
*/
|
||||
public async makeGitLabAPIRequest<T = unknown>(url: string, options?: ApiRequestOptions): Promise<T> {
|
||||
// remove leading slash
|
||||
const _url = url.replace(/^\/+/g, '');
|
||||
const _url = url.replaceAll(/^\/+/g, '');
|
||||
|
||||
const _options: Required<ApiRequestOptions> = {
|
||||
// eslint-disable-next-line unicorn/no-null
|
||||
@@ -533,7 +507,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Protect a branch
|
||||
*
|
||||
* @param projectId ID of the project the branch belongs to
|
||||
* @param branch Branch to protect
|
||||
*/
|
||||
@@ -548,7 +521,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Set assignee for an issue
|
||||
*
|
||||
* @param issue Issue to set assignee for
|
||||
* @param userId ID of the assignee to set for the issue
|
||||
*/
|
||||
@@ -563,7 +535,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Set assignee for an merge request
|
||||
*
|
||||
* @param mergeRequest Merge request to set assignee for
|
||||
* @param userId ID of the assignee to set for the merge request
|
||||
*/
|
||||
@@ -578,7 +549,6 @@ export class Api {
|
||||
|
||||
/**
|
||||
* Set milestone for an issue
|
||||
*
|
||||
* @param issue Issue to set milestone for
|
||||
* @param milestoneId ID of the milestone to set for the issue
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user