feat: 补充报告评论集合与评论详情证据
This commit is contained in:
@@ -40,10 +40,59 @@ export const EvidenceSchema = z.object({
|
||||
source_type: z.enum(evidenceSourceTypes),
|
||||
source_url: z.string().url(),
|
||||
review_ref: z.string().nullable(),
|
||||
review_detail: z
|
||||
.object({
|
||||
content: z.string().min(1),
|
||||
score: z.string().nullable(),
|
||||
created_at: z.string().nullable(),
|
||||
author_label: z.string().nullable(),
|
||||
sku_labels: z.array(z.string().min(1)).optional(),
|
||||
like_count: z.string().nullable().optional(),
|
||||
reply: z.string().nullable().optional(),
|
||||
append_content: z.string().nullable().optional(),
|
||||
picture_urls: z.array(z.string().min(1)).optional(),
|
||||
video_urls: z.array(z.string().min(1)).optional(),
|
||||
append_picture_urls: z.array(z.string().min(1)).optional()
|
||||
})
|
||||
.optional(),
|
||||
snippet: z.string().min(1),
|
||||
captured_at: z.string().datetime()
|
||||
});
|
||||
|
||||
const ReviewDetailSchema = z.object({
|
||||
content: z.string().min(1),
|
||||
score: z.string().nullable(),
|
||||
created_at: z.string().nullable(),
|
||||
author_label: z.string().nullable(),
|
||||
sku_labels: z.array(z.string().min(1)).optional(),
|
||||
like_count: z.string().nullable().optional(),
|
||||
reply: z.string().nullable().optional(),
|
||||
append_content: z.string().nullable().optional(),
|
||||
picture_urls: z.array(z.string().min(1)).optional(),
|
||||
video_urls: z.array(z.string().min(1)).optional(),
|
||||
append_picture_urls: z.array(z.string().min(1)).optional()
|
||||
});
|
||||
|
||||
const ReviewCollectionCommentSchema = ReviewDetailSchema.extend({
|
||||
review_ref: z.string().min(1),
|
||||
sample_bucket: z.enum(["latest", "hot", "negative"]).nullable().optional()
|
||||
});
|
||||
|
||||
const ReviewCollectionSchema = z.object({
|
||||
collection_id: z.string().min(1),
|
||||
candidate_id: z.string().min(1),
|
||||
product_evidence_id: z.string().min(1),
|
||||
platform: z.enum(platforms),
|
||||
source_url: z.string().url(),
|
||||
title: z.string().min(1),
|
||||
store_name: z.string().nullable(),
|
||||
price_label: z.string().nullable(),
|
||||
captured_at: z.string().datetime(),
|
||||
review_count: z.number().int().nonnegative(),
|
||||
sampled_review_refs: z.array(z.string().min(1)),
|
||||
comments: z.array(ReviewCollectionCommentSchema)
|
||||
});
|
||||
|
||||
export const PlatformInsightSchema = z.object({
|
||||
platform: z.enum(platforms),
|
||||
execution_status: z.enum(executionStatuses),
|
||||
@@ -86,6 +135,7 @@ export const ReportSchema = z.object({
|
||||
cross_platform_insights: z.array(InsightCardSchema),
|
||||
recommendations: z.array(InsightCardSchema),
|
||||
evidence_index: z.array(EvidenceSchema),
|
||||
review_collections: z.array(ReviewCollectionSchema).optional(),
|
||||
quality_flags: z.object({
|
||||
sample_insufficient: z.boolean(),
|
||||
partial_platform_failure: z.boolean(),
|
||||
|
||||
@@ -101,6 +101,75 @@ describe("ReportSchema", () => {
|
||||
review_ref: null,
|
||||
snippet: "详情页强调 5 倍长焦与钛金属材质。",
|
||||
captured_at: "2026-04-02T11:58:00.000Z"
|
||||
},
|
||||
{
|
||||
evidence_id: "evidence-2",
|
||||
platform: "tmall",
|
||||
source_type: "review",
|
||||
source_url: "https://example.com/tmall/iphone-15-pro",
|
||||
review_ref: "comment-1",
|
||||
review_detail: {
|
||||
content: "拍照效果稳定,夜景比预期更干净。",
|
||||
score: "5",
|
||||
created_at: "2026-04-02",
|
||||
author_label: "88VIP",
|
||||
sku_labels: ["远峰蓝 / 256G"],
|
||||
like_count: "12",
|
||||
reply: "感谢支持",
|
||||
append_content: "追评:一周后续航依然稳定。",
|
||||
picture_urls: ["https://example.com/review/pic-1.jpg"],
|
||||
video_urls: [],
|
||||
append_picture_urls: []
|
||||
},
|
||||
snippet: "样本 latest | 评分 5 | 88VIP | 拍照效果稳定,夜景更干净。",
|
||||
captured_at: "2026-04-02T11:59:00.000Z"
|
||||
}
|
||||
],
|
||||
review_collections: [
|
||||
{
|
||||
collection_id: "review-collection-candidate-1",
|
||||
candidate_id: "candidate-1",
|
||||
product_evidence_id: "evidence-1",
|
||||
platform: "tmall",
|
||||
source_url: "https://example.com/tmall/iphone-15-pro",
|
||||
title: "iPhone 15 Pro",
|
||||
store_name: "Apple 官方旗舰店",
|
||||
price_label: "¥7999",
|
||||
captured_at: "2026-04-02T11:59:00.000Z",
|
||||
review_count: 2,
|
||||
sampled_review_refs: ["comment-1"],
|
||||
comments: [
|
||||
{
|
||||
review_ref: "comment-1",
|
||||
sample_bucket: "latest",
|
||||
content: "拍照效果稳定,夜景比预期更干净。",
|
||||
score: "5",
|
||||
created_at: "2026-04-02",
|
||||
author_label: "88VIP",
|
||||
sku_labels: ["远峰蓝 / 256G"],
|
||||
like_count: "12",
|
||||
reply: "感谢支持",
|
||||
append_content: "追评:一周后续航依然稳定。",
|
||||
picture_urls: ["https://example.com/review/pic-1.jpg"],
|
||||
video_urls: [],
|
||||
append_picture_urls: []
|
||||
},
|
||||
{
|
||||
review_ref: "comment-2",
|
||||
sample_bucket: null,
|
||||
content: "手感不错,续航也正常。",
|
||||
score: "4",
|
||||
created_at: "2026-04-01",
|
||||
author_label: null,
|
||||
sku_labels: [],
|
||||
like_count: null,
|
||||
reply: null,
|
||||
append_content: null,
|
||||
picture_urls: [],
|
||||
video_urls: [],
|
||||
append_picture_urls: []
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
quality_flags: {
|
||||
@@ -113,6 +182,7 @@ describe("ReportSchema", () => {
|
||||
|
||||
expect(report.report_version).toBe(1);
|
||||
expect(report.platform_insights).toHaveLength(2);
|
||||
expect(report.review_collections).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("rejects a strong insight without evidence ids", () => {
|
||||
|
||||
Reference in New Issue
Block a user