Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

repo-report-schema.ts

46 lines1.1 KB

1import { z } from 'zod'
2​
3export const RepoReportSchema = z.object({
4 name: z.string(),
5 oneLiner: z.string(),
6 audience: z.string(),
7 mainPackages: z.array(
8 z.object({
9 name: z.string(),
10 role: z.string(),
11 }),
12 ),
13 howToRun: z.string(),
14})
15​
16export type RepoReport = z.infer<typeof RepoReportSchema>
17​
18const RepoReportCardSchema = z
19 .object({
20 name: z.string().optional(),
21 oneLiner: z.string().optional(),
22 audience: z.string().optional(),
23 howToRun: z.string().optional(),
24 mainPackages: z
25 .array(
26 z.object({
27 name: z.string().optional(),
28 role: z.string().optional(),
29 }),
30 )
31 .optional(),
32 })
33 .refine(
34 (value) =>
35 value.name !== undefined ||
36 value.oneLiner !== undefined ||
37 value.audience !== undefined ||
38 value.howToRun !== undefined ||
39 value.mainPackages !== undefined,
40 )
41​
42export type RepoReportCard = z.infer<typeof RepoReportCardSchema>
43​
44export function looksLikeReport(value: unknown): value is RepoReportCard {
45 return RepoReportCardSchema.safeParse(value).success