test: add common payload zod type and avoid ci problem

This commit is contained in:
moonrailgun 2024-02-10 01:45:18 +08:00
parent 97d55da454
commit 3d9921f16f
8 changed files with 14 additions and 8 deletions

View File

@ -54,7 +54,7 @@ export const websiteInfoSchema = z.object({
deletedAt: z.date().nullable(), deletedAt: z.date().nullable(),
}); });
export const monitorInfoWithNotificationIdSchema = MonitorModelSchema.and( export const monitorInfoWithNotificationIdSchema = MonitorModelSchema.merge(
z.object({ z.object({
notifications: z.array(z.object({ id: z.string() })), notifications: z.array(z.object({ id: z.string() })),
}) })

View File

@ -39,6 +39,7 @@ model Workspace {
/// [DashboardLayout] /// [DashboardLayout]
dashboardLayout Json? @db.Json dashboardLayout Json? @db.Json
/// [CommonPayload] /// [CommonPayload]
/// @zod.custom(imports.CommonPayloadSchema)
settings Json @default("{}") settings Json @default("{}")
createdAt DateTime @default(now()) @db.Timestamptz(6) createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @updatedAt @db.Timestamptz(6) updatedAt DateTime @updatedAt @db.Timestamptz(6)
@ -231,6 +232,7 @@ model TelemetryEvent {
urlPath String @db.VarChar(500) urlPath String @db.VarChar(500)
/// [CommonPayload] /// [CommonPayload]
/// @zod.custom(imports.CommonPayloadSchema)
payload Json? @db.Json // Other payload info get from query params, should be a object payload Json? @db.Json // Other payload info get from query params, should be a object
createdAt DateTime @default(now()) @db.Timestamptz(6) createdAt DateTime @default(now()) @db.Timestamptz(6)
@ -248,6 +250,7 @@ model Notification {
name String @db.VarChar(100) name String @db.VarChar(100)
type String @db.VarChar(100) type String @db.VarChar(100)
/// [CommonPayload] /// [CommonPayload]
/// @zod.custom(imports.CommonPayloadSchema)
payload Json @db.Json payload Json @db.Json
createdAt DateTime @default(now()) @db.Timestamptz(6) createdAt DateTime @default(now()) @db.Timestamptz(6)
@ -265,11 +268,11 @@ model Monitor {
type String @db.VarChar(100) type String @db.VarChar(100)
active Boolean @default(true) @db.Boolean active Boolean @default(true) @db.Boolean
interval Int @default(20) @db.Integer interval Int @default(20) @db.Integer
maxRetries Int @default(0) maxRetries Int @default(0) @db.Integer
// TODO // TODO
// maxRetry Int @default(0) @db.Integer
// retryInterval Int @default(0) @db.Integer // retryInterval Int @default(0) @db.Integer
/// [CommonPayload] /// [CommonPayload]
/// @zod.custom(imports.CommonPayloadSchema)
payload Json @db.Json payload Json @db.Json
createdAt DateTime @default(now()) @db.Timestamptz(6) createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @default(now()) @updatedAt @db.Timestamptz(6) updatedAt DateTime @default(now()) @updatedAt @db.Timestamptz(6)
@ -311,6 +314,7 @@ model MonitorStatus {
monitorId String @db.VarChar(30) monitorId String @db.VarChar(30)
statusName String @db.VarChar(50) statusName String @db.VarChar(50)
/// [CommonPayload] /// [CommonPayload]
/// @zod.custom(imports.CommonPayloadSchema)
payload Json @db.Json payload Json @db.Json
createdAt DateTime @default(now()) @db.Timestamptz(6) createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @updatedAt @db.Timestamptz(6) updatedAt DateTime @updatedAt @db.Timestamptz(6)

View File

@ -19,7 +19,7 @@ export const MonitorModelSchema = z.object({
/** /**
* [CommonPayload] * [CommonPayload]
*/ */
payload: jsonSchema, payload: imports.CommonPayloadSchema,
createdAt: z.date(), createdAt: z.date(),
updatedAt: z.date(), updatedAt: z.date(),
}) })

View File

@ -14,7 +14,7 @@ export const MonitorStatusModelSchema = z.object({
/** /**
* [CommonPayload] * [CommonPayload]
*/ */
payload: jsonSchema, payload: imports.CommonPayloadSchema,
createdAt: z.date(), createdAt: z.date(),
updatedAt: z.date(), updatedAt: z.date(),
}) })

View File

@ -16,7 +16,7 @@ export const NotificationModelSchema = z.object({
/** /**
* [CommonPayload] * [CommonPayload]
*/ */
payload: jsonSchema, payload: imports.CommonPayloadSchema,
createdAt: z.date(), createdAt: z.date(),
}) })

View File

@ -6,3 +6,5 @@ export const MonitorStatusPageListSchema = z.array(
showCurrent: z.boolean().default(false).optional(), showCurrent: z.boolean().default(false).optional(),
}) })
); );
export const CommonPayloadSchema = z.record(z.string(), z.any());

View File

@ -18,7 +18,7 @@ export const TelemetryEventModelSchema = z.object({
/** /**
* [CommonPayload] * [CommonPayload]
*/ */
payload: jsonSchema, payload: imports.CommonPayloadSchema,
createdAt: z.date(), createdAt: z.date(),
}) })

View File

@ -19,7 +19,7 @@ export const WorkspaceModelSchema = z.object({
/** /**
* [CommonPayload] * [CommonPayload]
*/ */
settings: jsonSchema, settings: imports.CommonPayloadSchema,
createdAt: z.date(), createdAt: z.date(),
updatedAt: z.date(), updatedAt: z.date(),
}) })