From 3d9921f16f463f5f39570d192f5aaf1c92050f24 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Sat, 10 Feb 2024 01:45:18 +0800 Subject: [PATCH] test: add common payload zod type and avoid ci problem --- src/server/model/_schema/index.ts | 2 +- src/server/prisma/schema.prisma | 8 ++++++-- src/server/prisma/zod/monitor.ts | 2 +- src/server/prisma/zod/monitorstatus.ts | 2 +- src/server/prisma/zod/notification.ts | 2 +- src/server/prisma/zod/schemas/index.ts | 2 ++ src/server/prisma/zod/telemetryevent.ts | 2 +- src/server/prisma/zod/workspace.ts | 2 +- 8 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/server/model/_schema/index.ts b/src/server/model/_schema/index.ts index ed8c12b..f6214e2 100644 --- a/src/server/model/_schema/index.ts +++ b/src/server/model/_schema/index.ts @@ -54,7 +54,7 @@ export const websiteInfoSchema = z.object({ deletedAt: z.date().nullable(), }); -export const monitorInfoWithNotificationIdSchema = MonitorModelSchema.and( +export const monitorInfoWithNotificationIdSchema = MonitorModelSchema.merge( z.object({ notifications: z.array(z.object({ id: z.string() })), }) diff --git a/src/server/prisma/schema.prisma b/src/server/prisma/schema.prisma index 98b2490..ef2352c 100644 --- a/src/server/prisma/schema.prisma +++ b/src/server/prisma/schema.prisma @@ -39,6 +39,7 @@ model Workspace { /// [DashboardLayout] dashboardLayout Json? @db.Json /// [CommonPayload] + /// @zod.custom(imports.CommonPayloadSchema) settings Json @default("{}") createdAt DateTime @default(now()) @db.Timestamptz(6) updatedAt DateTime @updatedAt @db.Timestamptz(6) @@ -231,6 +232,7 @@ model TelemetryEvent { urlPath String @db.VarChar(500) /// [CommonPayload] + /// @zod.custom(imports.CommonPayloadSchema) payload Json? @db.Json // Other payload info get from query params, should be a object createdAt DateTime @default(now()) @db.Timestamptz(6) @@ -248,6 +250,7 @@ model Notification { name String @db.VarChar(100) type String @db.VarChar(100) /// [CommonPayload] + /// @zod.custom(imports.CommonPayloadSchema) payload Json @db.Json createdAt DateTime @default(now()) @db.Timestamptz(6) @@ -265,11 +268,11 @@ model Monitor { type String @db.VarChar(100) active Boolean @default(true) @db.Boolean interval Int @default(20) @db.Integer - maxRetries Int @default(0) + maxRetries Int @default(0) @db.Integer // TODO - // maxRetry Int @default(0) @db.Integer // retryInterval Int @default(0) @db.Integer /// [CommonPayload] + /// @zod.custom(imports.CommonPayloadSchema) payload Json @db.Json createdAt DateTime @default(now()) @db.Timestamptz(6) updatedAt DateTime @default(now()) @updatedAt @db.Timestamptz(6) @@ -311,6 +314,7 @@ model MonitorStatus { monitorId String @db.VarChar(30) statusName String @db.VarChar(50) /// [CommonPayload] + /// @zod.custom(imports.CommonPayloadSchema) payload Json @db.Json createdAt DateTime @default(now()) @db.Timestamptz(6) updatedAt DateTime @updatedAt @db.Timestamptz(6) diff --git a/src/server/prisma/zod/monitor.ts b/src/server/prisma/zod/monitor.ts index a124db9..030eba3 100644 --- a/src/server/prisma/zod/monitor.ts +++ b/src/server/prisma/zod/monitor.ts @@ -19,7 +19,7 @@ export const MonitorModelSchema = z.object({ /** * [CommonPayload] */ - payload: jsonSchema, + payload: imports.CommonPayloadSchema, createdAt: z.date(), updatedAt: z.date(), }) diff --git a/src/server/prisma/zod/monitorstatus.ts b/src/server/prisma/zod/monitorstatus.ts index c5d9171..bb6393b 100644 --- a/src/server/prisma/zod/monitorstatus.ts +++ b/src/server/prisma/zod/monitorstatus.ts @@ -14,7 +14,7 @@ export const MonitorStatusModelSchema = z.object({ /** * [CommonPayload] */ - payload: jsonSchema, + payload: imports.CommonPayloadSchema, createdAt: z.date(), updatedAt: z.date(), }) diff --git a/src/server/prisma/zod/notification.ts b/src/server/prisma/zod/notification.ts index 6eadbbf..88de6e4 100644 --- a/src/server/prisma/zod/notification.ts +++ b/src/server/prisma/zod/notification.ts @@ -16,7 +16,7 @@ export const NotificationModelSchema = z.object({ /** * [CommonPayload] */ - payload: jsonSchema, + payload: imports.CommonPayloadSchema, createdAt: z.date(), }) diff --git a/src/server/prisma/zod/schemas/index.ts b/src/server/prisma/zod/schemas/index.ts index 4253045..8fea0c3 100644 --- a/src/server/prisma/zod/schemas/index.ts +++ b/src/server/prisma/zod/schemas/index.ts @@ -6,3 +6,5 @@ export const MonitorStatusPageListSchema = z.array( showCurrent: z.boolean().default(false).optional(), }) ); + +export const CommonPayloadSchema = z.record(z.string(), z.any()); diff --git a/src/server/prisma/zod/telemetryevent.ts b/src/server/prisma/zod/telemetryevent.ts index 1dfadf0..4aeb4f0 100644 --- a/src/server/prisma/zod/telemetryevent.ts +++ b/src/server/prisma/zod/telemetryevent.ts @@ -18,7 +18,7 @@ export const TelemetryEventModelSchema = z.object({ /** * [CommonPayload] */ - payload: jsonSchema, + payload: imports.CommonPayloadSchema, createdAt: z.date(), }) diff --git a/src/server/prisma/zod/workspace.ts b/src/server/prisma/zod/workspace.ts index 150755e..73662fe 100644 --- a/src/server/prisma/zod/workspace.ts +++ b/src/server/prisma/zod/workspace.ts @@ -19,7 +19,7 @@ export const WorkspaceModelSchema = z.object({ /** * [CommonPayload] */ - settings: jsonSchema, + settings: imports.CommonPayloadSchema, createdAt: z.date(), updatedAt: z.date(), })