69a0149bbe
Search: - migration 0009: trigram GIN index on brand.name + btree on country_of_origin - SearchProducts: typo-tolerant word_similarity matching (>=0.42) on top of ILIKE substring + barcode; new brand/country filters; rank by similarity * (0.5 + quality_score). Response gains country_of_origin, quality_score and per-result relevance score. - public search UI: brand/country filter inputs; show country in results Docs: - serve embedded OpenAPI 3 spec at GET /api/v1/openapi.json (not rate limited) - ApiDocs page: auth + rate-limit section, updated search params/response - docs/api.md developer guide Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
83 lines
1.9 KiB
TypeScript
83 lines
1.9 KiB
TypeScript
export interface ProductSummary {
|
|
id: string;
|
|
gtin: string | null;
|
|
name: string;
|
|
brand: string | null;
|
|
category_path: string | null;
|
|
country_of_origin?: string | null;
|
|
quality_score?: number;
|
|
score?: number | null;
|
|
}
|
|
|
|
export interface Barcode {
|
|
gtin: string;
|
|
gtin_type: string;
|
|
pack_level: string;
|
|
region: string | null;
|
|
is_primary: boolean;
|
|
}
|
|
|
|
export interface Product {
|
|
id: string;
|
|
gtin: string | null;
|
|
barcodes?: Barcode[] | null;
|
|
name: string;
|
|
brand: string | null;
|
|
category_path: string | null;
|
|
net_content_value: number | null;
|
|
net_content_unit: string | null;
|
|
country_of_origin: string | null;
|
|
quality_score: number;
|
|
nutriments?: Record<string, unknown> | null;
|
|
nutrition_basis?: string | null;
|
|
nutri_score?: string | null;
|
|
ingredients_text?: string | null;
|
|
allergens?: string[] | null;
|
|
additives?: string[] | null;
|
|
}
|
|
|
|
export interface Category {
|
|
id: string;
|
|
name_zh: string;
|
|
name_en: string | null;
|
|
path: string;
|
|
level: number;
|
|
}
|
|
|
|
export interface SubmissionImage {
|
|
url: string;
|
|
kind: string;
|
|
}
|
|
|
|
export interface SubmissionInput {
|
|
gtin?: string | null;
|
|
name: string;
|
|
brand_name?: string | null;
|
|
category_id?: string | null;
|
|
net_content_value?: number | null;
|
|
net_content_unit?: string | null;
|
|
country_of_origin?: string | null;
|
|
ingredients_text?: string | null;
|
|
nutriments?: Record<string, number> | null;
|
|
nutrition_basis?: string | null;
|
|
serving_size?: string | null;
|
|
nutri_score?: string | null;
|
|
images?: SubmissionImage[];
|
|
submitter_name?: string | null;
|
|
submitter_contact?: string | null;
|
|
note?: string | null;
|
|
}
|
|
|
|
export const NUTRIMENT_LABELS: Record<string, string> = {
|
|
energy_kcal: "能量 (kcal)",
|
|
energy_kj: "能量 (kJ)",
|
|
fat: "脂肪 (g)",
|
|
saturated_fat: "饱和脂肪 (g)",
|
|
carbohydrates: "碳水 (g)",
|
|
sugars: "糖 (g)",
|
|
proteins: "蛋白质 (g)",
|
|
salt: "盐 (g)",
|
|
sodium: "钠 (g)",
|
|
fiber: "膳食纤维 (g)",
|
|
};
|