2023-11-29 16:43:55 +00:00
|
|
|
import * as z from "zod"
|
2023-12-13 10:21:04 +00:00
|
|
|
import * as imports from "./schemas"
|
2024-01-05 15:05:19 +00:00
|
|
|
import { CompleteWorkspacesOnUsers, RelatedWorkspacesOnUsersModelSchema, CompleteWebsite, RelatedWebsiteModelSchema, CompleteNotification, RelatedNotificationModelSchema, CompleteMonitor, RelatedMonitorModelSchema, CompleteMonitorStatusPage, RelatedMonitorStatusPageModelSchema, CompleteUser, RelatedUserModelSchema, CompleteWorkspaceDailyUsage, RelatedWorkspaceDailyUsageModelSchema } from "./index"
|
2023-11-29 16:43:55 +00:00
|
|
|
|
|
|
|
// Helper schema for JSON fields
|
|
|
|
type Literal = boolean | number | string
|
|
|
|
type Json = Literal | { [key: string]: Json } | Json[]
|
|
|
|
const literalSchema = z.union([z.string(), z.number(), z.boolean()])
|
|
|
|
const jsonSchema: z.ZodSchema<Json> = z.lazy(() => z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)]))
|
|
|
|
|
|
|
|
export const WorkspaceModelSchema = z.object({
|
|
|
|
id: z.string(),
|
|
|
|
name: z.string(),
|
|
|
|
dashboardOrder: z.string().array(),
|
|
|
|
/**
|
|
|
|
* [DashboardLayout]
|
|
|
|
*/
|
|
|
|
dashboardLayout: jsonSchema,
|
|
|
|
createdAt: z.date(),
|
|
|
|
updatedAt: z.date(),
|
|
|
|
})
|
|
|
|
|
|
|
|
export interface CompleteWorkspace extends z.infer<typeof WorkspaceModelSchema> {
|
|
|
|
users: CompleteWorkspacesOnUsers[]
|
|
|
|
websites: CompleteWebsite[]
|
|
|
|
notifications: CompleteNotification[]
|
|
|
|
monitors: CompleteMonitor[]
|
2023-12-13 10:21:04 +00:00
|
|
|
monitorStatusPages: CompleteMonitorStatusPage[]
|
2023-11-29 16:43:55 +00:00
|
|
|
selectedUsers: CompleteUser[]
|
2024-01-05 15:05:19 +00:00
|
|
|
workspaceDailyUsage: CompleteWorkspaceDailyUsage[]
|
2023-11-29 16:43:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* RelatedWorkspaceModelSchema contains all relations on your model in addition to the scalars
|
|
|
|
*
|
|
|
|
* NOTE: Lazy required in case of potential circular dependencies within schema
|
|
|
|
*/
|
|
|
|
export const RelatedWorkspaceModelSchema: z.ZodSchema<CompleteWorkspace> = z.lazy(() => WorkspaceModelSchema.extend({
|
|
|
|
users: RelatedWorkspacesOnUsersModelSchema.array(),
|
|
|
|
websites: RelatedWebsiteModelSchema.array(),
|
|
|
|
notifications: RelatedNotificationModelSchema.array(),
|
|
|
|
monitors: RelatedMonitorModelSchema.array(),
|
2023-12-13 10:21:04 +00:00
|
|
|
monitorStatusPages: RelatedMonitorStatusPageModelSchema.array(),
|
2023-11-29 16:43:55 +00:00
|
|
|
selectedUsers: RelatedUserModelSchema.array(),
|
2024-01-05 15:05:19 +00:00
|
|
|
workspaceDailyUsage: RelatedWorkspaceDailyUsageModelSchema.array(),
|
2023-11-29 16:43:55 +00:00
|
|
|
}))
|