feat: ATM10-Statistikportal
Statistikportal für den All-the-Mods-10-Server (Minecraft 1.21.1, NeoForge 21.1): - mod/: serverseitige NeoForge-Mod atmstats – Ereignisse, Live-Zähler, Servergesundheit, FTB-Dateien; Outbox auf der Festplatte, signierter gzip-Versand per HTTPS mit Backoff - backend/: Fastify + PostgreSQL – idempotenter Ingest, Projektionen, Parser für SNBT, FTB Quests/Teams, world/stats, world/advancements und latest.log; Ranglisten, Snapshots, Retention, öffentliche API, SSE-Live-Updates, Admin mit argon2/CSRF, SFTP-Worker - web/: Next.js-Dashboard – Übersicht, Ranglisten, Spielerprofile, ATM10, Server, Datenquellen, Verwaltung - shared/: Protokoll v1 und API-Typen; tools/: Simulator, Log-Anonymisierer, RCON-Client - deploy/: Docker Compose hinter Traefik, Backup; docs/: Architektur, Datenquellen, Betrieb Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
56d2078e6a
commit
e66f89f49e
214 files changed
+27077
No files matched your search
@@ -0,0 +1,54 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { parseSnbt, SnbtError } from '../src/parsers/snbt.ts';
|
||||
|
||||
describe('parseSnbt', () => {
|
||||
it('parses newline-separated compound', () => {
|
||||
expect(parseSnbt('{\n\tversion: 1\n\tlock: false\n\tname: "CDOGamer#308a693c"\n}')).toEqual({
|
||||
version: 1,
|
||||
lock: false,
|
||||
name: 'CDOGamer#308a693c',
|
||||
});
|
||||
});
|
||||
|
||||
it('parses comma-separated compound', () => {
|
||||
expect(parseSnbt('{a: 1, b: "x", c: {d: 2b}}')).toEqual({ a: 1, b: 'x', c: { d: 2 } });
|
||||
});
|
||||
|
||||
it('parses suffixes 1L 2b 1.5f 0.0d -3s', () => {
|
||||
expect(parseSnbt('[1L, 2b, 1.5f, 0.0d, -3s, 1791559740996L]')).toEqual([1, 2, 1.5, 0, -3, 1791559740996]);
|
||||
});
|
||||
|
||||
it('parses keys that start with digits and quoted keys with colons', () => {
|
||||
expect(
|
||||
parseSnbt('{ 0000000000000001: 5L\n 308a693c2bd84d6b: { x: 1 }\n "a:B": 2L\n quest.ABC.title: "t" }'),
|
||||
).toEqual({ '0000000000000001': 5, '308a693c2bd84d6b': { x: 1 }, 'a:B': 2, 'quest.ABC.title': 't' });
|
||||
});
|
||||
|
||||
it('parses typed arrays and empty containers', () => {
|
||||
expect(parseSnbt('{a: [I; 1, 2], b: [L; 3L], c: [B; 1b], d: [], e: { }}')).toEqual({
|
||||
a: [1, 2],
|
||||
b: [3],
|
||||
c: [1],
|
||||
d: [],
|
||||
e: {},
|
||||
});
|
||||
});
|
||||
|
||||
it('parses string escapes and single quotes', () => {
|
||||
expect(parseSnbt(`["a\\"b", 'c\\'d', "\\\\"]`)).toEqual(['a"b', "c'd", '\\']);
|
||||
});
|
||||
|
||||
it('keeps unquoted non-numeric words as strings', () => {
|
||||
expect(parseSnbt('{type: item, id: 3BC0A50886A3222B}')).toEqual({ type: 'item', id: '3BC0A50886A3222B' });
|
||||
});
|
||||
|
||||
it('reports line on error', () => {
|
||||
try {
|
||||
parseSnbt('{\n a: 1\n b: {\n}');
|
||||
expect.unreachable();
|
||||
} catch (e) {
|
||||
expect(e).toBeInstanceOf(SnbtError);
|
||||
expect((e as SnbtError).line).toBe(4);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user