4 Commits

6 changed files with 84 additions and 2 deletions

View File

@@ -1,5 +1,21 @@
# Changelog # Changelog
## 2026-03-02 - 2.4.0 - feat(gitlab)
add repository branches and tags endpoints and corresponding types
- Add getRepoBranches(projectId, opts?) to list repository branches (supports pagination with page and perPage; defaults to page=1, perPage=50).
- Add getRepoTags(projectId, opts?) to list repository tags (supports pagination with page and perPage; defaults to page=1, perPage=50).
- Introduce IGitLabBranch and IGitLabTag interfaces and export them from ts/index.ts.
## 2026-02-28 - 2.3.0 - feat(gitlab)
add support for GitLab protected branches (list and unprotect)
- Added IGitLabProtectedBranch interface
- Added GitLabClient.getProtectedBranches(projectId) returning IGitLabProtectedBranch[]
- Added GitLabClient.unprotectBranch(projectId, branchName) to remove branch protection
- Exported IGitLabProtectedBranch from index.ts
- Non-breaking API additions; recommended minor version bump
## 2026-02-28 - 2.2.0 - feat(gitlabclient) ## 2026-02-28 - 2.2.0 - feat(gitlabclient)
add deleteProject method to delete a project using GitLab API DELETE /api/v4/projects/:id add deleteProject method to delete a project using GitLab API DELETE /api/v4/projects/:id

View File

@@ -1,6 +1,6 @@
{ {
"name": "@apiclient.xyz/gitlab", "name": "@apiclient.xyz/gitlab",
"version": "2.2.0", "version": "2.4.0",
"private": false, "private": false,
"description": "A TypeScript client for the GitLab API, providing easy access to projects, groups, CI/CD variables, and pipelines.", "description": "A TypeScript client for the GitLab API, providing easy access to projects, groups, CI/CD variables, and pipelines.",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",

View File

@@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@apiclient.xyz/gitlab', name: '@apiclient.xyz/gitlab',
version: '2.2.0', version: '2.4.0',
description: 'A TypeScript client for the GitLab API, providing easy access to projects, groups, CI/CD variables, and pipelines.' description: 'A TypeScript client for the GitLab API, providing easy access to projects, groups, CI/CD variables, and pipelines.'
} }

View File

@@ -6,6 +6,9 @@ import type {
IGitLabGroup, IGitLabGroup,
IGitLabVariable, IGitLabVariable,
IVariableOptions, IVariableOptions,
IGitLabProtectedBranch,
IGitLabBranch,
IGitLabTag,
IGitLabPipeline, IGitLabPipeline,
IGitLabJob, IGitLabJob,
ITestConnectionResult, ITestConnectionResult,
@@ -369,6 +372,46 @@ export class GitLabClient {
); );
} }
// ---------------------------------------------------------------------------
// Repository Branches & Tags
// ---------------------------------------------------------------------------
public async getRepoBranches(projectId: number | string, opts?: IListOptions): Promise<IGitLabBranch[]> {
const page = opts?.page || 1;
const perPage = opts?.perPage || 50;
return this.request<IGitLabBranch[]>(
'GET',
`/api/v4/projects/${encodeURIComponent(projectId)}/repository/branches?page=${page}&per_page=${perPage}`,
);
}
public async getRepoTags(projectId: number | string, opts?: IListOptions): Promise<IGitLabTag[]> {
const page = opts?.page || 1;
const perPage = opts?.perPage || 50;
return this.request<IGitLabTag[]>(
'GET',
`/api/v4/projects/${encodeURIComponent(projectId)}/repository/tags?page=${page}&per_page=${perPage}`,
);
}
// ---------------------------------------------------------------------------
// Protected Branches
// ---------------------------------------------------------------------------
public async getProtectedBranches(projectId: number | string): Promise<IGitLabProtectedBranch[]> {
return this.request<IGitLabProtectedBranch[]>(
'GET',
`/api/v4/projects/${encodeURIComponent(projectId)}/protected_branches`,
);
}
public async unprotectBranch(projectId: number | string, branchName: string): Promise<void> {
await this.request(
'DELETE',
`/api/v4/projects/${encodeURIComponent(projectId)}/protected_branches/${encodeURIComponent(branchName)}`,
);
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Project Deletion // Project Deletion
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@@ -44,6 +44,12 @@ export interface IVariableOptions {
environment_scope?: string; environment_scope?: string;
} }
export interface IGitLabProtectedBranch {
id: number;
name: string;
allow_force_push: boolean;
}
export interface IGitLabPipeline { export interface IGitLabPipeline {
id: number; id: number;
project_id: number; project_id: number;
@@ -64,6 +70,20 @@ export interface IGitLabJob {
duration: number; duration: number;
} }
export interface IGitLabBranch {
name: string;
commit: {
id: string;
};
}
export interface IGitLabTag {
name: string;
commit: {
id: string;
};
}
export interface ITestConnectionResult { export interface ITestConnectionResult {
ok: boolean; ok: boolean;
error?: string; error?: string;

View File

@@ -4,6 +4,9 @@ export type {
IGitLabProject, IGitLabProject,
IGitLabGroup, IGitLabGroup,
IGitLabVariable, IGitLabVariable,
IGitLabProtectedBranch,
IGitLabBranch,
IGitLabTag,
IVariableOptions, IVariableOptions,
IGitLabPipeline, IGitLabPipeline,
IGitLabJob, IGitLabJob,