fix: Remove Number() conversions that corrupt uint64 IDs
JavaScript's Number type cannot accurately represent uint64 values exceeding Number.MAX_SAFE_INTEGER (2^53-1). Converting these IDs to numbers causes precision loss and API errors. Root cause found: - match/[id]/+layout.ts: `Number(params.id)` corrupted match IDs - player/[id]/+page.ts: `Number(params.id)` corrupted player IDs Example of the bug: - URL param: "3638078243082338615" (correct) - After Number(): 3638078243082339000 (rounded!) - API response: "Match 3638078243082339000 not found" Changes: - Remove Number() conversions in route loaders - Keep params.id as string throughout the application - Update API functions to only accept string (not string | number) - Update MatchesQueryParams.player_id type to string - Add comprehensive transformers for legacy API responses - Transform player stats: duo→mk_2, triple→mk_3, steamid64→id - Build full Steam avatar URLs - Make share_code optional (not always present) This ensures uint64 IDs maintain full precision from URL → API → response. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -23,7 +23,7 @@ export const apiResponseSchema = <T extends z.ZodTypeAny>(dataSchema: T) =>
|
||||
|
||||
/** MatchParseResponse schema */
|
||||
export const matchParseResponseSchema = z.object({
|
||||
match_id: z.number().positive(),
|
||||
match_id: z.string().min(1), // uint64 as string to preserve precision
|
||||
status: z.enum(['parsing', 'queued', 'completed', 'error']),
|
||||
message: z.string(),
|
||||
estimated_time: z.number().int().positive().optional()
|
||||
@@ -31,7 +31,7 @@ export const matchParseResponseSchema = z.object({
|
||||
|
||||
/** MatchParseStatus schema */
|
||||
export const matchParseStatusSchema = z.object({
|
||||
match_id: z.number().positive(),
|
||||
match_id: z.string().min(1), // uint64 as string to preserve precision
|
||||
status: z.enum(['pending', 'parsing', 'completed', 'error']),
|
||||
progress: z.number().int().min(0).max(100).optional(),
|
||||
error_message: z.string().optional()
|
||||
|
||||
Reference in New Issue
Block a user