import type {ProductResponse, StatisticsRequest} from "@/types/lg"; const sortRecord = (obj?: Record | null): Record => { if (!obj) return {}; return Object.fromEntries( Object.keys(obj) .sort() .map((k) => [k, obj[k]]) ); }; const sortNumberArrayRecord = (obj?: Record | null): Record => { if (!obj) return {}; return Object.fromEntries( Object.keys(obj) .sort() .map((k) => [k, [...(obj[k] ?? [])].sort((a, b) => a - b)]) ); }; const normalizeReqForKey = (req: StatisticsRequest) => ({ variableIdMap: sortRecord(req.variableIdMap), bannerIdList: [...(req.bannerIdList ?? [])].sort(), filterCondition: sortNumberArrayRecord(req.filterCondition as any), // normalizeFilterCondition 결과면 Record option: req.option ?? null, }); export const productStatisticsKey = (req: StatisticsRequest) => ["statistics", "product", normalizeReqForKey(req)] as const; export const bannerStatisticsKey = (req: StatisticsRequest) => ["statistics", "banner", normalizeReqForKey(req)] as const;