fix: 移除项目入库接口标签数量限制
This commit is contained in:
@@ -4,9 +4,9 @@ import type { ProjectStatus, LinkType } from '@prisma/client'
|
|||||||
import { isValidApiKey } from '@/lib/auth'
|
import { isValidApiKey } from '@/lib/auth'
|
||||||
import {
|
import {
|
||||||
WebhookPayloadSchema,
|
WebhookPayloadSchema,
|
||||||
ProjectInputSchema,
|
ProjectIngestionInputSchema,
|
||||||
type WebhookPayload,
|
type WebhookPayload,
|
||||||
type ProjectInput,
|
type ProjectIngestionInput,
|
||||||
} from '@/lib/validations'
|
} from '@/lib/validations'
|
||||||
import {
|
import {
|
||||||
findExistingProject,
|
findExistingProject,
|
||||||
@@ -67,7 +67,7 @@ export async function POST(request: NextRequest) {
|
|||||||
const projectData = payload.projects[i]
|
const projectData = payload.projects[i]
|
||||||
|
|
||||||
// Validate individual project
|
// Validate individual project
|
||||||
const projectValidation = ProjectInputSchema.safeParse(projectData)
|
const projectValidation = ProjectIngestionInputSchema.safeParse(projectData)
|
||||||
|
|
||||||
if (!projectValidation.success) {
|
if (!projectValidation.success) {
|
||||||
results.failed++
|
results.failed++
|
||||||
@@ -82,7 +82,7 @@ export async function POST(request: NextRequest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const validProject = projectValidation.data as ProjectInput
|
const validProject = projectValidation.data as ProjectIngestionInput
|
||||||
|
|
||||||
// 多级去重:查找已存在的项目
|
// 多级去重:查找已存在的项目
|
||||||
const existingProject = await findExistingProject(validProject)
|
const existingProject = await findExistingProject(validProject)
|
||||||
|
|||||||
@@ -53,6 +53,11 @@ export const ProjectInputSchema = ProjectBaseSchema.extend({
|
|||||||
links: z.array(ExternalLinkSchema).min(1, "At least one link is required").max(10),
|
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
|
// Webhook Schemas
|
||||||
// ================================
|
// ================================
|
||||||
@@ -62,7 +67,7 @@ export const WebhookAuthSchema = z.object({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const WebhookPayloadSchema = WebhookAuthSchema.extend({
|
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<typeof ExternalLinkSchema>;
|
export type ExternalLink = z.infer<typeof ExternalLinkSchema>;
|
||||||
export type Tag = z.infer<typeof TagSchema>;
|
export type Tag = z.infer<typeof TagSchema>;
|
||||||
export type ProjectInput = z.infer<typeof ProjectInputSchema>;
|
export type ProjectInput = z.infer<typeof ProjectInputSchema>;
|
||||||
|
export type ProjectIngestionInput = z.infer<typeof ProjectIngestionInputSchema>;
|
||||||
export type WebhookPayload = z.infer<typeof WebhookPayloadSchema>;
|
export type WebhookPayload = z.infer<typeof WebhookPayloadSchema>;
|
||||||
export type ProjectQuery = z.infer<typeof ProjectQuerySchema>;
|
export type ProjectQuery = z.infer<typeof ProjectQuerySchema>;
|
||||||
export type TaskStatus = z.infer<typeof TaskStatusEnum>;
|
export type TaskStatus = z.infer<typeof TaskStatusEnum>;
|
||||||
|
|||||||
Reference in New Issue
Block a user