feat: add Nikke, the third Fandom template

Its robots.txt was read in a browser and is the standard Fandom file: no
Disallow: / for *, /api.php?action= explicitly allowed, and only the namespaces
we never want refused. The AI crawlers it blocks by name are not us. That was
the one thing missing — the API itself has always answered our own User-Agent
with a 200, and it is only robots.txt that a datacentre address cannot read.

The zone lives in the column header, Start(UTC+9) / End(UTC+9), and no date in
any cell carries an offset. So the header is the safety property: a table that
stops naming its zone is refused rather than read as UTC, which is the Blue
Archive hazard arriving one column to the left.

Two shapes worth knowing. Every title is an image read from <a title>, and the
newest row is the one whose logo has not been uploaded yet — it renders as a
red link reading "File:Persona on Frontline logo.png", so a reader that only
understood the link title would silently drop today's live event. And story
events state a clock only on the end, so the start keeps the day the page
printed rather than being shifted nine hours into the previous one; the start's
day is half an event ID. That is the FGO rule applied to the opposite gap.

resetOffsets and resetHourLocal ship with the game because the page evidences
both: events end 04:59:59 and the banner replacing them starts 05:00:00, one
second later, on a stated UTC+9. Adding that later would re-label day keys
readers had already logged ticks under.

Seconds now survive the date helpers, since rounding 04:59:59 to the minute
would make an event overlap the banner that succeeds it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
Lucas Winther
2026-08-19 04:11:03 +02:00
co-authored by Claude Opus 5
parent c9e9359808
commit bd385855c0
12 changed files with 533 additions and 31 deletions
+55 -22
View File
@@ -37,8 +37,8 @@ A web app that aggregates live and upcoming events across popular gacha games, p
calendar, sorts them by end date or by what the reader is partway through, tracks day-by-day
progress on events that repeat daily, and lets a user mark events completed.
**Status: working app, refreshing itself on a schedule.** Schema, eight parsers, eighteen sources across
seventeen games, the full interface, offline support, a static server, a Docker image and CI all exist and
**Status: working app, refreshing itself on a schedule.** Schema, eight parsers, nineteen sources across
eighteen games, the full interface, offline support, a static server, a Docker image and CI all exist and
are tested. The refresh runner (`bun run refresh`) fetches, caches raw snapshots and rebuilds the
feed; `.github/workflows/refresh.yml` runs it twice a day and commits only when a page actually
changed. The SQLite layer and the review queue are still specified in `docs/` but not built, so the
@@ -106,7 +106,7 @@ re-verify a sample against the live page afterward.
```
src/shared/ schema.ts (the contract), time.ts, daily.ts, effort.ts, games.ts, feed.ts
custom.ts — reader-authored games and events, and their key spaces
src/ingest/ html.ts, dates.ts (fourteen formats), merge.ts, sanitize.ts, robots.ts, snapshots.ts
src/ingest/ html.ts, dates.ts (fifteen formats), merge.ts, sanitize.ts, robots.ts, snapshots.ts
parsers/ game8.ts, wikigg.ts, akwiki.ts, fandom.ts, bawiki.ts, holodori.ts, iopwiki.ts,
stellasora.ts — keyed by SITE, not game
adapters/ index.ts — SOURCES registry binding url+game+parser, and the sanitize seam
@@ -119,7 +119,7 @@ src/client/ React app, service worker, manifest
theme.ts — dark or light, and what a game hue reads as on each
scripts/ build-feed.ts, build-static.ts, parse-fixture.ts (offline), refresh-sources.ts (fetches)
serve.ts static server + /api/health
test/ 686 tests
test/ 700 tests
fixtures/<game>/ raw HTML + .expected.json per source — pinned, kept forever
snapshots/ current page per source, rewritten by refresh — see its README
```
@@ -301,7 +301,7 @@ re-litigated each pass:
| `stellasora.miraheze.org` | **Built** (2026-08-19), from the front page's `Current Banners` module and **not** `/wiki/Banner_List` — see § Stella Sora below |
| `game8.co/games/Chaos-Zero-Nightmare` | **Built** (2026-08-19). Zero parser work — the existing `game8` parser reads it. The ninth game8 source, so fixture-backed in CI from day one |
| `game8.co/games/Umamusume-Pretty-Derby` | **Built** (2026-08-19), off the stable `List of All Banners` page, not the monthly release-schedule pages whose URL changes every month. Cost a widening of `game8.ts`'s section and column vocabulary — see § Working on parsers |
| `nikke-…-international.fandom.com` | **Blocked, not declined** (2026-08-19). The API answers our User-Agent with a 200 and the data is the best of any unbuilt source — story events *and* dated pickup banners, with an evidenced 05:00 UTC+9 reset. But this wiki's `robots.txt` cannot be read from here **at all**: 403 to our fetcher and an unresolving Cloudflare challenge to a real browser. The permission has to be in writing before the adapter exists, so this waits on someone reading that file from an address Fandom serves |
| `nikke-…-international.fandom.com` | **Built** (2026-08-19), via `api.php` like Reverse: 1999 and FGO. Its `robots.txt` was read in a browser and is the standard Fandom file — see § Fandom below. Richest schedule of anything added in this pass: story events *and* dated pickup banners, with the reset clock evidenced on the page |
| `infinitynikki.miraheze.org` | **Declined.** Exists and serves `robots.txt`, but the wiki is abandoned — front page last edited 11 February 2025 and `/wiki/Events` returns a permission error. Checked as a replacement for the stale Infinity Nikki Game8 page |
| `prydwen.gg/infinity-nikki` | **Declined.** 404 — prydwen does not cover Infinity Nikki |
| `grayravens.com` (Punishing: Gray Raven) | **Declined.** Conduct is fine; the data is not. The whole 626 KB `/wiki/Events` page contains exactly one date range, written as prose, one event per six-week patch |
@@ -309,22 +309,27 @@ re-litigated each pass:
| `blhx.fandom.com`, `azurlane-archive.fandom.com` | **Declined.** The two Fandom alternatives to the declined koumakan wiki are dead archives — `Event_Calendar` stops in **2021**, and the archive wiki's headings have nothing under them. Azur Lane still has no source |
| Aether Gazer | **Do not build.** The developer confirmed no further content updates after 23 July 2026, with store listings removed 17 October 2026. The wiki dates nothing anyway — `Event_Guide_List` is an image gallery. A lane that will be empty by winter |
**The Infinity Nikki lane is knowingly stale, and there is nowhere to move it** (checked
2026-08-19). `game8.co/games/Infinity-Nikki/archives/487445` fetches, parses and passes every test —
and its page says `Last updated on: August 31, 2025`. It mentions the year 2026 zero times. Seven
events parse out of it, of which **five carry `endsAt: null`** and so read as live-with-unknown-end
forever, on a calendar whose whole purpose is telling a reader what is still on. That is worse than
an empty lane, and it is the failure this product exists to prevent — arriving through a source that
looks perfectly healthy to the runner, because a stale page is not a broken one.
**The Infinity Nikki lane is knowingly stale, and the fix is a decision rather than a search**
(checked 2026-08-19). `game8.co/games/Infinity-Nikki/archives/487445` fetches, parses and passes
every test — and its page says `Last updated on: August 31, 2025`. It mentions the year 2026 zero
times. Seven events parse out of it, of which **five carry `endsAt: null`** and so read as
live-with-unknown-end forever, on a calendar whose whole purpose is telling a reader what is still
on. That is worse than an empty lane, and it arrives through a source that looks perfectly healthy
to the runner, because a stale page is not a broken one.
Every replacement was checked and none works: `infinitynikki.wiki.gg` 401s (no such wiki),
`prydwen.gg` does not cover the game, `infinitynikki.miraheze.org` is abandoned (front page last
edited February 2025, `/wiki/Events` a permission error), Game8's own `Banners` page for the game is
staler still (May 2025) and its whole Infinity Nikki wiki is unmaintained, and the Fandom wiki is
behind the blanket 403 above. **This is a decision for the repository owner, not a bug to fix in
code**: either the lane stays and the footer's freshness disclosure carries it, or the game is
retired. Retiring it is not free — `nikki` is the first segment of every completion key that game's
readers have, so dropping the `GameId` orphans them with no server-side recovery (§ Event IDs).
A live replacement exists: `infinity-nikki.fandom.com` (the canonical host; the unhyphenated name
301s to it) is maintained, permitted by the same standard Fandom `robots.txt` as Nikke, and its
`Event` page carries `Current Events` / `Upcoming Events` tables of
`Event | Duration | Description | Type` with full dates and clocks on both sides. **What it does not
carry is a timezone on that column** — only prose elsewhere dating version launches `(UTC-7)` and a
note that rewards reset at `04:00 (Server Time)`. The durations run `04:00 → 03:59`, which only
lands on a reset boundary if the column is server-local, so the case for UTC-7 is strong and
circumstantial. It matters because the offset moves the *day*, and the start's day is half an event
ID. `docs/SOURCES.md` § 11 lays out the four options and recommends taking the printed date at day
precision, which invents nothing and treats these cells exactly as every Game8 date is already
treated — and which conflicts with § Blue Archive as written, so that rule needs narrowing if it is
chosen. **Not to be decided by an agent**: retiring the game instead would drop a `GameId` that
prefixes every completion key its readers hold, with no server-side recovery.
`.github/ISSUE_TEMPLATE/feature_request.yml` points readers at that table by heading, so a source
request can be checked against it before anyone writes it up — the loudest feedback on the first
@@ -361,8 +366,19 @@ Two consequences, and neither is a licence to work around it:
- The two built Fandom sources now report `skipped_robots` on **every** run, from any address we
have, so `r1999` and `fgo` are permanently fixture-backed until someone refreshes them from an
address Fandom serves. `fgo` has never had a snapshot at all.
- A **new** Fandom source cannot be added at all, because the permission cannot be read. That is
what blocks Nikke, whose data is otherwise the best of any unbuilt source.
- A **new** Fandom source can still be added, but only once someone reads that wiki's `robots.txt`
from an address Fandom serves and records it here. That is exactly how Nikke was cleared on
2026-08-19: the file was read in a browser, is the standard Fandom file — no `Disallow: /` for
`*`, `/api.php?action=` explicitly allowed, only `Special:`, `User:`, `User_talk:`, `Template:`,
`Template_talk:`, `Help:` and `UserProfile:` refused — and the named AI crawlers it blocks
(`GPTBot`, `CCBot`, `OAI-SearchBot`, `ImagesiftBot`) are not us.
**The 403 is on `robots.txt`, not on the API.** Worth separating, because it decides what is
possible: `api.php?action=parse` answers our own User-Agent with a `200` from here, on all three
Fandom wikis we read. Only the robots file is challenged. So an adapter can be *written and
fixture-backed* from any address; what it cannot do is pass the robots gate at refresh time, which
fails closed and skips. The permission is therefore a thing a human records once, and the freshness
is a thing that needs an address Fandom serves.
One consequence to keep in mind: because `/robots.txt` is unreadable from a challenged address, the
robots gate **fails closed there and the source is skipped**. That is a warning line rather than a
@@ -371,6 +387,23 @@ broken build — `skipped_robots` does not touch the failure streak, and the run
falls back to the checked-in fixture. Refreshing it means running `bun run refresh` from an address
Fandom serves, which is how its first snapshot was taken.
**Three Fandom templates now, and the third states its zone in a column header.** The Nikke wiki's
`Event` page is `Event | Start(UTC+9) | End(UTC+9) | Archived(?)` for story events and
`Nikke | Start(UTC+9) | End(UTC+9)` for pickup banners. That header is the safety property, not a
convenience: no date in any cell carries an offset, so a table whose Start/End columns stop naming a
zone must be **refused** rather than read as UTC — the Blue Archive hazard, arriving one column to
the left, and `canParse` asserts the lookup. Two more things about it:
- **Every title is an image, and the newest row is the one without one.** Names come from the
wrapping `<a title="Project Matis">`, but an event whose logo has not been uploaded yet renders as
a red link reading `File:Persona on Frontline logo.png` — so a reader that only understood
`<a title>` would silently drop *today's live event* and publish a calendar missing what is on
now. The file name is the fallback, and a test pins that exact row.
- **A start with no clock keeps the day the page printed.** Story events state a bare date on the
start and a clock on the end; converting the bare one from UTC+9 would move it to the previous
calendar day, and the start's day is half an event ID. That is the Fate/Grand Order rule below,
applied to the opposite gap — there, a zone with no clock; here, a clock on only one side.
**Two Fandom sources now, and the second one's page is chosen, not obvious.**
`fategrandorder.fandom.com` publishes two schedules: `Event_List` opens "This page lists all Events
in Fate/Grand Order Japan", and `Event_List_(US)` is the English server. They run months apart, each
+12 -1
View File
@@ -10,7 +10,7 @@ import { z } from "zod";
export const GameId = z.enum([
"genshin", "hsr", "zzz", "wuwa", "arknights", "endfield", "nte", "nikki", "p5x", "r1999",
"ba", "fgo", "holodori", "gfl2", "stellasora", "czn", "uma",
"ba", "fgo", "holodori", "gfl2", "stellasora", "czn", "uma", "nikke",
]);
export const EventType = z.enum([
@@ -308,6 +308,17 @@ nothing to add, which is the point worth carrying to the next game: an override
the game moves nobody, while the same override added a year later re-labels every tick already
logged under the old clock. Get it right at introduction or accept a migration.
Nikke is the third game to earn one from the source rather than from habit, after Arknights and
Reverse: 1999, and it earns `resetHourLocal` too: every schedule column on its wiki is headed
`Start(UTC+9)` / `End(UTC+9)`, and the rows show where the day turns — a story event ends at
04:59:59 and the pickup banner replacing it starts at 05:00:00, one second later. So UTC+9 for every
region, rolling at 05:00 rather than 04:00. It shipped in the same commit as the game, which costs
nothing while no reader has a day key for it.
Note also that `nikke` and `nikki` are one letter apart and are different games — Goddess of Victory:
Nikke and Infinity Nikki. Both are the first segment of every completion key their game will ever
have, so a typo in either direction is silent data loss for real readers.
Infinity Nikki, P5X, Blue Archive, Chaos Zero Nightmare and Umamusume carry **no `resetOffsets`
entry**, so they take the regional default. That is an assumption, not a verified server map — none
of those sources states one. Two of the 2026-08-19 additions are worth separating out, because they
+2 -1
View File
@@ -51,7 +51,7 @@ Consequences worth internalising:
| `game8` | game8.co article calendars | Genshin, Star Rail, Wuthering Waves, ZZZ, Endfield, NTE, Infinity Nikki, Persona 5: The Phantom X, Chaos Zero Nightmare, Umamusume |
| `wikigg` | wiki.gg MediaWiki `mp-event` templates | Endfield |
| `akwiki` | arknights.wiki.gg's `mrfz-wtable` "Ongoing/upcoming" table | Arknights |
| `fandom` | Fandom wikis via the MediaWiki `action=parse` API — two page templates: `Event \| Time Period \| Version` wikitables, and FGO's picture-fenced `ONGOING EVENTS` blocks | Reverse: 1999, Fate/Grand Order |
| `fandom` | Fandom wikis via the MediaWiki `action=parse` API — three page templates: `Event \| Time Period \| Version` wikitables, FGO's picture-fenced `ONGOING EVENTS` blocks, and Nikke's `Event \| Start(UTC+9) \| End(UTC+9)` tables | Reverse: 1999, Fate/Grand Order, Nikke |
| `bawiki` | bluearchive.wiki's rendered `/wiki/Events` — a JP/Global tabber over `Name (EN) \| Start date \| End date \| Notes` wikitables | Blue Archive |
| `holodoriwiki` | holodori.wiki's rendered `/wiki/Events``Current Events` and `Past Events` wikitables over `Event \| Type \| Start Date \| End Date` | hololive Dreams |
| `iopwiki` | iopwiki.com's `gf-table event-period` tables — `Title \| Period (start/end) \| Server \| Type \| Comment`, one table per event and one row per server | Girls' Frontline 2 |
@@ -144,6 +144,7 @@ All live in `src/ingest/dates.ts`, each returning null rather than inferring any
| `parseSlashClockZone` | `08/17/2026 8:00PM (JST)` (one boundary per column, 12-hour clock, **named** zone) | hololive Dreams |
| `parseIsoClockRangeUtc` | `2026-08-06 13:00 - 2026-08-26 22:59 (UTC)` (whole range in one cell, **zone required**, nothing converted) | Girls' Frontline 2 |
| `parseIsoOffsetInstant` | `2026-08-03T21:00-07:00` (a machine-readable `<time datetime>` attribute; **offset required**) | Stella Sora |
| `parseDayMonthYearClock` | `12 August 2026`, `10 September 202604:59:59` (day-first; the offset comes from the **column header**, and a clockless boundary keeps its printed day) | Nikke |
| `parseOpenRange` | `Jul. 24, 2026 - End of 4.6`, `July 10, 2026 - Permanent` | Star Rail, Wuthering Waves |
**A day-precision result is 00:00Z, and that is a placeholder rather than a time.** Every reader
+2 -2
View File
@@ -59,7 +59,7 @@ have a source — this table is the launch scope, not a roster to keep in sync.
Adding a game must require no change to `GachaEvent` — only a `GameId` entry, its `games.ts`
metadata, and a source registration. That is the test of whether the data model is right, and it has
held: the seventeen games here have cost the event schema nothing. Per-game *metadata* does occasionally
held: the eighteen games here have cost the event schema nothing. Per-game *metadata* does occasionally
grow (Reverse: 1999 needed `resetHourLocal` for a 05:00 reset), which is a different file and moves
no stored key. A game may have several sources; see `docs/INGESTION.md` § Three layers.
@@ -90,7 +90,7 @@ default `"game"` — the board every existing reader already has). Merged, the o
`endingSoonestFirst`, the same comparator behind the list's "Ending soonest" (F2), so the two views
cannot mean different things by the same words and an unannounced end still sorts behind every dated
one rather than claiming a place in the queue. Merged there is also no lane heading to say whose
event a bar is, and hue alone cannot answer that once seventeen games share a stack — so each bar
event a bar is, and hue alone cannot answer that once eighteen games share a stack — so each bar
carries its game's short name, with the full name in its tooltip. A bar too narrow for a tag and a
title both keeps the title: a chopped game name reads as a broken word, and the hue and the tooltip
still answer it.
@@ -0,0 +1,65 @@
[
{
"id": "nikke:maxwell-ordinary-mechanic:2026-07-29",
"game": "nikke",
"title": "Maxwell: Ordinary Mechanic",
"type": "banner",
"summary": null,
"startsAt": "2026-07-29T20:00:00.000Z",
"startPrecision": "exact",
"endsAt": "2026-08-19T19:59:59.000Z",
"endPrecision": "exact",
"regionScoped": false,
"regionEnds": null,
"sourceUrl": "https://nikke-goddess-of-victory-international.fandom.com/wiki/Maxwell:_Ordinary_Mechanic",
"sourceId": "nikke-fandom-events",
"status": "published",
"confidence": 0.95,
"extractionMethod": "parser",
"version": 1,
"firstSeenAt": "2026-08-14T00:00:00.000Z",
"updatedAt": "2026-08-14T00:00:00.000Z"
},
{
"id": "nikke:persona-on-frontline:2026-08-12",
"game": "nikke",
"title": "Persona on Frontline",
"type": "other",
"summary": null,
"startsAt": "2026-08-12T00:00:00.000Z",
"startPrecision": "day",
"endsAt": "2026-09-09T19:59:59.000Z",
"endPrecision": "exact",
"regionScoped": false,
"regionEnds": null,
"sourceUrl": "https://nikke-goddess-of-victory-international.fandom.com/api.php?action=parse&page=Event&prop=text&formatversion=2&format=json",
"sourceId": "nikke-fandom-events",
"status": "published",
"confidence": 0.9,
"extractionMethod": "parser",
"version": 1,
"firstSeenAt": "2026-08-14T00:00:00.000Z",
"updatedAt": "2026-08-14T00:00:00.000Z"
},
{
"id": "nikke:queen-makoto:2026-08-12",
"game": "nikke",
"title": "Queen (Makoto)",
"type": "banner",
"summary": null,
"startsAt": "2026-08-12T00:00:00.000Z",
"startPrecision": "day",
"endsAt": "2026-09-10T14:59:59.000Z",
"endPrecision": "exact",
"regionScoped": false,
"regionEnds": null,
"sourceUrl": "https://nikke-goddess-of-victory-international.fandom.com/wiki/Queen_(Makoto)",
"sourceId": "nikke-fandom-events",
"status": "published",
"confidence": 0.9,
"extractionMethod": "parser",
"version": 1,
"firstSeenAt": "2026-08-14T00:00:00.000Z",
"updatedAt": "2026-08-14T00:00:00.000Z"
}
]
File diff suppressed because one or more lines are too long
+16
View File
@@ -143,6 +143,22 @@ const SOURCES: SourceSpec[] = [
url: "https://stellasora.miraheze.org/wiki/Main_Page",
parserId: "stellasorawiki",
},
{
id: "nikke-fandom-events",
game: "nikke",
// The MediaWiki API, like the two Fandom sources above. This wiki's
// robots.txt was read in a browser on 2026-08-19 and is the standard Fandom
// file: no `Disallow: /` for `*`, `/api.php?action=` explicitly allowed,
// and only `Special:`, `User:`, `User_talk:`, `Template:`, `Template_talk:`,
// `Help:` and `UserProfile:` refused. The named AI crawlers it blocks
// (GPTBot, CCBot, OAI-SearchBot, ImagesiftBot) are not us.
//
// As with r1999 and fgo, the robots gate still fails closed from a
// datacentre address, so the scheduled refresh reports skipped_robots and
// this lane is fixture-backed until refreshed from an address Fandom serves.
url: "https://nikke-goddess-of-victory-international.fandom.com/api.php?action=parse&page=Event&prop=text&formatversion=2&format=json",
parserId: "fandom",
},
{
id: "czn-game8-events",
game: "czn",
+58 -3
View File
@@ -34,9 +34,12 @@ function iso(
d: number,
hh = 0,
mm = 0,
ss = 0,
): string | null {
if (m < 1 || m > 12 || d < 1 || d > 31 || hh > 23 || mm > 59) return null;
const date = new Date(Date.UTC(y, m - 1, d, hh, mm, 0, 0));
if (m < 1 || m > 12 || d < 1 || d > 31 || hh > 23 || mm > 59 || ss > 59) {
return null;
}
const date = new Date(Date.UTC(y, m - 1, d, hh, mm, ss, 0));
// Rejects impossible calendar dates such as February 30.
if (date.getUTCMonth() !== m - 1 || date.getUTCDate() !== d) return null;
return date.toISOString();
@@ -379,8 +382,9 @@ function offsetIso(
hh: number,
mm: number,
offsetMs: number,
ss = 0,
): string | null {
const local = iso(y, m, d, hh, mm);
const local = iso(y, m, d, hh, mm, ss);
if (local === null) return null;
return new Date(Date.parse(local) - offsetMs).toISOString();
}
@@ -555,3 +559,54 @@ export function parseIsoOffsetInstant(input: string): ParsedInstant | null {
if (Number.isNaN(value)) return null;
return { iso: new Date(value).toISOString(), precision: "exact" };
}
/**
* "12 August 2026" → 2026-08-12T00:00:00.000Z, day precision.
* "10 September 202604:59:59" → converted from `offsetMs`, exact precision.
*
* The Nikke wiki's schedule states its zone in the *column header*
* (`Start(UTC+9)`), not in the cell, so the offset arrives as an argument here
* rather than being read out of the text. A caller that cannot prove the zone
* must not call this.
*
* **A boundary with no clock keeps the day the page printed, unconverted.**
* That is the Fate/Grand Order rule (`AGENTS.md` § Fandom): there is no time of
* day to anchor a conversion to, and shifting a bare date by nine hours would
* move it to the previous calendar day — and the start's day is half an event
* ID. A boundary that does state a clock is converted, because then there is
* something real to convert.
*
* Day-first, unlike `parseMonthDayYear`: this wiki writes `12 August 2026`
* where Game8 writes `August 12, 2026`. The date and the clock arrive with no
* separator between them because they are separate elements in the markup, and
* reference markers (`[1]`) trail some cells, so the tail is tolerated rather
* than anchored.
*/
export function parseDayMonthYearClock(
input: string,
offsetMs: number,
): ParsedInstant | null {
const re = /^\s*(\d{1,2})\s+([A-Za-z]+)\.?\s+(\d{4})\s*(?:(\d{1,2}):(\d{2})(?::(\d{2}))?)?/;
const m = re.exec(input.replace(/\[\d+\]/g, " "));
if (!m) return null;
const month = monthNumber(m[2] ?? "");
if (month === null) return null;
const day = Number(m[1]);
const year = Number(m[3]);
if (m[4] === undefined) {
// No clock: the printed day stands, exactly as it does on FGO's page.
const value = iso(year, month, day);
return value === null ? null : { iso: value, precision: "day" };
}
// Seconds matter here and are carried: this page ends its events at
// 04:59:59 and starts the next banner at 05:00:00, one second apart, and
// rounding that to the minute would make the two overlap.
const value = offsetIso(
year, month, day, Number(m[4]), Number(m[5]), offsetMs, Number(m[6] ?? 0),
);
return value === null ? null : { iso: value, precision: "exact" };
}
+209 -2
View File
@@ -1,5 +1,9 @@
import { eventId, type GachaEvent } from "../../shared/schema.ts";
import { parseFullRange, parseOrdinalDateTimeRange } from "../dates.ts";
import {
parseDayMonthYearClock,
parseFullRange,
parseOrdinalDateTimeRange,
} from "../dates.ts";
import { text } from "../html.ts";
import type { ParseContext } from "../adapters/types.ts";
import { inferType } from "./game8.ts";
@@ -83,6 +87,32 @@ const FGO_DURATION = /<b>\s*Duration:\s*<\/b>([^<]*)/i;
*/
const FGO_ARTICLE_SUFFIX = /\s*\(US\)\s*$/;
/**
* The Nikke wiki's schedule tables — the third template this parser reads, and
* the only one that states its timezone in the *header* rather than the cell:
* `Event | Start(UTC+9) | End(UTC+9) | Archived(?)` for story events, and
* `Nikke | Start(UTC+9) | End(UTC+9)` for pickup banners.
*
* That header is the safety property rather than a convenience. No date on this
* page carries an offset next to it, so a table whose Start/End columns stop
* naming a zone is one this reader must refuse rather than read as UTC — the
* Blue Archive hazard, arriving one column to the left.
*/
const NIKKE_ZONE_HEADER = /^(start|end)\s*\(utc([+-]\d{1,2})\)$/;
/**
* A title cell's fallback, for when the wiki has no logo for the event yet.
*
* Every title on this page is an image and the name is normally recoverable
* from the wrapping `<a title="Project Matis">`. The newest row — today's live
* event — is the one most likely to have no logo uploaded, and then the cell is
* a red link reading `File:Persona on Frontline logo.png`. A reader that only
* understood `<a title>` would silently drop the single most important row on
* the page and publish a calendar missing what is on right now.
*/
const NIKKE_FILE_TITLE =
/^File:\s*(.+?)\s*(?:logo)?\.(?:png|jpe?g|gif|webp)$/i;
/** The rendered HTML inside an `action=parse` response, or null. */
export function renderedHtml(body: string): string | null {
let payload: unknown;
@@ -216,6 +246,173 @@ function parseFgoOngoingEvents(
return out;
}
/**
* True for the Nikke wiki's `Event` page, and the gate on the branch below.
*
* Asserts a schedule table whose Start/End headers name a zone, which is the
* one fact the reader cannot get from anywhere else on the page.
*/
function isNikkeEventPage(rendered: string): boolean {
return nikkeTables(rendered).length > 0;
}
interface NikkeTable {
body: string;
startIdx: number;
endIdx: number;
offsetMs: number;
/** Pickup banners head their title column `Nikke`; story events, `Event`. */
banner: boolean;
/** That first header, unsquashed — the table's own name for its rows. */
label: string;
}
/** Every table on the page whose Start/End columns state their offset. */
function nikkeTables(rendered: string): NikkeTable[] {
const out: NikkeTable[] = [];
for (const table of rendered.matchAll(/<table\b[^>]*>([\s\S]*?)<\/table>/gi)) {
const body = table[1] ?? "";
const headers = [...body.matchAll(/<th\b[^>]*>([\s\S]*?)<\/th>/gi)].map((h) =>
text(h[1] ?? "").toLowerCase().replace(/\s+/g, ""),
);
let startIdx = -1;
let endIdx = -1;
let offsetMs: number | null = null;
headers.forEach((h, i) => {
const m = NIKKE_ZONE_HEADER.exec(h);
if (m === null) return;
// Both columns must agree on the offset; a table stating two different
// ones is a shape this reader does not understand.
const hours = Number(m[2]);
const ms = hours * 60 * 60 * 1000;
if (offsetMs !== null && offsetMs !== ms) return;
offsetMs = ms;
if (m[1] === "start") startIdx = i;
else endIdx = i;
});
if (startIdx < 0 || endIdx < 0 || offsetMs === null) continue;
const first = headers[0] ?? "";
const label = text(
/<th\b[^>]*>([\s\S]*?)<\/th>/i.exec(body)?.[1] ?? "",
);
out.push({
body,
startIdx,
endIdx,
offsetMs,
banner: first === "nikke",
label,
});
}
return out;
}
/**
* The Nikke wiki's story events and pickup banners.
*
* Both tables are read because both are schedules our readers act on, and both
* state their zone the same way. What differs is how much they pin down: a
* story event's start is a bare date and its end carries a clock, while a
* banner usually carries one on both. `parseDayMonthYearClock` keeps a
* clockless boundary on the day the page printed rather than shifting it nine
* hours into the previous one — the Fate/Grand Order rule, and here it matters
* doubly because the start's day is half an event ID.
*/
function parseNikkeEvents(rendered: string, ctx: ParseContext): GachaEvent[] {
const nowMs = Date.parse(ctx.now);
const out: GachaEvent[] = [];
const seen = new Set<string>();
for (const table of nikkeTables(rendered)) {
for (const row of table.body.matchAll(ROW)) {
const cells = [...(row[1] ?? "").matchAll(CELL)].map((c) => ({
tag: c[1] ?? "",
html: c[2] ?? "",
}));
if (cells.length === 0 || cells.some((c) => c.tag === "h")) continue;
const titleCell = cells[0]?.html ?? "";
const title = nikkeTitle(titleCell);
if (title === null) continue;
const start = parseDayMonthYearClock(
text(cells[table.startIdx]?.html ?? ""),
table.offsetMs,
);
if (start === null) continue;
const end = parseDayMonthYearClock(
text(cells[table.endIdx]?.html ?? ""),
table.offsetMs,
);
if (end === null || end.iso <= start.iso) continue;
// Five year-tabbed tables of history sit alongside the live one, so
// inclusion is decided against ctx.now as it is everywhere else here.
if (Date.parse(end.iso) < nowMs) continue;
const id = eventId(ctx.game, title, start.iso);
if (seen.has(id)) continue;
seen.add(id);
const href = ARTICLE_LINK.exec(titleCell)?.[1];
out.push({
id,
game: ctx.game,
title,
// The table names what its rows are — "Costume Gacha", "Popularity
// Poll" — which the title alone never does. A pickup table is a
// character banner outright; everything else goes through the shared
// vocabulary with that label alongside the title.
type: table.banner ? "banner" : inferType(`${title} ${table.label}`),
summary: null,
startsAt: start.iso,
startPrecision: start.precision,
endsAt: end.iso,
endPrecision: end.precision,
// One worldwide server on a single stated offset, and the page draws no
// distinction between regions.
regionScoped: false,
regionEnds: null,
sourceUrl:
href === undefined
? ctx.sourceUrl
: new URL(href, ctx.sourceUrl).toString(),
sourceId: ctx.sourceId,
status: "published",
// Docked where the source pinned less down: a start with no clock is a
// day, not an instant.
confidence: start.precision === "day" ? 0.9 : 0.95,
extractionMethod: "parser",
version: 1,
firstSeenAt: ctx.now,
updatedAt: ctx.now,
});
}
}
return out;
}
/** A title cell's event name: the link's title, or the file name behind it. */
function nikkeTitle(cell: string): string | null {
const linked = /<a\b[^>]*title="([^"]*)"/i.exec(cell)?.[1];
const raw = (linked ?? text(cell)).trim();
if (raw.length === 0) return null;
// "File:Persona on Frontline logo.png" -> "Persona on Frontline". Applied to
// the link title too: a red link carries the file name in both places.
const named = NIKKE_FILE_TITLE.exec(raw)?.[1];
const title = (named ?? raw).trim();
return title.length === 0 ? null : title;
}
export function parseFandomEventsPage(
body: string,
ctx: ParseContext,
@@ -228,6 +425,14 @@ export function parseFandomEventsPage(
// apart, and `canParse` asserts it, so a template change fails the source
// loudly instead of routing an FGO page through the `Time Period` reader and
// emptying the lane.
if (isNikkeEventPage(rendered)) {
return parseNikkeEvents(rendered, ctx).sort((a, b) =>
a.startsAt === b.startsAt
? a.id.localeCompare(b.id)
: a.startsAt.localeCompare(b.startsAt),
);
}
if (isFgoEventList(rendered)) {
return parseFgoOngoingEvents(rendered, ctx).sort((a, b) =>
a.startsAt === b.startsAt
@@ -336,7 +541,9 @@ export const fandomParser: SourceParser = {
if (rendered === null) return false;
const isTimePeriodTable =
/class="[^"]*wikitable/.test(rendered) && /Time Period/i.test(rendered);
return isTimePeriodTable || isFgoEventList(rendered);
return (
isTimePeriodTable || isFgoEventList(rendered) || isNikkeEventPage(rendered)
);
},
parse: parseFandomEventsPage,
};
+11
View File
@@ -139,6 +139,17 @@ export const GAMES: Record<GameId, GameMeta> = {
// which states the zone the *dates* are in and says nothing about where the
// server's day rolls — and every row on it is a bare date anyway, with no
// time of day to read a reset out of. Same silence as p5x and czn.
// Nikke runs one worldwide server on a Japanese clock that rolls its day at
// **05:00**, not 04:00 — and both halves come from the source rather than
// from habit. Every schedule column on the wiki is headed `Start(UTC+9)` /
// `End(UTC+9)`, and the rows themselves show the boundary: story events end
// at 04:59:59 and the pickup banner replacing them starts at 05:00:00, one
// second apart. That is the Reverse: 1999 evidence pattern exactly.
//
// Set in the same commit that ships the game, which costs nothing now and
// could not be added later without re-labelling day keys readers had already
// logged ticks under.
nikke: { id: "nikke", name: "Goddess of Victory: Nikke", short: "Nikke", hue: "#E4572E", studio: "Shift Up", dailyTasks: "Daily missions, outpost", resetOffsets: { asia: 9, america: 9, europe: 9 }, resetHourLocal: 5 },
uma: { id: "uma", name: "Umamusume: Pretty Derby", short: "Umamusume", hue: "#6FBF44", studio: "Cygames", dailyTasks: "Daily races, missions" },
};
+3
View File
@@ -18,6 +18,9 @@ export const GameId = z.enum([
"stellasora", // Stella Sora
"czn", // Chaos Zero Nightmare
"uma", // Umamusume: Pretty Derby
// NOTE: one letter from "nikki" (Infinity Nikki) above, and both are the
// first segment of every completion key their game will ever have.
"nikke", // Goddess of Victory: Nikke
]);
export type GameId = z.infer<typeof GameId>;
+99
View File
@@ -46,6 +46,7 @@ const CASES: Array<{ adapter: Adapter; fixture: string }> = [
{ adapter: adapter("stellasora-stellasorawiki-events"), fixture: "fixtures/stellasora/stellasorawiki-events-2026-08-19" },
{ adapter: adapter("czn-game8-events"), fixture: "fixtures/czn/game8-events-2026-08-19" },
{ adapter: adapter("uma-game8-events"), fixture: "fixtures/uma/game8-events-2026-08-19" },
{ adapter: adapter("nikke-fandom-events"), fixture: "fixtures/nikke/fandom-events-2026-08-19" },
];
async function runAdapter(adapter: Adapter, fixture: string) {
@@ -1455,3 +1456,101 @@ describe("game8 column vocabulary", () => {
expect(events).toEqual([]);
});
});
describe("Nikke wiki (the third Fandom template)", () => {
const fixture = "fixtures/nikke/fandom-events-2026-08-19";
const nikke = adapter("nikke-fandom-events");
function parse(html: string) {
return nikke.parse(html, {
now: NOW,
sourceUrl: nikke.url,
sourceId: nikke.id,
game: nikke.game,
});
}
/** An `action=parse` envelope around one schedule table. */
const wrapped = (rows: string, startHead = "Start(UTC+9)", endHead = "End(UTC+9)") =>
JSON.stringify({
parse: {
text: `<table class="wikitable"><tr><th>Event</th><th>${startHead}</th>
<th>${endHead}</th><th>Archived(?)</th></tr>${rows}</table>`,
},
});
test("keeps the live event whose logo has not been uploaded", async () => {
// The row that matters most and the one a naive reader drops: every title
// here is an image read from <a title>, and the newest row is a red link
// reading "File:Persona on Frontline logo.png". Losing it publishes a
// calendar missing what is on right now.
const titles = (await runAdapter(nikke, fixture)).map((e) => e.title);
expect(titles).toContain("Persona on Frontline");
for (const t of titles) expect(t).not.toMatch(/^File:/);
for (const t of titles) expect(t).not.toMatch(/\.png$/i);
});
test("converts the stated UTC+9, carrying seconds", async () => {
const events = await runAdapter(nikke, fixture);
const persona = events.find((e) => e.title === "Persona on Frontline");
// Start is a bare date, so it keeps the day the page printed.
expect(persona?.startsAt).toBe("2026-08-12T00:00:00.000Z");
expect(persona?.startPrecision).toBe("day");
// End states 10 September 2026 04:59:59 (UTC+9) → 19:59:59Z the day before.
expect(persona?.endsAt).toBe("2026-09-09T19:59:59.000Z");
expect(persona?.endPrecision).toBe("exact");
});
test("a start with no clock keeps its printed day rather than shifting", () => {
// Nine hours would move a bare date to the previous calendar day, and the
// start's day is half an event ID. Same rule as the FGO page.
const events = parse(
wrapped(`<tr><td><a title="Bare Start">x</a></td><td>12 August 2026</td>
<td>10 September 202604:59:59</td><td></td></tr>`),
);
expect(events[0]?.startsAt).toBe("2026-08-12T00:00:00.000Z");
expect(events[0]?.id).toBe("nikke:bare-start:2026-08-12");
});
test("refuses a table whose columns stop naming the zone", () => {
// No date on this page carries an offset next to it, so the header is the
// only evidence of the zone. Losing it must empty the table, not default
// the whole schedule to UTC — the Blue Archive hazard one column left.
expect(() =>
parse(
wrapped(
`<tr><td><a title="Zoneless">x</a></td><td>12 August 2026</td>
<td>10 September 202604:59:59</td><td></td></tr>`,
"Start",
"End",
),
),
).toThrow(/redesigned/);
});
test("reads the offset the header states, not a hardcoded one", () => {
const events = parse(
wrapped(
`<tr><td><a title="Shifted">x</a></td><td>12 August 2026</td>
<td>10 September 202604:00:00</td><td></td></tr>`,
"Start(UTC+2)",
"End(UTC+2)",
),
);
expect(events[0]?.endsAt).toBe("2026-09-10T02:00:00.000Z");
});
test("publishes nothing that has already ended", async () => {
for (const e of await runAdapter(nikke, fixture)) {
expect(e.endsAt === null || e.endsAt > NOW).toBe(true);
}
});
test("still reads the other two Fandom templates", async () => {
// The branch is additive: r1999 and FGO must be untouched by it.
expect((await runAdapter(adapter("r1999-fandom-events"),
"fixtures/r1999/fandom-events-2026-08-17")).length).toBeGreaterThan(0);
expect((await runAdapter(adapter("fgo-fandom-events"),
"fixtures/fgo/fandom-events-2026-08-18")).length).toBeGreaterThan(0);
});
});