Add GitHubCreateUpdateFileResponseSchema to files module

This commit is contained in:
Peter M. Elias 2024-12-28 02:10:27 -08:00
commit 9f43900170

View file

@ -2,10 +2,11 @@ import { z } from "zod";
import { githubRequest } from "../common/utils"; import { githubRequest } from "../common/utils";
import { import {
GitHubContentSchema, GitHubContentSchema,
GitHubCreateUpdateFileResponseSchema, GitHubAuthorSchema,
GitHubTreeSchema, GitHubTreeSchema,
GitHubCommitSchema, GitHubCommitSchema,
GitHubReferenceSchema, GitHubReferenceSchema,
GitHubFileContentSchema,
} from "../common/types"; } from "../common/types";
// Schema definitions // Schema definitions
@ -39,8 +40,33 @@ export const PushFilesSchema = z.object({
message: z.string().describe("Commit message"), message: z.string().describe("Commit message"),
}); });
export const GitHubCreateUpdateFileResponseSchema = z.object({
content: GitHubFileContentSchema.nullable(),
commit: z.object({
sha: z.string(),
node_id: z.string(),
url: z.string(),
html_url: z.string(),
author: GitHubAuthorSchema,
committer: GitHubAuthorSchema,
message: z.string(),
tree: z.object({
sha: z.string(),
url: z.string(),
}),
parents: z.array(
z.object({
sha: z.string(),
url: z.string(),
html_url: z.string(),
})
),
}),
});
// Type exports // Type exports
export type FileOperation = z.infer<typeof FileOperationSchema>; export type FileOperation = z.infer<typeof FileOperationSchema>;
export type GitHubCreateUpdateFileResponse = z.infer<typeof GitHubCreateUpdateFileResponseSchema>;
// Function implementations // Function implementations
export async function getFileContents( export async function getFileContents(