Skip to content

Commit 0ebf80e

Browse files
committed
fix: 保留 auth_index 原值,避免丢弃历史/异构格式
1 parent 3c9acfa commit 0ebf80e

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

lib/usage.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,8 @@ const tokensSchema = z.object({
1313
const detailSchema = z.object({
1414
timestamp: z.string().optional(),
1515
source: z.string().optional(),
16-
// auth_index may arrive as non-numeric string; drop invalid values instead of failing parse
17-
auth_index: z
18-
.preprocess((value) => {
19-
if (value === undefined || value === null) return undefined;
20-
const num = Number(value);
21-
return Number.isNaN(num) ? undefined : num;
22-
}, z.number().optional()),
16+
// 保留 auth_index 原值(字符串或数字),避免历史/异构格式被丢弃
17+
auth_index: z.union([z.string(), z.number()]).optional(),
2318
tokens: tokensSchema.optional(),
2419
failed: z.boolean().optional(),
2520
// 兼容旧格式

0 commit comments

Comments
 (0)