Clean up some unnecessary types

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
Sebastian Martinez
2023-09-19 07:49:36 +02:00
committed by Rūdolfs Ošiņš
parent 217d8b2dd4
commit ee9cb2b0d7
+2 -28
View File
@@ -1,23 +1,9 @@
import type { z } from "zod";
export type { Commits, HunkLine, Commit, Diff, CommitHeader, DiffContent };
import { array, literal, number, object, optional, string, union } from "zod";
export { commitHeaderSchema, diffSchema, commitSchema, commitsSchema };
export type {
Commits,
HunkLine,
Commit,
DiffFile,
Diff,
DiffCopiedChangeset,
DiffMovedChangeset,
CommitHeader,
DiffAddedChangeset,
DiffDeletedChangeset,
DiffModifiedChangeset,
DiffContent,
};
const gitPersonSchema = object({
name: string(),
email: string(),
@@ -50,8 +36,6 @@ const deletionHunkLineSchema = object({
type: literal("deletion"),
});
type DiffFile = z.infer<typeof diffFileSchema>;
const diffFileSchema = object({
oid: string(),
mode: union([
@@ -103,33 +87,23 @@ const diffChangesetSchema = object({
diff: diffContentSchema,
});
type DiffAddedChangeset = z.infer<typeof diffAddedChangesetSchema>;
const diffAddedChangesetSchema = diffChangesetSchema.merge(
object({ new: diffFileSchema }),
);
type DiffDeletedChangeset = z.infer<typeof diffDeletedChangesetSchema>;
const diffDeletedChangesetSchema = diffChangesetSchema.merge(
object({ old: diffFileSchema }),
);
type DiffModifiedChangeset = z.infer<typeof diffModifiedChangesetSchema>;
const diffModifiedChangesetSchema = diffChangesetSchema.merge(
object({ new: diffFileSchema, old: diffFileSchema }),
);
type DiffCopiedChangeset = z.infer<typeof diffCopiedChangesetSchema>;
const diffCopiedChangesetSchema = object({
newPath: string(),
oldPath: string(),
});
type DiffMovedChangeset = z.infer<typeof diffMovedChangesetSchema>;
const diffMovedChangesetSchema = diffCopiedChangesetSchema.merge(
object({
old: optional(diffFileSchema),