Fix Issue Links API schema to properly handle GitLab response formats
This commit is contained in:
8
index.ts
8
index.ts
@ -49,6 +49,7 @@ import {
|
|||||||
UpdateIssueSchema,
|
UpdateIssueSchema,
|
||||||
DeleteIssueSchema,
|
DeleteIssueSchema,
|
||||||
GitLabIssueLinkSchema,
|
GitLabIssueLinkSchema,
|
||||||
|
GitLabIssueWithLinkDetailsSchema,
|
||||||
ListIssueLinksSchema,
|
ListIssueLinksSchema,
|
||||||
GetIssueLinkSchema,
|
GetIssueLinkSchema,
|
||||||
CreateIssueLinkSchema,
|
CreateIssueLinkSchema,
|
||||||
@ -72,6 +73,7 @@ import {
|
|||||||
type FileOperation,
|
type FileOperation,
|
||||||
type GitLabMergeRequestDiff,
|
type GitLabMergeRequestDiff,
|
||||||
type GitLabIssueLink,
|
type GitLabIssueLink,
|
||||||
|
type GitLabIssueWithLinkDetails,
|
||||||
type GitLabNamespace,
|
type GitLabNamespace,
|
||||||
type GitLabNamespaceExistsResponse,
|
type GitLabNamespaceExistsResponse,
|
||||||
type GitLabProject,
|
type GitLabProject,
|
||||||
@ -480,12 +482,12 @@ async function deleteIssue(
|
|||||||
*
|
*
|
||||||
* @param {string} projectId - The ID or URL-encoded path of the project
|
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||||
* @param {number} issueIid - The internal ID of the project issue
|
* @param {number} issueIid - The internal ID of the project issue
|
||||||
* @returns {Promise<GitLabIssueLink[]>} List of issue links
|
* @returns {Promise<GitLabIssueWithLinkDetails[]>} List of issues with link details
|
||||||
*/
|
*/
|
||||||
async function listIssueLinks(
|
async function listIssueLinks(
|
||||||
projectId: string,
|
projectId: string,
|
||||||
issueIid: number
|
issueIid: number
|
||||||
): Promise<GitLabIssueLink[]> {
|
): Promise<GitLabIssueWithLinkDetails[]> {
|
||||||
const url = new URL(
|
const url = new URL(
|
||||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/issues/${issueIid}/links`
|
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/issues/${issueIid}/links`
|
||||||
);
|
);
|
||||||
@ -496,7 +498,7 @@ async function listIssueLinks(
|
|||||||
|
|
||||||
await handleGitLabError(response);
|
await handleGitLabError(response);
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
return z.array(GitLabIssueLinkSchema).parse(data);
|
return z.array(GitLabIssueWithLinkDetailsSchema).parse(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
14
schemas.ts
14
schemas.ts
@ -280,6 +280,14 @@ export const GitLabIssueSchema = z.object({
|
|||||||
weight: z.number().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
|
// Fork related schemas
|
||||||
export const GitLabForkParentSchema = z.object({
|
export const GitLabForkParentSchema = z.object({
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
@ -544,12 +552,9 @@ export const DeleteIssueSchema = z.object({
|
|||||||
|
|
||||||
// Issue links related schemas
|
// Issue links related schemas
|
||||||
export const GitLabIssueLinkSchema = z.object({
|
export const GitLabIssueLinkSchema = z.object({
|
||||||
id: z.number(),
|
|
||||||
link_type: z.enum(['relates_to', 'blocks', 'is_blocked_by']),
|
|
||||||
source_issue: GitLabIssueSchema,
|
source_issue: GitLabIssueSchema,
|
||||||
target_issue: GitLabIssueSchema,
|
target_issue: GitLabIssueSchema,
|
||||||
link_created_at: z.string().optional(),
|
link_type: z.enum(['relates_to', 'blocks', 'is_blocked_by']),
|
||||||
link_updated_at: z.string().optional(),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const ListIssueLinksSchema = z.object({
|
export const ListIssueLinksSchema = z.object({
|
||||||
@ -618,6 +623,7 @@ export const ListProjectsSchema = z.object({
|
|||||||
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>;
|
||||||
|
Reference in New Issue
Block a user