Merge pull request #17 from chad-loder/main
Implement GitLab Issues and Issue Links API
This commit is contained in:
866
build/index.js
866
build/index.js
File diff suppressed because it is too large
Load Diff
236
build/schemas.js
236
build/schemas.js
@ -5,6 +5,31 @@ export const GitLabAuthorSchema = z.object({
|
|||||||
email: z.string(),
|
email: z.string(),
|
||||||
date: z.string(),
|
date: z.string(),
|
||||||
});
|
});
|
||||||
|
// Namespace related schemas
|
||||||
|
export const GitLabNamespaceSchema = z.object({
|
||||||
|
id: z.number(),
|
||||||
|
name: z.string(),
|
||||||
|
path: z.string(),
|
||||||
|
kind: z.enum(["user", "group"]),
|
||||||
|
full_path: z.string(),
|
||||||
|
parent_id: z.number().nullable(),
|
||||||
|
avatar_url: z.string().nullable(),
|
||||||
|
web_url: z.string(),
|
||||||
|
members_count_with_descendants: z.number().optional(),
|
||||||
|
billable_members_count: z.number().optional(),
|
||||||
|
max_seats_used: z.number().optional(),
|
||||||
|
seats_in_use: z.number().optional(),
|
||||||
|
plan: z.string().optional(),
|
||||||
|
end_date: z.string().nullable().optional(),
|
||||||
|
trial_ends_on: z.string().nullable().optional(),
|
||||||
|
trial: z.boolean().optional(),
|
||||||
|
root_repository_size: z.number().optional(),
|
||||||
|
projects_count: z.number().optional(),
|
||||||
|
});
|
||||||
|
export const GitLabNamespaceExistsResponseSchema = z.object({
|
||||||
|
exists: z.boolean(),
|
||||||
|
suggests: z.array(z.string()).optional(),
|
||||||
|
});
|
||||||
// Repository related schemas
|
// Repository related schemas
|
||||||
export const GitLabOwnerSchema = z.object({
|
export const GitLabOwnerSchema = z.object({
|
||||||
username: z.string(), // Changed from login to match GitLab API
|
username: z.string(), // Changed from login to match GitLab API
|
||||||
@ -28,7 +53,51 @@ export const GitLabRepositorySchema = z.object({
|
|||||||
created_at: z.string().optional(),
|
created_at: z.string().optional(),
|
||||||
last_activity_at: z.string().optional(),
|
last_activity_at: z.string().optional(),
|
||||||
default_branch: z.string().optional(),
|
default_branch: z.string().optional(),
|
||||||
|
namespace: z.object({
|
||||||
|
id: z.number(),
|
||||||
|
name: z.string(),
|
||||||
|
path: z.string(),
|
||||||
|
kind: z.string(),
|
||||||
|
full_path: z.string(),
|
||||||
|
avatar_url: z.string().nullable().optional(),
|
||||||
|
web_url: z.string().optional(),
|
||||||
|
}).optional(),
|
||||||
|
readme_url: z.string().optional().nullable(),
|
||||||
|
topics: z.array(z.string()).optional(),
|
||||||
|
tag_list: z.array(z.string()).optional(), // deprecated but still present
|
||||||
|
open_issues_count: z.number().optional(),
|
||||||
|
archived: z.boolean().optional(),
|
||||||
|
forks_count: z.number().optional(),
|
||||||
|
star_count: z.number().optional(),
|
||||||
|
permissions: z.object({
|
||||||
|
project_access: z.object({
|
||||||
|
access_level: z.number(),
|
||||||
|
notification_level: z.number().optional(),
|
||||||
|
}).optional().nullable(),
|
||||||
|
group_access: z.object({
|
||||||
|
access_level: z.number(),
|
||||||
|
notification_level: z.number().optional(),
|
||||||
|
}).optional().nullable(),
|
||||||
|
}).optional(),
|
||||||
|
container_registry_enabled: z.boolean().optional(),
|
||||||
|
container_registry_access_level: z.string().optional(),
|
||||||
|
issues_enabled: z.boolean().optional(),
|
||||||
|
merge_requests_enabled: z.boolean().optional(),
|
||||||
|
wiki_enabled: z.boolean().optional(),
|
||||||
|
jobs_enabled: z.boolean().optional(),
|
||||||
|
snippets_enabled: z.boolean().optional(),
|
||||||
|
can_create_merge_request_in: z.boolean().optional(),
|
||||||
|
resolve_outdated_diff_discussions: z.boolean().optional(),
|
||||||
|
shared_runners_enabled: z.boolean().optional(),
|
||||||
|
shared_with_groups: z.array(z.object({
|
||||||
|
group_id: z.number(),
|
||||||
|
group_name: z.string(),
|
||||||
|
group_full_path: z.string(),
|
||||||
|
group_access_level: z.number(),
|
||||||
|
})).optional(),
|
||||||
});
|
});
|
||||||
|
// Project schema (extended from repository schema)
|
||||||
|
export const GitLabProjectSchema = GitLabRepositorySchema;
|
||||||
// File content schemas
|
// File content schemas
|
||||||
export const GitLabFileContentSchema = z.object({
|
export const GitLabFileContentSchema = z.object({
|
||||||
file_name: z.string(), // Changed from name to match GitLab API
|
file_name: z.string(), // Changed from name to match GitLab API
|
||||||
@ -39,7 +108,9 @@ export const GitLabFileContentSchema = z.object({
|
|||||||
content_sha256: z.string(), // Changed from sha to match GitLab API
|
content_sha256: z.string(), // Changed from sha to match GitLab API
|
||||||
ref: z.string(), // Added as GitLab requires branch reference
|
ref: z.string(), // Added as GitLab requires branch reference
|
||||||
blob_id: z.string(), // Added to match GitLab API
|
blob_id: z.string(), // Added to match GitLab API
|
||||||
|
commit_id: z.string(), // ID of the current file version
|
||||||
last_commit_id: z.string(), // Added to match GitLab API
|
last_commit_id: z.string(), // Added to match GitLab API
|
||||||
|
execute_filemode: z.boolean().optional(), // Added to match GitLab API
|
||||||
});
|
});
|
||||||
export const GitLabDirectoryContentSchema = z.object({
|
export const GitLabDirectoryContentSchema = z.object({
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
@ -122,7 +193,7 @@ export const CreateBranchOptionsSchema = z.object({
|
|||||||
export const GitLabCreateUpdateFileResponseSchema = z.object({
|
export const GitLabCreateUpdateFileResponseSchema = z.object({
|
||||||
file_path: z.string(),
|
file_path: z.string(),
|
||||||
branch: z.string(),
|
branch: z.string(),
|
||||||
commit_id: z.string(), // Changed from sha to match GitLab API
|
commit_id: z.string().optional(), // Optional since it's not always returned by the API
|
||||||
content: GitLabFileContentSchema.optional(),
|
content: GitLabFileContentSchema.optional(),
|
||||||
});
|
});
|
||||||
export const GitLabSearchResponseSchema = z.object({
|
export const GitLabSearchResponseSchema = z.object({
|
||||||
@ -131,20 +202,6 @@ export const GitLabSearchResponseSchema = z.object({
|
|||||||
current_page: z.number().optional(),
|
current_page: z.number().optional(),
|
||||||
items: z.array(GitLabRepositorySchema),
|
items: z.array(GitLabRepositorySchema),
|
||||||
});
|
});
|
||||||
// Fork related schemas
|
|
||||||
export const GitLabForkParentSchema = z.object({
|
|
||||||
name: z.string(),
|
|
||||||
path_with_namespace: z.string(), // Changed from full_name to match GitLab API
|
|
||||||
owner: z.object({
|
|
||||||
username: z.string(), // Changed from login to match GitLab API
|
|
||||||
id: z.number(),
|
|
||||||
avatar_url: z.string(),
|
|
||||||
}),
|
|
||||||
web_url: z.string(), // Changed from html_url to match GitLab API
|
|
||||||
});
|
|
||||||
export const GitLabForkSchema = GitLabRepositorySchema.extend({
|
|
||||||
forked_from_project: GitLabForkParentSchema, // Changed from parent to match GitLab API
|
|
||||||
});
|
|
||||||
// Issue related schemas
|
// Issue related schemas
|
||||||
export const GitLabLabelSchema = z.object({
|
export const GitLabLabelSchema = z.object({
|
||||||
id: z.number(),
|
id: z.number(),
|
||||||
@ -176,12 +233,48 @@ export const GitLabIssueSchema = z.object({
|
|||||||
state: z.string(),
|
state: z.string(),
|
||||||
author: GitLabUserSchema,
|
author: GitLabUserSchema,
|
||||||
assignees: z.array(GitLabUserSchema),
|
assignees: z.array(GitLabUserSchema),
|
||||||
labels: z.array(GitLabLabelSchema),
|
labels: z.array(GitLabLabelSchema).or(z.array(z.string())), // Support both label objects and strings
|
||||||
milestone: GitLabMilestoneSchema.nullable(),
|
milestone: GitLabMilestoneSchema.nullable(),
|
||||||
created_at: z.string(),
|
created_at: z.string(),
|
||||||
updated_at: z.string(),
|
updated_at: z.string(),
|
||||||
closed_at: z.string().nullable(),
|
closed_at: z.string().nullable(),
|
||||||
web_url: z.string(), // Changed from html_url to match GitLab API
|
web_url: z.string(), // Changed from html_url to match GitLab API
|
||||||
|
references: z.object({
|
||||||
|
short: z.string(),
|
||||||
|
relative: z.string(),
|
||||||
|
full: z.string(),
|
||||||
|
}).optional(),
|
||||||
|
time_stats: z.object({
|
||||||
|
time_estimate: z.number(),
|
||||||
|
total_time_spent: z.number(),
|
||||||
|
human_time_estimate: z.string().nullable(),
|
||||||
|
human_total_time_spent: z.string().nullable(),
|
||||||
|
}).optional(),
|
||||||
|
confidential: z.boolean().optional(),
|
||||||
|
due_date: z.string().nullable().optional(),
|
||||||
|
discussion_locked: z.boolean().nullable().optional(),
|
||||||
|
weight: z.number().nullable().optional(),
|
||||||
|
});
|
||||||
|
// NEW SCHEMA: For issue with link details (used in listing issue links)
|
||||||
|
export const GitLabIssueWithLinkDetailsSchema = GitLabIssueSchema.extend({
|
||||||
|
issue_link_id: z.number(),
|
||||||
|
link_type: z.enum(['relates_to', 'blocks', 'is_blocked_by']),
|
||||||
|
link_created_at: z.string(),
|
||||||
|
link_updated_at: z.string(),
|
||||||
|
});
|
||||||
|
// Fork related schemas
|
||||||
|
export const GitLabForkParentSchema = z.object({
|
||||||
|
name: z.string(),
|
||||||
|
path_with_namespace: z.string(), // Changed from full_name to match GitLab API
|
||||||
|
owner: z.object({
|
||||||
|
username: z.string(), // Changed from login to match GitLab API
|
||||||
|
id: z.number(),
|
||||||
|
avatar_url: z.string(),
|
||||||
|
}).optional(), // Made optional to handle cases where GitLab API doesn't include it
|
||||||
|
web_url: z.string(), // Changed from html_url to match GitLab API
|
||||||
|
});
|
||||||
|
export const GitLabForkSchema = GitLabRepositorySchema.extend({
|
||||||
|
forked_from_project: GitLabForkParentSchema.optional(), // Made optional to handle cases where GitLab API doesn't include it
|
||||||
});
|
});
|
||||||
// Merge Request related schemas (equivalent to Pull Request)
|
// Merge Request related schemas (equivalent to Pull Request)
|
||||||
export const GitLabMergeRequestDiffRefSchema = z.object({
|
export const GitLabMergeRequestDiffRefSchema = z.object({
|
||||||
@ -236,6 +329,14 @@ export const CreateOrUpdateFileSchema = ProjectParamsSchema.extend({
|
|||||||
.string()
|
.string()
|
||||||
.optional()
|
.optional()
|
||||||
.describe("Path of the file to move/rename"),
|
.describe("Path of the file to move/rename"),
|
||||||
|
last_commit_id: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.describe("Last known file commit ID"),
|
||||||
|
commit_id: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.describe("Current file commit ID (for update operations)"),
|
||||||
});
|
});
|
||||||
export const SearchRepositoriesSchema = z.object({
|
export const SearchRepositoriesSchema = z.object({
|
||||||
search: z.string().describe("Search query"), // Changed from query to match GitLab API
|
search: z.string().describe("Search query"), // Changed from query to match GitLab API
|
||||||
@ -354,3 +455,106 @@ export const CreateNoteSchema = z.object({
|
|||||||
noteable_iid: z.number().describe("IID of the issue or merge request"),
|
noteable_iid: z.number().describe("IID of the issue or merge request"),
|
||||||
body: z.string().describe("Note content"),
|
body: z.string().describe("Note content"),
|
||||||
});
|
});
|
||||||
|
// Issues API operation schemas
|
||||||
|
export const ListIssuesSchema = z.object({
|
||||||
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||||
|
assignee_id: z.number().optional().describe("Return issues assigned to the given user ID"),
|
||||||
|
assignee_username: z.string().optional().describe("Return issues assigned to the given username"),
|
||||||
|
author_id: z.number().optional().describe("Return issues created by the given user ID"),
|
||||||
|
author_username: z.string().optional().describe("Return issues created by the given username"),
|
||||||
|
confidential: z.boolean().optional().describe("Filter confidential or public issues"),
|
||||||
|
created_after: z.string().optional().describe("Return issues created after the given time"),
|
||||||
|
created_before: z.string().optional().describe("Return issues created before the given time"),
|
||||||
|
due_date: z.string().optional().describe("Return issues that have the due date"),
|
||||||
|
label_name: z.array(z.string()).optional().describe("Array of label names"),
|
||||||
|
milestone: z.string().optional().describe("Milestone title"),
|
||||||
|
scope: z.enum(['created-by-me', 'assigned-to-me', 'all']).optional().describe("Return issues from a specific scope"),
|
||||||
|
search: z.string().optional().describe("Search for specific terms"),
|
||||||
|
state: z.enum(['opened', 'closed', 'all']).optional().describe("Return issues with a specific state"),
|
||||||
|
updated_after: z.string().optional().describe("Return issues updated after the given time"),
|
||||||
|
updated_before: z.string().optional().describe("Return issues updated before the given time"),
|
||||||
|
with_labels_details: z.boolean().optional().describe("Return more details for each label"),
|
||||||
|
page: z.number().optional().describe("Page number for pagination"),
|
||||||
|
per_page: z.number().optional().describe("Number of items per page"),
|
||||||
|
});
|
||||||
|
export const GetIssueSchema = z.object({
|
||||||
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||||
|
issue_iid: z.number().describe("The internal ID of the project issue"),
|
||||||
|
});
|
||||||
|
export const UpdateIssueSchema = z.object({
|
||||||
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||||
|
issue_iid: z.number().describe("The internal ID of the project issue"),
|
||||||
|
title: z.string().optional().describe("The title of the issue"),
|
||||||
|
description: z.string().optional().describe("The description of the issue"),
|
||||||
|
assignee_ids: z.array(z.number()).optional().describe("Array of user IDs to assign issue to"),
|
||||||
|
confidential: z.boolean().optional().describe("Set the issue to be confidential"),
|
||||||
|
discussion_locked: z.boolean().optional().describe("Flag to lock discussions"),
|
||||||
|
due_date: z.string().optional().describe("Date the issue is due (YYYY-MM-DD)"),
|
||||||
|
labels: z.array(z.string()).optional().describe("Array of label names"),
|
||||||
|
milestone_id: z.number().optional().describe("Milestone ID to assign"),
|
||||||
|
state_event: z.enum(['close', 'reopen']).optional().describe("Update issue state (close/reopen)"),
|
||||||
|
weight: z.number().optional().describe("Weight of the issue (0-9)"),
|
||||||
|
});
|
||||||
|
export const DeleteIssueSchema = z.object({
|
||||||
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||||
|
issue_iid: z.number().describe("The internal ID of the project issue"),
|
||||||
|
});
|
||||||
|
// Issue links related schemas
|
||||||
|
export const GitLabIssueLinkSchema = z.object({
|
||||||
|
source_issue: GitLabIssueSchema,
|
||||||
|
target_issue: GitLabIssueSchema,
|
||||||
|
link_type: z.enum(['relates_to', 'blocks', 'is_blocked_by']),
|
||||||
|
});
|
||||||
|
export const ListIssueLinksSchema = z.object({
|
||||||
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||||
|
issue_iid: z.number().describe("The internal ID of a project's issue"),
|
||||||
|
});
|
||||||
|
export const GetIssueLinkSchema = z.object({
|
||||||
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||||
|
issue_iid: z.number().describe("The internal ID of a project's issue"),
|
||||||
|
issue_link_id: z.number().describe("ID of an issue relationship"),
|
||||||
|
});
|
||||||
|
export const CreateIssueLinkSchema = z.object({
|
||||||
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||||
|
issue_iid: z.number().describe("The internal ID of a project's issue"),
|
||||||
|
target_project_id: z.string().describe("The ID or URL-encoded path of a target project"),
|
||||||
|
target_issue_iid: z.number().describe("The internal ID of a target project's issue"),
|
||||||
|
link_type: z.enum(['relates_to', 'blocks', 'is_blocked_by']).optional().describe("The type of the relation, defaults to relates_to"),
|
||||||
|
});
|
||||||
|
export const DeleteIssueLinkSchema = z.object({
|
||||||
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||||
|
issue_iid: z.number().describe("The internal ID of a project's issue"),
|
||||||
|
issue_link_id: z.number().describe("The ID of an issue relationship"),
|
||||||
|
});
|
||||||
|
// Namespace API operation schemas
|
||||||
|
export const ListNamespacesSchema = z.object({
|
||||||
|
search: z.string().optional().describe("Search term for namespaces"),
|
||||||
|
page: z.number().optional().describe("Page number for pagination"),
|
||||||
|
per_page: z.number().optional().describe("Number of items per page"),
|
||||||
|
owned: z.boolean().optional().describe("Filter for namespaces owned by current user"),
|
||||||
|
});
|
||||||
|
export const GetNamespaceSchema = z.object({
|
||||||
|
namespace_id: z.string().describe("Namespace ID or full path"),
|
||||||
|
});
|
||||||
|
export const VerifyNamespaceSchema = z.object({
|
||||||
|
path: z.string().describe("Namespace path to verify"),
|
||||||
|
});
|
||||||
|
// Project API operation schemas
|
||||||
|
export const GetProjectSchema = z.object({
|
||||||
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||||
|
});
|
||||||
|
export const ListProjectsSchema = z.object({
|
||||||
|
search: z.string().optional().describe("Search term for projects"),
|
||||||
|
page: z.number().optional().describe("Page number for pagination"),
|
||||||
|
per_page: z.number().optional().describe("Number of items per page"),
|
||||||
|
owned: z.boolean().optional().describe("Filter for projects owned by current user"),
|
||||||
|
membership: z.boolean().optional().describe("Filter for projects where current user is a member"),
|
||||||
|
simple: z.boolean().optional().describe("Return only limited fields"),
|
||||||
|
archived: z.boolean().optional().describe("Filter for archived projects"),
|
||||||
|
visibility: z.enum(["public", "internal", "private"]).optional().describe("Filter by project visibility"),
|
||||||
|
order_by: z.enum(["id", "name", "path", "created_at", "updated_at", "last_activity_at"]).optional().describe("Return projects ordered by field"),
|
||||||
|
sort: z.enum(["asc", "desc"]).optional().describe("Return projects sorted in ascending or descending order"),
|
||||||
|
with_issues_enabled: z.boolean().optional().describe("Filter projects with issues feature enabled"),
|
||||||
|
with_merge_requests_enabled: z.boolean().optional().describe("Filter projects with merge requests feature enabled"),
|
||||||
|
min_access_level: z.number().optional().describe("Filter by minimum access level"),
|
||||||
|
});
|
||||||
|
441
index.ts
441
index.ts
@ -26,6 +26,7 @@ import {
|
|||||||
GitLabCommitSchema,
|
GitLabCommitSchema,
|
||||||
GitLabNamespaceSchema,
|
GitLabNamespaceSchema,
|
||||||
GitLabNamespaceExistsResponseSchema,
|
GitLabNamespaceExistsResponseSchema,
|
||||||
|
GitLabProjectSchema,
|
||||||
CreateRepositoryOptionsSchema,
|
CreateRepositoryOptionsSchema,
|
||||||
CreateIssueOptionsSchema,
|
CreateIssueOptionsSchema,
|
||||||
CreateMergeRequestOptionsSchema,
|
CreateMergeRequestOptionsSchema,
|
||||||
@ -43,11 +44,22 @@ import {
|
|||||||
GetMergeRequestSchema,
|
GetMergeRequestSchema,
|
||||||
GetMergeRequestDiffsSchema,
|
GetMergeRequestDiffsSchema,
|
||||||
UpdateMergeRequestSchema,
|
UpdateMergeRequestSchema,
|
||||||
|
ListIssuesSchema,
|
||||||
|
GetIssueSchema,
|
||||||
|
UpdateIssueSchema,
|
||||||
|
DeleteIssueSchema,
|
||||||
|
GitLabIssueLinkSchema,
|
||||||
|
GitLabIssueWithLinkDetailsSchema,
|
||||||
|
ListIssueLinksSchema,
|
||||||
|
GetIssueLinkSchema,
|
||||||
|
CreateIssueLinkSchema,
|
||||||
|
DeleteIssueLinkSchema,
|
||||||
ListNamespacesSchema,
|
ListNamespacesSchema,
|
||||||
GetNamespaceSchema,
|
GetNamespaceSchema,
|
||||||
VerifyNamespaceSchema,
|
VerifyNamespaceSchema,
|
||||||
GetProjectSchema,
|
GetProjectSchema,
|
||||||
ListProjectsSchema,
|
ListProjectsSchema,
|
||||||
|
CreateNoteSchema,
|
||||||
type GitLabFork,
|
type GitLabFork,
|
||||||
type GitLabReference,
|
type GitLabReference,
|
||||||
type GitLabRepository,
|
type GitLabRepository,
|
||||||
@ -60,10 +72,11 @@ import {
|
|||||||
type GitLabCommit,
|
type GitLabCommit,
|
||||||
type FileOperation,
|
type FileOperation,
|
||||||
type GitLabMergeRequestDiff,
|
type GitLabMergeRequestDiff,
|
||||||
|
type GitLabIssueLink,
|
||||||
|
type GitLabIssueWithLinkDetails,
|
||||||
type GitLabNamespace,
|
type GitLabNamespace,
|
||||||
type GitLabNamespaceExistsResponse,
|
type GitLabNamespaceExistsResponse,
|
||||||
type GitLabProject,
|
type GitLabProject,
|
||||||
CreateNoteSchema,
|
|
||||||
} from "./schemas.js";
|
} from "./schemas.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -342,6 +355,242 @@ async function createIssue(
|
|||||||
return GitLabIssueSchema.parse(data);
|
return GitLabIssueSchema.parse(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List issues in a GitLab project
|
||||||
|
* 프로젝트의 이슈 목록 조회
|
||||||
|
*
|
||||||
|
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||||
|
* @param {Object} options - Options for listing issues
|
||||||
|
* @returns {Promise<GitLabIssue[]>} List of issues
|
||||||
|
*/
|
||||||
|
async function listIssues(
|
||||||
|
projectId: string,
|
||||||
|
options: Omit<z.infer<typeof ListIssuesSchema>, "project_id"> = {}
|
||||||
|
): Promise<GitLabIssue[]> {
|
||||||
|
const url = new URL(
|
||||||
|
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/issues`
|
||||||
|
);
|
||||||
|
|
||||||
|
// Add all query parameters
|
||||||
|
Object.entries(options).forEach(([key, value]) => {
|
||||||
|
if (value !== undefined) {
|
||||||
|
if (key === 'label_name' && Array.isArray(value)) {
|
||||||
|
// Handle array of labels
|
||||||
|
url.searchParams.append(key, value.join(','));
|
||||||
|
} else {
|
||||||
|
url.searchParams.append(key, value.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await fetch(url.toString(), {
|
||||||
|
headers: DEFAULT_HEADERS,
|
||||||
|
});
|
||||||
|
|
||||||
|
await handleGitLabError(response);
|
||||||
|
const data = await response.json();
|
||||||
|
return z.array(GitLabIssueSchema).parse(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a single issue from a GitLab project
|
||||||
|
* 단일 이슈 조회
|
||||||
|
*
|
||||||
|
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||||
|
* @param {number} issueIid - The internal ID of the project issue
|
||||||
|
* @returns {Promise<GitLabIssue>} The issue
|
||||||
|
*/
|
||||||
|
async function getIssue(
|
||||||
|
projectId: string,
|
||||||
|
issueIid: number
|
||||||
|
): Promise<GitLabIssue> {
|
||||||
|
const url = new URL(
|
||||||
|
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/issues/${issueIid}`
|
||||||
|
);
|
||||||
|
|
||||||
|
const response = await fetch(url.toString(), {
|
||||||
|
headers: DEFAULT_HEADERS,
|
||||||
|
});
|
||||||
|
|
||||||
|
await handleGitLabError(response);
|
||||||
|
const data = await response.json();
|
||||||
|
return GitLabIssueSchema.parse(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update an issue in a GitLab project
|
||||||
|
* 이슈 업데이트
|
||||||
|
*
|
||||||
|
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||||
|
* @param {number} issueIid - The internal ID of the project issue
|
||||||
|
* @param {Object} options - Update options for the issue
|
||||||
|
* @returns {Promise<GitLabIssue>} The updated issue
|
||||||
|
*/
|
||||||
|
async function updateIssue(
|
||||||
|
projectId: string,
|
||||||
|
issueIid: number,
|
||||||
|
options: Omit<z.infer<typeof UpdateIssueSchema>, "project_id" | "issue_iid">
|
||||||
|
): Promise<GitLabIssue> {
|
||||||
|
const url = new URL(
|
||||||
|
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/issues/${issueIid}`
|
||||||
|
);
|
||||||
|
|
||||||
|
// Convert labels array to comma-separated string if present
|
||||||
|
const body: Record<string, any> = { ...options };
|
||||||
|
if (body.labels && Array.isArray(body.labels)) {
|
||||||
|
body.labels = body.labels.join(',');
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch(url.toString(), {
|
||||||
|
method: "PUT",
|
||||||
|
headers: DEFAULT_HEADERS,
|
||||||
|
body: JSON.stringify(body),
|
||||||
|
});
|
||||||
|
|
||||||
|
await handleGitLabError(response);
|
||||||
|
const data = await response.json();
|
||||||
|
return GitLabIssueSchema.parse(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete an issue from a GitLab project
|
||||||
|
* 이슈 삭제
|
||||||
|
*
|
||||||
|
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||||
|
* @param {number} issueIid - The internal ID of the project issue
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
async function deleteIssue(
|
||||||
|
projectId: string,
|
||||||
|
issueIid: number
|
||||||
|
): Promise<void> {
|
||||||
|
const url = new URL(
|
||||||
|
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/issues/${issueIid}`
|
||||||
|
);
|
||||||
|
|
||||||
|
const response = await fetch(url.toString(), {
|
||||||
|
method: "DELETE",
|
||||||
|
headers: DEFAULT_HEADERS,
|
||||||
|
});
|
||||||
|
|
||||||
|
await handleGitLabError(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List all issue links for a specific issue
|
||||||
|
* 이슈 관계 목록 조회
|
||||||
|
*
|
||||||
|
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||||
|
* @param {number} issueIid - The internal ID of the project issue
|
||||||
|
* @returns {Promise<GitLabIssueWithLinkDetails[]>} List of issues with link details
|
||||||
|
*/
|
||||||
|
async function listIssueLinks(
|
||||||
|
projectId: string,
|
||||||
|
issueIid: number
|
||||||
|
): Promise<GitLabIssueWithLinkDetails[]> {
|
||||||
|
const url = new URL(
|
||||||
|
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/issues/${issueIid}/links`
|
||||||
|
);
|
||||||
|
|
||||||
|
const response = await fetch(url.toString(), {
|
||||||
|
headers: DEFAULT_HEADERS,
|
||||||
|
});
|
||||||
|
|
||||||
|
await handleGitLabError(response);
|
||||||
|
const data = await response.json();
|
||||||
|
return z.array(GitLabIssueWithLinkDetailsSchema).parse(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a specific issue link
|
||||||
|
* 특정 이슈 관계 조회
|
||||||
|
*
|
||||||
|
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||||
|
* @param {number} issueIid - The internal ID of the project issue
|
||||||
|
* @param {number} issueLinkId - The ID of the issue link
|
||||||
|
* @returns {Promise<GitLabIssueLink>} The issue link
|
||||||
|
*/
|
||||||
|
async function getIssueLink(
|
||||||
|
projectId: string,
|
||||||
|
issueIid: number,
|
||||||
|
issueLinkId: number
|
||||||
|
): Promise<GitLabIssueLink> {
|
||||||
|
const url = new URL(
|
||||||
|
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/issues/${issueIid}/links/${issueLinkId}`
|
||||||
|
);
|
||||||
|
|
||||||
|
const response = await fetch(url.toString(), {
|
||||||
|
headers: DEFAULT_HEADERS,
|
||||||
|
});
|
||||||
|
|
||||||
|
await handleGitLabError(response);
|
||||||
|
const data = await response.json();
|
||||||
|
return GitLabIssueLinkSchema.parse(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an issue link between two issues
|
||||||
|
* 이슈 관계 생성
|
||||||
|
*
|
||||||
|
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||||
|
* @param {number} issueIid - The internal ID of the project issue
|
||||||
|
* @param {string} targetProjectId - The ID or URL-encoded path of the target project
|
||||||
|
* @param {number} targetIssueIid - The internal ID of the target project issue
|
||||||
|
* @param {string} linkType - The type of the relation (relates_to, blocks, is_blocked_by)
|
||||||
|
* @returns {Promise<GitLabIssueLink>} The created issue link
|
||||||
|
*/
|
||||||
|
async function createIssueLink(
|
||||||
|
projectId: string,
|
||||||
|
issueIid: number,
|
||||||
|
targetProjectId: string,
|
||||||
|
targetIssueIid: number,
|
||||||
|
linkType: 'relates_to' | 'blocks' | 'is_blocked_by' = 'relates_to'
|
||||||
|
): Promise<GitLabIssueLink> {
|
||||||
|
const url = new URL(
|
||||||
|
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/issues/${issueIid}/links`
|
||||||
|
);
|
||||||
|
|
||||||
|
const response = await fetch(url.toString(), {
|
||||||
|
method: "POST",
|
||||||
|
headers: DEFAULT_HEADERS,
|
||||||
|
body: JSON.stringify({
|
||||||
|
target_project_id: targetProjectId,
|
||||||
|
target_issue_iid: targetIssueIid,
|
||||||
|
link_type: linkType
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
await handleGitLabError(response);
|
||||||
|
const data = await response.json();
|
||||||
|
return GitLabIssueLinkSchema.parse(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete an issue link
|
||||||
|
* 이슈 관계 삭제
|
||||||
|
*
|
||||||
|
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||||
|
* @param {number} issueIid - The internal ID of the project issue
|
||||||
|
* @param {number} issueLinkId - The ID of the issue link
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
async function deleteIssueLink(
|
||||||
|
projectId: string,
|
||||||
|
issueIid: number,
|
||||||
|
issueLinkId: number
|
||||||
|
): Promise<void> {
|
||||||
|
const url = new URL(
|
||||||
|
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/issues/${issueIid}/links/${issueLinkId}`
|
||||||
|
);
|
||||||
|
|
||||||
|
const response = await fetch(url.toString(), {
|
||||||
|
method: "DELETE",
|
||||||
|
headers: DEFAULT_HEADERS,
|
||||||
|
});
|
||||||
|
|
||||||
|
await handleGitLabError(response);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new merge request in a GitLab project
|
* Create a new merge request in a GitLab project
|
||||||
* 병합 요청 생성
|
* 병합 요청 생성
|
||||||
@ -1044,6 +1293,46 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|||||||
description: "Create a new note (comment) to an issue or merge request",
|
description: "Create a new note (comment) to an issue or merge request",
|
||||||
inputSchema: zodToJsonSchema(CreateNoteSchema),
|
inputSchema: zodToJsonSchema(CreateNoteSchema),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "list_issues",
|
||||||
|
description: "List issues in a GitLab project with filtering options",
|
||||||
|
inputSchema: zodToJsonSchema(ListIssuesSchema),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "get_issue",
|
||||||
|
description: "Get details of a specific issue in a GitLab project",
|
||||||
|
inputSchema: zodToJsonSchema(GetIssueSchema),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "update_issue",
|
||||||
|
description: "Update an issue in a GitLab project",
|
||||||
|
inputSchema: zodToJsonSchema(UpdateIssueSchema),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "delete_issue",
|
||||||
|
description: "Delete an issue from a GitLab project",
|
||||||
|
inputSchema: zodToJsonSchema(DeleteIssueSchema),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "list_issue_links",
|
||||||
|
description: "List all issue links for a specific issue",
|
||||||
|
inputSchema: zodToJsonSchema(ListIssueLinksSchema),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "get_issue_link",
|
||||||
|
description: "Get a specific issue link",
|
||||||
|
inputSchema: zodToJsonSchema(GetIssueLinkSchema),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "create_issue_link",
|
||||||
|
description: "Create an issue link between two issues",
|
||||||
|
inputSchema: zodToJsonSchema(CreateIssueLinkSchema),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "delete_issue_link",
|
||||||
|
description: "Delete an issue link",
|
||||||
|
inputSchema: zodToJsonSchema(DeleteIssueLinkSchema),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "list_namespaces",
|
name: "list_namespaces",
|
||||||
description: "List all namespaces available to the current user",
|
description: "List all namespaces available to the current user",
|
||||||
@ -1051,17 +1340,17 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "get_namespace",
|
name: "get_namespace",
|
||||||
description: "Get details on a specified namespace",
|
description: "Get details of a namespace by ID or path",
|
||||||
inputSchema: zodToJsonSchema(GetNamespaceSchema),
|
inputSchema: zodToJsonSchema(GetNamespaceSchema),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "verify_namespace",
|
name: "verify_namespace",
|
||||||
description: "Verify if a specified namespace already exists",
|
description: "Verify if a namespace path exists",
|
||||||
inputSchema: zodToJsonSchema(VerifyNamespaceSchema),
|
inputSchema: zodToJsonSchema(VerifyNamespaceSchema),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "get_project",
|
name: "get_project",
|
||||||
description: "Get details on a specified project",
|
description: "Get details of a specific project",
|
||||||
inputSchema: zodToJsonSchema(GetProjectSchema),
|
inputSchema: zodToJsonSchema(GetProjectSchema),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -1242,7 +1531,29 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|||||||
|
|
||||||
case "list_namespaces": {
|
case "list_namespaces": {
|
||||||
const args = ListNamespacesSchema.parse(request.params.arguments);
|
const args = ListNamespacesSchema.parse(request.params.arguments);
|
||||||
const namespaces = await listNamespaces(args);
|
const url = new URL(`${GITLAB_API_URL}/namespaces`);
|
||||||
|
|
||||||
|
if (args.search) {
|
||||||
|
url.searchParams.append("search", args.search);
|
||||||
|
}
|
||||||
|
if (args.page) {
|
||||||
|
url.searchParams.append("page", args.page.toString());
|
||||||
|
}
|
||||||
|
if (args.per_page) {
|
||||||
|
url.searchParams.append("per_page", args.per_page.toString());
|
||||||
|
}
|
||||||
|
if (args.owned) {
|
||||||
|
url.searchParams.append("owned", args.owned.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch(url.toString(), {
|
||||||
|
headers: DEFAULT_HEADERS,
|
||||||
|
});
|
||||||
|
|
||||||
|
await handleGitLabError(response);
|
||||||
|
const data = await response.json();
|
||||||
|
const namespaces = z.array(GitLabNamespaceSchema).parse(data);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content: [{ type: "text", text: JSON.stringify(namespaces, null, 2) }],
|
content: [{ type: "text", text: JSON.stringify(namespaces, null, 2) }],
|
||||||
};
|
};
|
||||||
@ -1250,7 +1561,16 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|||||||
|
|
||||||
case "get_namespace": {
|
case "get_namespace": {
|
||||||
const args = GetNamespaceSchema.parse(request.params.arguments);
|
const args = GetNamespaceSchema.parse(request.params.arguments);
|
||||||
const namespace = await getNamespace(args.id);
|
const url = new URL(`${GITLAB_API_URL}/namespaces/${encodeURIComponent(args.namespace_id)}`);
|
||||||
|
|
||||||
|
const response = await fetch(url.toString(), {
|
||||||
|
headers: DEFAULT_HEADERS,
|
||||||
|
});
|
||||||
|
|
||||||
|
await handleGitLabError(response);
|
||||||
|
const data = await response.json();
|
||||||
|
const namespace = GitLabNamespaceSchema.parse(data);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content: [{ type: "text", text: JSON.stringify(namespace, null, 2) }],
|
content: [{ type: "text", text: JSON.stringify(namespace, null, 2) }],
|
||||||
};
|
};
|
||||||
@ -1258,16 +1578,33 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|||||||
|
|
||||||
case "verify_namespace": {
|
case "verify_namespace": {
|
||||||
const args = VerifyNamespaceSchema.parse(request.params.arguments);
|
const args = VerifyNamespaceSchema.parse(request.params.arguments);
|
||||||
const result = await verifyNamespaceExistence(args.namespace, args.parent_id);
|
const url = new URL(`${GITLAB_API_URL}/namespaces/${encodeURIComponent(args.path)}/exists`);
|
||||||
|
|
||||||
|
const response = await fetch(url.toString(), {
|
||||||
|
headers: DEFAULT_HEADERS,
|
||||||
|
});
|
||||||
|
|
||||||
|
await handleGitLabError(response);
|
||||||
|
const data = await response.json();
|
||||||
|
const namespaceExists = GitLabNamespaceExistsResponseSchema.parse(data);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
content: [{ type: "text", text: JSON.stringify(namespaceExists, null, 2) }],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
case "get_project": {
|
case "get_project": {
|
||||||
const args = GetProjectSchema.parse(request.params.arguments);
|
const args = GetProjectSchema.parse(request.params.arguments);
|
||||||
const { id, ...options } = args;
|
const url = new URL(`${GITLAB_API_URL}/projects/${encodeURIComponent(args.project_id)}`);
|
||||||
const project = await getProject(id, options);
|
|
||||||
|
const response = await fetch(url.toString(), {
|
||||||
|
headers: DEFAULT_HEADERS,
|
||||||
|
});
|
||||||
|
|
||||||
|
await handleGitLabError(response);
|
||||||
|
const data = await response.json();
|
||||||
|
const project = GitLabProjectSchema.parse(data);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content: [{ type: "text", text: JSON.stringify(project, null, 2) }],
|
content: [{ type: "text", text: JSON.stringify(project, null, 2) }],
|
||||||
};
|
};
|
||||||
@ -1275,7 +1612,23 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|||||||
|
|
||||||
case "list_projects": {
|
case "list_projects": {
|
||||||
const args = ListProjectsSchema.parse(request.params.arguments);
|
const args = ListProjectsSchema.parse(request.params.arguments);
|
||||||
const projects = await listProjects(args);
|
const url = new URL(`${GITLAB_API_URL}/projects`);
|
||||||
|
|
||||||
|
// Add query parameters for filtering
|
||||||
|
Object.entries(args).forEach(([key, value]) => {
|
||||||
|
if (value !== undefined) {
|
||||||
|
url.searchParams.append(key, value.toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await fetch(url.toString(), {
|
||||||
|
headers: DEFAULT_HEADERS,
|
||||||
|
});
|
||||||
|
|
||||||
|
await handleGitLabError(response);
|
||||||
|
const data = await response.json();
|
||||||
|
const projects = z.array(GitLabProjectSchema).parse(data);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content: [{ type: "text", text: JSON.stringify(projects, null, 2) }],
|
content: [{ type: "text", text: JSON.stringify(projects, null, 2) }],
|
||||||
};
|
};
|
||||||
@ -1296,6 +1649,72 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "list_issues": {
|
||||||
|
const args = ListIssuesSchema.parse(request.params.arguments);
|
||||||
|
const { project_id, ...options } = args;
|
||||||
|
const issues = await listIssues(project_id, options);
|
||||||
|
return {
|
||||||
|
content: [{ type: "text", text: JSON.stringify(issues, null, 2) }],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case "get_issue": {
|
||||||
|
const args = GetIssueSchema.parse(request.params.arguments);
|
||||||
|
const issue = await getIssue(args.project_id, args.issue_iid);
|
||||||
|
return {
|
||||||
|
content: [{ type: "text", text: JSON.stringify(issue, null, 2) }],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case "update_issue": {
|
||||||
|
const args = UpdateIssueSchema.parse(request.params.arguments);
|
||||||
|
const { project_id, issue_iid, ...options } = args;
|
||||||
|
const issue = await updateIssue(project_id, issue_iid, options);
|
||||||
|
return {
|
||||||
|
content: [{ type: "text", text: JSON.stringify(issue, null, 2) }],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case "delete_issue": {
|
||||||
|
const args = DeleteIssueSchema.parse(request.params.arguments);
|
||||||
|
await deleteIssue(args.project_id, args.issue_iid);
|
||||||
|
return {
|
||||||
|
content: [{ type: "text", text: JSON.stringify({ status: "success", message: "Issue deleted successfully" }, null, 2) }],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case "list_issue_links": {
|
||||||
|
const args = ListIssueLinksSchema.parse(request.params.arguments);
|
||||||
|
const links = await listIssueLinks(args.project_id, args.issue_iid);
|
||||||
|
return {
|
||||||
|
content: [{ type: "text", text: JSON.stringify(links, null, 2) }],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case "get_issue_link": {
|
||||||
|
const args = GetIssueLinkSchema.parse(request.params.arguments);
|
||||||
|
const link = await getIssueLink(args.project_id, args.issue_iid, args.issue_link_id);
|
||||||
|
return {
|
||||||
|
content: [{ type: "text", text: JSON.stringify(link, null, 2) }],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case "create_issue_link": {
|
||||||
|
const args = CreateIssueLinkSchema.parse(request.params.arguments);
|
||||||
|
const link = await createIssueLink(args.project_id, args.issue_iid, args.target_project_id, args.target_issue_iid, args.link_type);
|
||||||
|
return {
|
||||||
|
content: [{ type: "text", text: JSON.stringify(link, null, 2) }],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case "delete_issue_link": {
|
||||||
|
const args = DeleteIssueLinkSchema.parse(request.params.arguments);
|
||||||
|
await deleteIssueLink(args.project_id, args.issue_iid, args.issue_link_id);
|
||||||
|
return {
|
||||||
|
content: [{ type: "text", text: JSON.stringify({ status: "success", message: "Issue link deleted successfully" }, null, 2) }],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unknown tool: ${request.params.name}`);
|
throw new Error(`Unknown tool: ${request.params.name}`);
|
||||||
}
|
}
|
||||||
|
211
schemas.ts
211
schemas.ts
@ -102,6 +102,9 @@ export const GitLabRepositorySchema = z.object({
|
|||||||
})).optional(),
|
})).optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Project schema (extended from repository schema)
|
||||||
|
export const GitLabProjectSchema = GitLabRepositorySchema;
|
||||||
|
|
||||||
// File content schemas
|
// File content schemas
|
||||||
export const GitLabFileContentSchema = z.object({
|
export const GitLabFileContentSchema = z.object({
|
||||||
file_name: z.string(), // Changed from name to match GitLab API
|
file_name: z.string(), // Changed from name to match GitLab API
|
||||||
@ -220,22 +223,6 @@ export const GitLabSearchResponseSchema = z.object({
|
|||||||
items: z.array(GitLabRepositorySchema),
|
items: z.array(GitLabRepositorySchema),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Fork related schemas
|
|
||||||
export const GitLabForkParentSchema = z.object({
|
|
||||||
name: z.string(),
|
|
||||||
path_with_namespace: z.string(), // Changed from full_name to match GitLab API
|
|
||||||
owner: z.object({
|
|
||||||
username: z.string(), // Changed from login to match GitLab API
|
|
||||||
id: z.number(),
|
|
||||||
avatar_url: z.string(),
|
|
||||||
}).optional(), // Made optional to handle cases where GitLab API doesn't include it
|
|
||||||
web_url: z.string(), // Changed from html_url to match GitLab API
|
|
||||||
});
|
|
||||||
|
|
||||||
export const GitLabForkSchema = GitLabRepositorySchema.extend({
|
|
||||||
forked_from_project: GitLabForkParentSchema.optional(), // Made optional to handle cases where GitLab API doesn't include it
|
|
||||||
});
|
|
||||||
|
|
||||||
// Issue related schemas
|
// Issue related schemas
|
||||||
export const GitLabLabelSchema = z.object({
|
export const GitLabLabelSchema = z.object({
|
||||||
id: z.number(),
|
id: z.number(),
|
||||||
@ -270,12 +257,51 @@ export const GitLabIssueSchema = z.object({
|
|||||||
state: z.string(),
|
state: z.string(),
|
||||||
author: GitLabUserSchema,
|
author: GitLabUserSchema,
|
||||||
assignees: z.array(GitLabUserSchema),
|
assignees: z.array(GitLabUserSchema),
|
||||||
labels: z.array(GitLabLabelSchema),
|
labels: z.array(GitLabLabelSchema).or(z.array(z.string())), // Support both label objects and strings
|
||||||
milestone: GitLabMilestoneSchema.nullable(),
|
milestone: GitLabMilestoneSchema.nullable(),
|
||||||
created_at: z.string(),
|
created_at: z.string(),
|
||||||
updated_at: z.string(),
|
updated_at: z.string(),
|
||||||
closed_at: z.string().nullable(),
|
closed_at: z.string().nullable(),
|
||||||
web_url: z.string(), // Changed from html_url to match GitLab API
|
web_url: z.string(), // Changed from html_url to match GitLab API
|
||||||
|
references: z.object({
|
||||||
|
short: z.string(),
|
||||||
|
relative: z.string(),
|
||||||
|
full: z.string(),
|
||||||
|
}).optional(),
|
||||||
|
time_stats: z.object({
|
||||||
|
time_estimate: z.number(),
|
||||||
|
total_time_spent: z.number(),
|
||||||
|
human_time_estimate: z.string().nullable(),
|
||||||
|
human_total_time_spent: z.string().nullable(),
|
||||||
|
}).optional(),
|
||||||
|
confidential: z.boolean().optional(),
|
||||||
|
due_date: z.string().nullable().optional(),
|
||||||
|
discussion_locked: z.boolean().nullable().optional(),
|
||||||
|
weight: z.number().nullable().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
// NEW SCHEMA: For issue with link details (used in listing issue links)
|
||||||
|
export const GitLabIssueWithLinkDetailsSchema = GitLabIssueSchema.extend({
|
||||||
|
issue_link_id: z.number(),
|
||||||
|
link_type: z.enum(['relates_to', 'blocks', 'is_blocked_by']),
|
||||||
|
link_created_at: z.string(),
|
||||||
|
link_updated_at: z.string(),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fork related schemas
|
||||||
|
export const GitLabForkParentSchema = z.object({
|
||||||
|
name: z.string(),
|
||||||
|
path_with_namespace: z.string(), // Changed from full_name to match GitLab API
|
||||||
|
owner: z.object({
|
||||||
|
username: z.string(), // Changed from login to match GitLab API
|
||||||
|
id: z.number(),
|
||||||
|
avatar_url: z.string(),
|
||||||
|
}).optional(), // Made optional to handle cases where GitLab API doesn't include it
|
||||||
|
web_url: z.string(), // Changed from html_url to match GitLab API
|
||||||
|
});
|
||||||
|
|
||||||
|
export const GitLabForkSchema = GitLabRepositorySchema.extend({
|
||||||
|
forked_from_project: GitLabForkParentSchema.optional(), // Made optional to handle cases where GitLab API doesn't include it
|
||||||
});
|
});
|
||||||
|
|
||||||
// Merge Request related schemas (equivalent to Pull Request)
|
// Merge Request related schemas (equivalent to Pull Request)
|
||||||
@ -476,83 +502,146 @@ export const CreateNoteSchema = z.object({
|
|||||||
body: z.string().describe("Note content"),
|
body: z.string().describe("Note content"),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add namespace-related operation schemas
|
// Issues API operation schemas
|
||||||
|
export const ListIssuesSchema = z.object({
|
||||||
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||||
|
assignee_id: z.number().optional().describe("Return issues assigned to the given user ID"),
|
||||||
|
assignee_username: z.string().optional().describe("Return issues assigned to the given username"),
|
||||||
|
author_id: z.number().optional().describe("Return issues created by the given user ID"),
|
||||||
|
author_username: z.string().optional().describe("Return issues created by the given username"),
|
||||||
|
confidential: z.boolean().optional().describe("Filter confidential or public issues"),
|
||||||
|
created_after: z.string().optional().describe("Return issues created after the given time"),
|
||||||
|
created_before: z.string().optional().describe("Return issues created before the given time"),
|
||||||
|
due_date: z.string().optional().describe("Return issues that have the due date"),
|
||||||
|
label_name: z.array(z.string()).optional().describe("Array of label names"),
|
||||||
|
milestone: z.string().optional().describe("Milestone title"),
|
||||||
|
scope: z.enum(['created-by-me', 'assigned-to-me', 'all']).optional().describe("Return issues from a specific scope"),
|
||||||
|
search: z.string().optional().describe("Search for specific terms"),
|
||||||
|
state: z.enum(['opened', 'closed', 'all']).optional().describe("Return issues with a specific state"),
|
||||||
|
updated_after: z.string().optional().describe("Return issues updated after the given time"),
|
||||||
|
updated_before: z.string().optional().describe("Return issues updated before the given time"),
|
||||||
|
with_labels_details: z.boolean().optional().describe("Return more details for each label"),
|
||||||
|
page: z.number().optional().describe("Page number for pagination"),
|
||||||
|
per_page: z.number().optional().describe("Number of items per page"),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const GetIssueSchema = z.object({
|
||||||
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||||
|
issue_iid: z.number().describe("The internal ID of the project issue"),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const UpdateIssueSchema = z.object({
|
||||||
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||||
|
issue_iid: z.number().describe("The internal ID of the project issue"),
|
||||||
|
title: z.string().optional().describe("The title of the issue"),
|
||||||
|
description: z.string().optional().describe("The description of the issue"),
|
||||||
|
assignee_ids: z.array(z.number()).optional().describe("Array of user IDs to assign issue to"),
|
||||||
|
confidential: z.boolean().optional().describe("Set the issue to be confidential"),
|
||||||
|
discussion_locked: z.boolean().optional().describe("Flag to lock discussions"),
|
||||||
|
due_date: z.string().optional().describe("Date the issue is due (YYYY-MM-DD)"),
|
||||||
|
labels: z.array(z.string()).optional().describe("Array of label names"),
|
||||||
|
milestone_id: z.number().optional().describe("Milestone ID to assign"),
|
||||||
|
state_event: z.enum(['close', 'reopen']).optional().describe("Update issue state (close/reopen)"),
|
||||||
|
weight: z.number().optional().describe("Weight of the issue (0-9)"),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const DeleteIssueSchema = z.object({
|
||||||
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||||
|
issue_iid: z.number().describe("The internal ID of the project issue"),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Issue links related schemas
|
||||||
|
export const GitLabIssueLinkSchema = z.object({
|
||||||
|
source_issue: GitLabIssueSchema,
|
||||||
|
target_issue: GitLabIssueSchema,
|
||||||
|
link_type: z.enum(['relates_to', 'blocks', 'is_blocked_by']),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const ListIssueLinksSchema = z.object({
|
||||||
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||||
|
issue_iid: z.number().describe("The internal ID of a project's issue"),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const GetIssueLinkSchema = z.object({
|
||||||
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||||
|
issue_iid: z.number().describe("The internal ID of a project's issue"),
|
||||||
|
issue_link_id: z.number().describe("ID of an issue relationship"),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const CreateIssueLinkSchema = z.object({
|
||||||
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||||
|
issue_iid: z.number().describe("The internal ID of a project's issue"),
|
||||||
|
target_project_id: z.string().describe("The ID or URL-encoded path of a target project"),
|
||||||
|
target_issue_iid: z.number().describe("The internal ID of a target project's issue"),
|
||||||
|
link_type: z.enum(['relates_to', 'blocks', 'is_blocked_by']).optional().describe("The type of the relation, defaults to relates_to"),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const DeleteIssueLinkSchema = z.object({
|
||||||
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||||
|
issue_iid: z.number().describe("The internal ID of a project's issue"),
|
||||||
|
issue_link_id: z.number().describe("The ID of an issue relationship"),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Namespace API operation schemas
|
||||||
export const ListNamespacesSchema = z.object({
|
export const ListNamespacesSchema = z.object({
|
||||||
search: z.string().optional().describe("Only returns namespaces accessible by the current user"),
|
search: z.string().optional().describe("Search term for namespaces"),
|
||||||
owned_only: z.boolean().optional().describe("If true, only returns namespaces by the current user"),
|
page: z.number().optional().describe("Page number for pagination"),
|
||||||
top_level_only: z.boolean().optional().describe("In GitLab 16.8 and later, if true, only returns top-level namespaces"),
|
per_page: z.number().optional().describe("Number of items per page"),
|
||||||
|
owned: z.boolean().optional().describe("Filter for namespaces owned by current user"),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const GetNamespaceSchema = z.object({
|
export const GetNamespaceSchema = z.object({
|
||||||
id: z.string().describe("ID or URL-encoded path of the namespace"),
|
namespace_id: z.string().describe("Namespace ID or full path"),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const VerifyNamespaceSchema = z.object({
|
export const VerifyNamespaceSchema = z.object({
|
||||||
namespace: z.string().describe("Path of the namespace"),
|
path: z.string().describe("Namespace path to verify"),
|
||||||
parent_id: z.number().optional().describe("ID of the parent namespace. If unspecified, only returns top-level namespaces"),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Project API operation schemas
|
// Project API operation schemas
|
||||||
export const GetProjectSchema = z.object({
|
export const GetProjectSchema = z.object({
|
||||||
id: z.string().describe("ID or URL-encoded path of the project"),
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||||
license: z.boolean().optional().describe("Include project license data"),
|
|
||||||
statistics: z.boolean().optional().describe("Include project statistics"),
|
|
||||||
with_custom_attributes: z.boolean().optional().describe("Include custom attributes in response"),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const ListProjectsSchema = z.object({
|
export const ListProjectsSchema = z.object({
|
||||||
archived: z.boolean().optional().describe("Limit by archived status"),
|
search: z.string().optional().describe("Search term for projects"),
|
||||||
id_after: z.number().optional().describe("Limit results to projects with IDs greater than the specified ID"),
|
|
||||||
id_before: z.number().optional().describe("Limit results to projects with IDs less than the specified ID"),
|
|
||||||
membership: z.boolean().optional().describe("Limit by projects that the current user is a member of"),
|
|
||||||
min_access_level: z.number().optional().describe("Limit by minimum access level"),
|
|
||||||
order_by: z.enum(['id', 'name', 'path', 'created_at', 'updated_at', 'last_activity_at']).optional().describe("Return projects ordered by field"),
|
|
||||||
owned: z.boolean().optional().describe("Limit by projects explicitly owned by the current user"),
|
|
||||||
search: z.string().optional().describe("Return list of projects matching the search criteria"),
|
|
||||||
simple: z.boolean().optional().describe("Return only limited fields for each project"),
|
|
||||||
sort: z.enum(['asc', 'desc']).optional().describe("Return projects sorted in ascending or descending order"),
|
|
||||||
starred: z.boolean().optional().describe("Limit by projects starred by the current user"),
|
|
||||||
visibility: z.enum(['public', 'internal', 'private']).optional().describe("Limit by visibility"),
|
|
||||||
with_custom_attributes: z.boolean().optional().describe("Include custom attributes in response"),
|
|
||||||
with_issues_enabled: z.boolean().optional().describe("Limit by enabled issues feature"),
|
|
||||||
with_merge_requests_enabled: z.boolean().optional().describe("Limit by enabled merge requests feature"),
|
|
||||||
with_programming_language: z.string().optional().describe("Limit by projects which use the given programming language"),
|
|
||||||
with_shared: z.boolean().optional().describe("Include projects shared to this group"),
|
|
||||||
page: z.number().optional().describe("Page number for pagination"),
|
page: z.number().optional().describe("Page number for pagination"),
|
||||||
per_page: z.number().optional().describe("Number of items per page"),
|
per_page: z.number().optional().describe("Number of items per page"),
|
||||||
|
owned: z.boolean().optional().describe("Filter for projects owned by current user"),
|
||||||
|
membership: z.boolean().optional().describe("Filter for projects where current user is a member"),
|
||||||
|
simple: z.boolean().optional().describe("Return only limited fields"),
|
||||||
|
archived: z.boolean().optional().describe("Filter for archived projects"),
|
||||||
|
visibility: z.enum(["public", "internal", "private"]).optional().describe("Filter by project visibility"),
|
||||||
|
order_by: z.enum(["id", "name", "path", "created_at", "updated_at", "last_activity_at"]).optional().describe("Return projects ordered by field"),
|
||||||
|
sort: z.enum(["asc", "desc"]).optional().describe("Return projects sorted in ascending or descending order"),
|
||||||
|
with_issues_enabled: z.boolean().optional().describe("Filter projects with issues feature enabled"),
|
||||||
|
with_merge_requests_enabled: z.boolean().optional().describe("Filter projects with merge requests feature enabled"),
|
||||||
|
min_access_level: z.number().optional().describe("Filter by minimum access level"),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Export types
|
// Export types
|
||||||
export type GitLabAuthor = z.infer<typeof GitLabAuthorSchema>;
|
export type GitLabAuthor = z.infer<typeof GitLabAuthorSchema>;
|
||||||
export type GitLabFork = z.infer<typeof GitLabForkSchema>;
|
export type GitLabFork = z.infer<typeof GitLabForkSchema>;
|
||||||
export type GitLabIssue = z.infer<typeof GitLabIssueSchema>;
|
export type GitLabIssue = z.infer<typeof GitLabIssueSchema>;
|
||||||
|
export type GitLabIssueWithLinkDetails = z.infer<typeof GitLabIssueWithLinkDetailsSchema>;
|
||||||
export type GitLabMergeRequest = z.infer<typeof GitLabMergeRequestSchema>;
|
export type GitLabMergeRequest = z.infer<typeof GitLabMergeRequestSchema>;
|
||||||
export type GitLabRepository = z.infer<typeof GitLabRepositorySchema>;
|
export type GitLabRepository = z.infer<typeof GitLabRepositorySchema>;
|
||||||
export type GitLabFileContent = z.infer<typeof GitLabFileContentSchema>;
|
export type GitLabFileContent = z.infer<typeof GitLabFileContentSchema>;
|
||||||
export type GitLabDirectoryContent = z.infer<
|
export type GitLabDirectoryContent = z.infer<typeof GitLabDirectoryContentSchema>;
|
||||||
typeof GitLabDirectoryContentSchema
|
|
||||||
>;
|
|
||||||
export type GitLabContent = z.infer<typeof GitLabContentSchema>;
|
export type GitLabContent = z.infer<typeof GitLabContentSchema>;
|
||||||
export type FileOperation = z.infer<typeof FileOperationSchema>;
|
export type FileOperation = z.infer<typeof FileOperationSchema>;
|
||||||
export type GitLabTree = z.infer<typeof GitLabTreeSchema>;
|
export type GitLabTree = z.infer<typeof GitLabTreeSchema>;
|
||||||
export type GitLabCommit = z.infer<typeof GitLabCommitSchema>;
|
export type GitLabCommit = z.infer<typeof GitLabCommitSchema>;
|
||||||
export type GitLabReference = z.infer<typeof GitLabReferenceSchema>;
|
export type GitLabReference = z.infer<typeof GitLabReferenceSchema>;
|
||||||
export type CreateRepositoryOptions = z.infer<
|
export type CreateRepositoryOptions = z.infer<typeof CreateRepositoryOptionsSchema>;
|
||||||
typeof CreateRepositoryOptionsSchema
|
|
||||||
>;
|
|
||||||
export type CreateIssueOptions = z.infer<typeof CreateIssueOptionsSchema>;
|
export type CreateIssueOptions = z.infer<typeof CreateIssueOptionsSchema>;
|
||||||
export type CreateMergeRequestOptions = z.infer<
|
export type CreateMergeRequestOptions = z.infer<typeof CreateMergeRequestOptionsSchema>;
|
||||||
typeof CreateMergeRequestOptionsSchema
|
|
||||||
>;
|
|
||||||
export type CreateBranchOptions = z.infer<typeof CreateBranchOptionsSchema>;
|
export type CreateBranchOptions = z.infer<typeof CreateBranchOptionsSchema>;
|
||||||
export type GitLabCreateUpdateFileResponse = z.infer<
|
export type GitLabCreateUpdateFileResponse = z.infer<typeof GitLabCreateUpdateFileResponseSchema>;
|
||||||
typeof GitLabCreateUpdateFileResponseSchema
|
|
||||||
>;
|
|
||||||
export type GitLabSearchResponse = z.infer<typeof GitLabSearchResponseSchema>;
|
export type GitLabSearchResponse = z.infer<typeof GitLabSearchResponseSchema>;
|
||||||
export type GitLabMergeRequestDiff = z.infer<
|
export type GitLabMergeRequestDiff = z.infer<typeof GitLabMergeRequestDiffSchema>;
|
||||||
typeof GitLabMergeRequestDiffSchema
|
|
||||||
>;
|
|
||||||
export type CreateNoteOptions = z.infer<typeof CreateNoteSchema>;
|
export type CreateNoteOptions = z.infer<typeof CreateNoteSchema>;
|
||||||
|
export type GitLabIssueLink = z.infer<typeof GitLabIssueLinkSchema>;
|
||||||
export type GitLabNamespace = z.infer<typeof GitLabNamespaceSchema>;
|
export type GitLabNamespace = z.infer<typeof GitLabNamespaceSchema>;
|
||||||
export type GitLabNamespaceExistsResponse = z.infer<typeof GitLabNamespaceExistsResponseSchema>;
|
export type GitLabNamespaceExistsResponse = z.infer<typeof GitLabNamespaceExistsResponseSchema>;
|
||||||
export type GitLabProject = z.infer<typeof GitLabRepositorySchema>;
|
export type GitLabProject = z.infer<typeof GitLabProjectSchema>;
|
||||||
|
Reference in New Issue
Block a user