Refactor usage of authorSchema

This commit is contained in:
Sebastian Martinez
2024-08-22 09:43:06 +02:00
parent cf08c83913
commit b84cace48f
6 changed files with 12 additions and 8 deletions
+2
View File
@@ -9,6 +9,7 @@ import type {
TreeStats,
} from "./lib/project.js";
import type {
Author,
Config,
SeedingPolicy,
DefaultSeedingPolicy,
@@ -50,6 +51,7 @@ import {
} from "./lib/shared.js";
export type {
Author,
BaseUrl,
Blob,
ChangesetWithDiff,
+2 -1
View File
@@ -26,6 +26,7 @@ import {
} from "./project/commit.js";
import { issueSchema, issuesSchema } from "./project/issue.js";
import { patchSchema, patchesSchema } from "./project/patch.js";
import { authorSchema } from "./shared.js";
const repoSchema = object({
rid: string(),
@@ -34,7 +35,7 @@ const repoSchema = object({
description: string(),
defaultBranch: string(),
}),
delegates: array(object({ id: string(), alias: optional(string()) })),
delegates: array(authorSchema),
head: string(),
threshold: number(),
visibility: union([
+2
View File
@@ -117,6 +117,8 @@ export const codeLocationSchema = object({
new: rangeSchema.nullable(),
});
export type Author = z.infer<typeof authorSchema>;
export const authorSchema = object({
id: string(),
alias: string().optional(),
+2 -5
View File
@@ -1,4 +1,4 @@
import type { BaseUrl } from "@http-client";
import type { Author, BaseUrl } from "@http-client";
import md5 from "md5";
import bs58 from "bs58";
@@ -80,10 +80,7 @@ export function formatCommit(oid: string): string {
return oid.substring(0, 7);
}
export function formatEditedCaption(
author: { id: string; alias?: string },
timestamp: number,
) {
export function formatEditedCaption(author: Author, timestamp: number) {
return `${
author.alias ? author.alias : formatNodeId(author.id)
} edited ${absoluteTimestamp(timestamp)}`;
+2 -1
View File
@@ -1,5 +1,6 @@
<script lang="ts">
import type {
Author,
BaseUrl,
Comment,
DiffResponse,
@@ -44,7 +45,7 @@
export let revisionOid: string;
export let revisionTimestamp: number;
export let revisionReactions: Comment["reactions"];
export let revisionAuthor: { id: string; alias?: string | undefined };
export let revisionAuthor: Author;
export let revisionDescription: string;
export let timelines: Timeline[];
export let previousRevBase: string | undefined = undefined;
+2 -1
View File
@@ -1,5 +1,6 @@
<script lang="ts" context="module">
import type {
Author,
Comment,
Review,
Merge,
@@ -168,7 +169,7 @@
revisionOid: string;
revisionEdits: Revision["edits"];
revisionReactions: Revision["reactions"];
revisionAuthor: { id: string; alias?: string | undefined };
revisionAuthor: Author;
revisionDescription: string;
},
Timeline[],