Files
blitzkit/packages/website-ue/src/core/api/abstract.ts
T

47 lines
1.4 KiB
TypeScript
Raw Normal View History

2026-01-02 14:20:29 -06:00
import type { CatalogItemAccessor } from "@blitzkit/closed";
2026-01-09 13:38:00 -06:00
import type { Strings } from "@blitzkit/i18n";
import locales from "@blitzkit/i18n/locales.json";
import type { Tank } from "../../protos/tank";
import type { TankList } from "../../protos/tank_list";
import type { Tanks } from "../../protos/tanks";
2025-11-28 13:51:17 -06:00
export abstract class AbstractAPI {
abstract tanks(): Promise<Tanks>;
2025-11-28 14:13:03 -06:00
2025-12-26 14:59:09 -06:00
abstract tankList(): Promise<TankList>;
2026-01-09 13:38:00 -06:00
abstract _strings(locale: string): Promise<Strings>;
abstract _gameStrings(
2025-11-28 14:13:03 -06:00
locale: string,
2026-01-09 13:38:00 -06:00
prefix: string
2025-11-28 14:13:03 -06:00
): Promise<Record<string, string>>;
2025-11-28 14:21:26 -06:00
2026-01-09 13:38:00 -06:00
private assertLocale(locale: string) {
const supported = locales.supported.find(
(supported) => supported.locale === locale
);
if (supported === undefined) {
throw new Error(`Unsupported locale: ${locale}`);
}
return supported;
}
async strings(locale: string) {
this.assertLocale(locale);
return await this._strings(locale);
}
async gameStrings(locale: string, prefix: string) {
const supported = this.assertLocale(locale);
const blitz = supported.blitz ?? supported.locale;
return await this._gameStrings(blitz, prefix);
}
2025-12-26 14:14:29 -06:00
abstract tank(id: string): Promise<Tank>;
2026-01-02 14:20:29 -06:00
abstract avatars(): Promise<CatalogItemAccessor[]>;
2026-01-02 20:04:19 -06:00
abstract avatar(id: string): Promise<CatalogItemAccessor>;
2026-01-02 20:17:24 -06:00
abstract backgrounds(): Promise<CatalogItemAccessor[]>;
abstract background(id: string): Promise<CatalogItemAccessor>;
2025-11-28 13:51:17 -06:00
}