补2025产品候选并核对成立年与Trace主体

This commit is contained in:
2026-10-30 15:21:28 +08:00
parent dca7c81889
commit 79a6a8dbd7
9 changed files with 699 additions and 75 deletions
+6 -4
View File
@@ -48,8 +48,8 @@ export type ResearchCandidateBatch = {
records: {
id: string; name: string; url: string | null; categoryId: string;
kind: "product" | "promotion"; profileStatus: "readable" | "unavailable" | "archive-only";
status: "pending-year" | "linked" | "existing-outside-cohort" | "promotion";
companyId?: string; note: string;
status: "pending-year" | "linked" | "existing-outside-cohort" | "outside-cohort" | "promotion";
companyId?: string; evidenceIds?: string[]; note: string;
}[];
};
export type ResearchSnapshot = {
@@ -121,11 +121,13 @@ export function validateResearch(snapshot: ResearchSnapshot) {
if (!row.name.trim() || !row.note.trim() || !categories.has(row.categoryId) ||
!["product", "promotion"].includes(row.kind) ||
!["readable", "unavailable", "archive-only"].includes(row.profileStatus) ||
!["pending-year", "linked", "existing-outside-cohort", "promotion"].includes(row.status) ||
!["pending-year", "linked", "existing-outside-cohort", "outside-cohort", "promotion"].includes(row.status) ||
(row.kind === "product" && (!row.url || !evidenceUrl(row.url))) ||
(row.url !== null && !evidenceUrl(row.url)) ||
linked !== !!row.companyId || (row.companyId && !companies.has(row.companyId)) ||
(row.kind === "promotion") !== (row.status === "promotion"))
(row.kind === "promotion") !== (row.status === "promotion") ||
(row.evidenceIds ?? []).some((id) => !evidence.has(id)) ||
(row.status === "outside-cohort" && !row.evidenceIds?.length))
throw new Error(`Invalid research candidate: ${row.id}`);
}
}