fix contract
This commit is contained in:
parent
44f68efbdc
commit
c31f00f54f
2 changed files with 25 additions and 3 deletions
|
|
@ -18,6 +18,7 @@ import {
|
||||||
GitHubSearchResponseSchema,
|
GitHubSearchResponseSchema,
|
||||||
GitHubTreeSchema,
|
GitHubTreeSchema,
|
||||||
GitHubCommitSchema,
|
GitHubCommitSchema,
|
||||||
|
GitHubListCommitsSchema,
|
||||||
CreateRepositoryOptionsSchema,
|
CreateRepositoryOptionsSchema,
|
||||||
CreateIssueOptionsSchema,
|
CreateIssueOptionsSchema,
|
||||||
CreatePullRequestOptionsSchema,
|
CreatePullRequestOptionsSchema,
|
||||||
|
|
@ -42,7 +43,8 @@ import {
|
||||||
CreatePullRequestSchema,
|
CreatePullRequestSchema,
|
||||||
ForkRepositorySchema,
|
ForkRepositorySchema,
|
||||||
CreateBranchSchema,
|
CreateBranchSchema,
|
||||||
ListCommitsSchema
|
ListCommitsSchema,
|
||||||
|
GitHubListCommits
|
||||||
} from './schemas.js';
|
} from './schemas.js';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { zodToJsonSchema } from 'zod-to-json-schema';
|
import { zodToJsonSchema } from 'zod-to-json-schema';
|
||||||
|
|
@ -474,7 +476,7 @@ async function listCommits(
|
||||||
page: number = 1,
|
page: number = 1,
|
||||||
perPage: number = 30,
|
perPage: number = 30,
|
||||||
sha?: string,
|
sha?: string,
|
||||||
): Promise<GitHubCommit[]> {
|
): Promise<GitHubListCommits> {
|
||||||
const url = new URL(`https://api.github.com/repos/${owner}/${repo}/commits`);
|
const url = new URL(`https://api.github.com/repos/${owner}/${repo}/commits`);
|
||||||
url.searchParams.append("page", page.toString());
|
url.searchParams.append("page", page.toString());
|
||||||
url.searchParams.append("per_page", perPage.toString());
|
url.searchParams.append("per_page", perPage.toString());
|
||||||
|
|
@ -499,7 +501,7 @@ async function listCommits(
|
||||||
throw new Error(`GitHub API error: ${response.statusText}`);
|
throw new Error(`GitHub API error: ${response.statusText}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return GitHubCommitSchema.array().parse(await response.json());
|
return GitHubListCommitsSchema.parse(await response.json());
|
||||||
}
|
}
|
||||||
|
|
||||||
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,25 @@ export const GitHubTreeSchema = z.object({
|
||||||
truncated: z.boolean()
|
truncated: z.boolean()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const GitHubListCommitsSchema = z.array(z.object({
|
||||||
|
sha: z.string(),
|
||||||
|
node_id: z.string(),
|
||||||
|
commit: z.object({
|
||||||
|
author: GitHubAuthorSchema,
|
||||||
|
committer: GitHubAuthorSchema,
|
||||||
|
message: z.string(),
|
||||||
|
tree: z.object({
|
||||||
|
sha: z.string(),
|
||||||
|
url: z.string()
|
||||||
|
}),
|
||||||
|
url: z.string(),
|
||||||
|
comment_count: z.number(),
|
||||||
|
}),
|
||||||
|
url: z.string(),
|
||||||
|
html_url: z.string(),
|
||||||
|
comments_url: z.string()
|
||||||
|
}));
|
||||||
|
|
||||||
export const GitHubCommitSchema = z.object({
|
export const GitHubCommitSchema = z.object({
|
||||||
sha: z.string(),
|
sha: z.string(),
|
||||||
node_id: z.string(),
|
node_id: z.string(),
|
||||||
|
|
@ -378,6 +397,7 @@ export type GitHubContent = z.infer<typeof GitHubContentSchema>;
|
||||||
export type FileOperation = z.infer<typeof FileOperationSchema>;
|
export type FileOperation = z.infer<typeof FileOperationSchema>;
|
||||||
export type GitHubTree = z.infer<typeof GitHubTreeSchema>;
|
export type GitHubTree = z.infer<typeof GitHubTreeSchema>;
|
||||||
export type GitHubCommit = z.infer<typeof GitHubCommitSchema>;
|
export type GitHubCommit = z.infer<typeof GitHubCommitSchema>;
|
||||||
|
export type GitHubListCommits = z.infer<typeof GitHubListCommitsSchema>;
|
||||||
export type GitHubReference = z.infer<typeof GitHubReferenceSchema>;
|
export type GitHubReference = z.infer<typeof GitHubReferenceSchema>;
|
||||||
export type CreateRepositoryOptions = z.infer<typeof CreateRepositoryOptionsSchema>;
|
export type CreateRepositoryOptions = z.infer<typeof CreateRepositoryOptionsSchema>;
|
||||||
export type CreateIssueOptions = z.infer<typeof CreateIssueOptionsSchema>;
|
export type CreateIssueOptions = z.infer<typeof CreateIssueOptionsSchema>;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue