tianji/prisma/zod/website.ts

38 lines
1.5 KiB
TypeScript
Raw Permalink Normal View History

import * as z from "zod"
2023-12-13 10:21:04 +00:00
import * as imports from "./schemas"
import { CompleteWorkspace, RelatedWorkspaceModelSchema, CompleteMonitor, RelatedMonitorModelSchema, CompleteWebsiteSession, RelatedWebsiteSessionModelSchema, CompleteWebsiteEventData, RelatedWebsiteEventDataModelSchema, CompleteWebsiteSessionData, RelatedWebsiteSessionDataModelSchema } from "./index"
export const WebsiteModelSchema = z.object({
id: z.string(),
workspaceId: z.string(),
name: z.string(),
domain: z.string().nullish(),
shareId: z.string().nullish(),
resetAt: z.date().nullish(),
monitorId: z.string().nullish(),
createdAt: z.date(),
updatedAt: z.date(),
deletedAt: z.date().nullish(),
})
export interface CompleteWebsite extends z.infer<typeof WebsiteModelSchema> {
workspace: CompleteWorkspace
monitor?: CompleteMonitor | null
sessions: CompleteWebsiteSession[]
eventData: CompleteWebsiteEventData[]
sessionData: CompleteWebsiteSessionData[]
}
/**
* RelatedWebsiteModelSchema contains all relations on your model in addition to the scalars
*
* NOTE: Lazy required in case of potential circular dependencies within schema
*/
export const RelatedWebsiteModelSchema: z.ZodSchema<CompleteWebsite> = z.lazy(() => WebsiteModelSchema.extend({
workspace: RelatedWorkspaceModelSchema,
monitor: RelatedMonitorModelSchema.nullish(),
sessions: RelatedWebsiteSessionModelSchema.array(),
eventData: RelatedWebsiteEventDataModelSchema.array(),
sessionData: RelatedWebsiteSessionDataModelSchema.array(),
}))