Skip to content

Commit 316e23a

Browse files
committed
Simplify the Instant zod type.
1 parent 479cda7 commit 316e23a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

frontend/src/lib/repo-summaries.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
import { Temporal, toTemporalInstant } from '@js-temporal/polyfill';
1+
import { Temporal } from '@js-temporal/polyfill';
22
import { z } from 'zod';
33

44
export const SloType = z.enum(["triage", "urgent", "important", "none"]);
55
export type SloType = z.infer<typeof SloType>;
66

77
const duration = z.string().transform(val => Temporal.Duration.from(val));
8+
const instant = z.string().transform(val => Temporal.Instant.from(val));
89

910
export const IssueSummary = z.object({
1011
url: z.string().url(),
1112
title: z.string(),
12-
createdAt: z.coerce.date().transform(val => toTemporalInstant.call(val)),
13+
createdAt: instant,
1314
pull_request: z.object({ draft: z.boolean().default(false) }).optional(),
1415
labels: z.array(z.string()),
1516
sloTimeUsed: duration,
@@ -23,7 +24,7 @@ export const IssueSummary = z.object({
2324
export type IssueSummary = z.infer<typeof IssueSummary>;
2425

2526
export const RepoSummary = z.object({
26-
cachedAt: z.string().transform(val => Temporal.Instant.from(val)),
27+
cachedAt: instant,
2728
org: z.string(),
2829
repo: z.string(),
2930
issues: IssueSummary.array(),

0 commit comments

Comments
 (0)