From 44b58143c947a8e1335e4619c50946ce349292e8 Mon Sep 17 00:00:00 2001 From: mzaxd Date: Mon, 23 Feb 2026 17:39:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=85=A5=E5=BA=93=E6=8E=A5=E5=8F=A3=E6=A0=87=E7=AD=BE=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/api/webhook/projects/route.ts | 8 ++++---- src/lib/validations.ts | 8 +++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/app/api/webhook/projects/route.ts b/src/app/api/webhook/projects/route.ts index edaf6f3..1704546 100644 --- a/src/app/api/webhook/projects/route.ts +++ b/src/app/api/webhook/projects/route.ts @@ -4,9 +4,9 @@ import type { ProjectStatus, LinkType } from '@prisma/client' import { isValidApiKey } from '@/lib/auth' import { WebhookPayloadSchema, - ProjectInputSchema, + ProjectIngestionInputSchema, type WebhookPayload, - type ProjectInput, + type ProjectIngestionInput, } from '@/lib/validations' import { findExistingProject, @@ -67,7 +67,7 @@ export async function POST(request: NextRequest) { const projectData = payload.projects[i] // Validate individual project - const projectValidation = ProjectInputSchema.safeParse(projectData) + const projectValidation = ProjectIngestionInputSchema.safeParse(projectData) if (!projectValidation.success) { results.failed++ @@ -82,7 +82,7 @@ export async function POST(request: NextRequest) { } try { - const validProject = projectValidation.data as ProjectInput + const validProject = projectValidation.data as ProjectIngestionInput // 多级去重:查找已存在的项目 const existingProject = await findExistingProject(validProject) diff --git a/src/lib/validations.ts b/src/lib/validations.ts index eb6e90e..27ecb4c 100644 --- a/src/lib/validations.ts +++ b/src/lib/validations.ts @@ -53,6 +53,11 @@ export const ProjectInputSchema = ProjectBaseSchema.extend({ links: z.array(ExternalLinkSchema).min(1, "At least one link is required").max(10), }); +export const ProjectIngestionInputSchema = ProjectBaseSchema.extend({ + tags: z.array(TagSchema).min(1, "At least one tag is required"), + links: z.array(ExternalLinkSchema).min(1, "At least one link is required").max(10), +}); + // ================================ // Webhook Schemas // ================================ @@ -62,7 +67,7 @@ export const WebhookAuthSchema = z.object({ }); export const WebhookPayloadSchema = WebhookAuthSchema.extend({ - projects: z.array(ProjectInputSchema).min(1).max(100), + projects: z.array(ProjectIngestionInputSchema).min(1).max(100), }); // ================================ @@ -299,6 +304,7 @@ export const N8NChatJobResponseSchema = z.object({ export type ExternalLink = z.infer; export type Tag = z.infer; export type ProjectInput = z.infer; +export type ProjectIngestionInput = z.infer; export type WebhookPayload = z.infer; export type ProjectQuery = z.infer; export type TaskStatus = z.infer;