All files / lib/packages/shared-types issue.ts

100% Statements 13/13
100% Branches 0/0
100% Functions 0/0
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40    186x                       186x               186x       186x         186x       186x     186x  
import { z } from "zod";
 
const baseIssueSchema = {
  title: z.string().min(1, { message: "Title is required" }),
  description: z.string().min(1, { message: "Description is required" }),
  type: z.enum(["look", "functionality", "other"], {
    required_error: "type is required",
  }),
  priority: z.enum(["low", "medium", "high"], {
    required_error: "priority is required",
  }),
  resolved: z.boolean().default(false),
};
 
export const issueSchema = z.object({
  id: z.string().uuid(),
  createdAt: z.number(),
  updatedAt: z.number().optional(),
  ...baseIssueSchema,
});
 
export type Issue = z.infer<typeof issueSchema>;
export const validateIssue = issueSchema.parse;
 
//////////////////////
 
export const createIssueSchema = z.object({
  ...baseIssueSchema,
});
 
export type CreateIssue = z.infer<typeof createIssueSchema>;
export const validateCreateIssue = createIssueSchema.parse;
 
///////////////////////
 
export const listIssueSchema = issueSchema.array();
 
export type IssueList = [z.infer<typeof listIssueSchema>];
export const validateListIssues = listIssueSchema.parse;