Skip to content

Commit

Permalink
Simplify the Instant zod type.
Browse files Browse the repository at this point in the history
  • Loading branch information
jyasskin committed Oct 26, 2023
1 parent 479cda7 commit 316e23a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions frontend/src/lib/repo-summaries.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { Temporal, toTemporalInstant } from '@js-temporal/polyfill';
import { Temporal } from '@js-temporal/polyfill';
import { z } from 'zod';

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

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

export const IssueSummary = z.object({
url: z.string().url(),
title: z.string(),
createdAt: z.coerce.date().transform(val => toTemporalInstant.call(val)),
createdAt: instant,
pull_request: z.object({ draft: z.boolean().default(false) }).optional(),
labels: z.array(z.string()),
sloTimeUsed: duration,
Expand All @@ -23,7 +24,7 @@ export const IssueSummary = z.object({
export type IssueSummary = z.infer<typeof IssueSummary>;

export const RepoSummary = z.object({
cachedAt: z.string().transform(val => Temporal.Instant.from(val)),
cachedAt: instant,
org: z.string(),
repo: z.string(),
issues: IssueSummary.array(),
Expand Down

0 comments on commit 316e23a

Please sign in to comment.