d9f992ca9a
- Added structured warning system with `AdminAiWarning` type in backend and Flutter - Implemented detailed reason descriptors with `FlyerReasonDescriptor` for parse and match operations - Added `legacyWarnings` field to maintain backward compatibility - Enhanced AI trace service to collect and format warnings with item-level context - Updated flyer import services to include detailed reason descriptions in responses - Added Swedish diacritic preservation for cheese variants (Prästost, Herrgårdsost, Grevéost) - Implemented UTF-8 content validation for AI responses - Added new reason code definitions in `reason-codes.ts` - Updated Flutter UI to display structured warnings with severity indicators - Added error report generation and copy functionality in admin panel - Added comprehensive test coverage for new warning system and cheese normalization BREAKING CHANGE: AI trace warnings are now structured objects instead of simple strings
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
export type FlyerImportMatchVia = 'alias' | 'exact' | 'token' | 'none';
|
|
|
|
export type FlyerReasonDescriptor = {
|
|
code: string;
|
|
kind: 'parse' | 'match';
|
|
title: string;
|
|
message: string;
|
|
severity: 'info' | 'warning' | 'error';
|
|
location: string | null;
|
|
};
|
|
|
|
export type FlyerImportItem = {
|
|
flyerItemId: number | null;
|
|
rawName: string;
|
|
normalizedName: string;
|
|
brand: string | null;
|
|
category: string | null;
|
|
categoryId: number | null;
|
|
price: number | null;
|
|
priceUnit: string | null;
|
|
comparisonPrice: number | null;
|
|
comparisonUnit: string | null;
|
|
weight: string | null;
|
|
bundleWeight: string | null;
|
|
isBundle: boolean;
|
|
bundleItems: string[];
|
|
offerText: string | null;
|
|
isOffer: boolean;
|
|
offerLimitText: string | null;
|
|
parseConfidence: number;
|
|
parseReasons: string[];
|
|
parseReasonsDetailed: FlyerReasonDescriptor[];
|
|
matchedProductId: number | null;
|
|
matchedProductName: string | null;
|
|
matchedVia: FlyerImportMatchVia;
|
|
matchConfidence: number;
|
|
matchReasons: string[];
|
|
matchReasonsDetailed: FlyerReasonDescriptor[];
|
|
};
|
|
|
|
export type FlyerImportResponse = {
|
|
sessionId: number | null;
|
|
retailer: 'willys';
|
|
parserVersion: 'v1';
|
|
sourceAvailable: boolean;
|
|
sourceFileName: string | null;
|
|
sourceMimeType: string | null;
|
|
sourceFileSize: number | null;
|
|
items: FlyerImportItem[];
|
|
warnings: string[];
|
|
};
|