Files
gacha-event-tracker/src/shared/codes.ts
T
Lucas WintherandClaude Opus 5.5 b8e8d44816 feat(codes): mark a code dead once the owner confirms it in game
Game8 still lists Y1INABQB6DEX, 2BJ64QRZ7RT8 and PLDXIB886Y1S as active
Genshin codes after the game refused them. CODE_CHECKS records the
owner's in-game check; build-codes stamps the matching code confirmedDead,
and the Codes tab shows it expired: "Confirmed expired in game, 2026-10-20."

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 03:34:52 +02:00

34 lines
1.0 KiB
TypeScript

import { z } from "zod";
import { GameId } from "./schema.ts";
import { SourceHealth } from "./feed.ts";
export const RedeemCodeSchema = z.object({
id: z.string(),
game: GameId,
code: z.string().min(1).max(100),
reward: z.string().max(1000).nullable(),
expiresAt: z.string().datetime().nullable(),
expiresOn: z
.string()
.regex(/^\d{4}-\d{2}-\d{2}$/)
.nullable()
.optional(),
/**
* The day the repository owner tried the code in game and it no longer
* worked (`codeChecks.ts`). Only ever "dead": the source still supplies the
* code, its reward and its link.
*/
confirmedDead: z
.string()
.regex(/^\d{4}-\d{2}-\d{2}$/)
.optional(),
firstObservedAt: z.string().datetime(),
sourceUrl: z.string().url(),
});
export type RedeemCode = z.infer<typeof RedeemCodeSchema>;
export const CodesFeedSchema = z.object({
schemaVersion: z.literal(1),
codes: z.array(RedeemCodeSchema),
sources: z.array(SourceHealth),
});
export type CodesFeed = z.infer<typeof CodesFeedSchema>;