PioneerSquareLabs / otto-playground

A playground where Otto can run free while hopefully not accidentally reformatting your hard drive
https://otto-playground.vercel.app
13 stars 0 forks source link

Create TypeScript interfaces => src/types.ts #712

Closed otto-jacob closed 1 year ago

otto-jacob commented 1 year ago

Create a file called types.ts in the src directory that will contain the TypeScript interfaces and Zod schemas for the database. Here is the code:

import { z } from "zod";

export const userSchema = z.object({ id: z.string().default("cuid()"), githubId: z.number(), name: z.string(), email: z.string(), imageUrl: z.string().nullable(), createdAt: z.date().default(() => new Date()), updatedAt: z.date().default(() => new Date()), });

export type User = z.infer;

export const projectSchema = z.object({ id: z.string().default("cuid()"), name: z.string(), description: z.string(), userId: z.string(), githubRepoUrl: z.string().nullable(), slackChannelId: z.string().nullable(), createdAt: z.date().default(() => new Date()), updatedAt: z.date().default(() => new Date()), });

export type Project = z.infer;

export const projectSitemapSchema = z.object({ id: z.string().default("cuid()"), projectId: z.string(), fileName: z.string(), fileDescription: z.string().nullable(), figmaUrl: z.string().nullable(), approved: z.boolean().default(false), createdAt: z.date().default(() => new Date()), updatedAt: z.date().default(() => new Date()), });

export type ProjectSitemap = z.infer;

export const projectDataSchemaSchema = z.object({ id: z.string().default("cuid()"), projectId: z.string(), tableName: z.string(), approved: z.boolean().default(false), createdAt: z.date().default(() => new Date()), updatedAt: z.date().default(() => new Date()), });

export type ProjectDataSchema = z.infer;

export const projectDataColumnSchema = z.object({ id: z.string().default("cuid()"), dataSchemaId: z.string(), columnName: z.string(), columnType: z.string(), columnDescription: z.string().nullable(), createdAt: z.date().default(() => new Date()), updatedAt: z.date().default(() => new Date()), });

export type ProjectDataColumn = z.infer;

export const projectTaskSchema = z.object({ id: z.string().default("cuid()"), projectId: z.string(), taskName: z.string(), taskDescription: z.string(), githubIssueId: z.number().nullable(), approved: z.boolean().default(false), createdAt: z.date().default(() => new Date()), updatedAt: z.date().default(() => new Date()), });

export type ProjectTask = z.infer;