cf66ed7e26
Tests · Go / test (push) Successful in 7s
Tests · Integration / integration (push) Successful in 12s
Tests · Go / test (pull_request) Successful in 6s
Tests · Integration / integration (pull_request) Successful in 11s
Tests · UI / test (pull_request) Successful in 19s
New platform/telegram connector (own container, bot token only there): - go-telegram/bot long-poll loop: /start deep-links + Mini App launch button. - gRPC API pkg/proto/telegram/v1 (Telegram service): ValidateInitData, Notify (renders a localized message + deep-link button), SendToUser/SendToGameChannel (admin, wired in Stage 10). Generic methods are platform-agnostic (external_id). - Bot API base override for Telegram's test environment; Dockerfile + compose (VPN sidecar, no public ingress); README. Gateway: - initData validation relocated from the gateway into the connector; the gateway calls ValidateInitData over gRPC (GATEWAY_CONNECTOR_ADDR), drops the bot token, and deletes internal/auth. - Out-of-app push: runPushPump routes events whose recipient has no live in-app stream to connector.Notify, gated by /internal/push-target + the in-app-only flag (race-free de-dup); HasSubscribers added to the push hub. Backend: - Migration 00007 accounts.notifications_in_app_only (default true) + jetgen. - ProvisionTelegram seeds a new account's language/display name from the launch fields; IdentityExternalID reverse lookup; /internal/push-target handler. UI: - Telegram Mini App launch: detect initData, apply themeParams, authTelegram, route the deep-link start_param (g/i/f); /telegram/ guard redirects outside Telegram. Vite relative base + telegram-web-app.js. In-app-only profile toggle; share-to-Telegram link for a friend code. Vitest + Playwright coverage. Wire/docs/CI: fbs Profile/UpdateProfileRequest gain notifications_in_app_only (Go + TS); go.work uses ./platform/telegram; go-unit.yaml covers it; PLAN, ARCHITECTURE, FUNCTIONAL (+ru), UI_DESIGN, READMEs updated.
122 lines
4.0 KiB
TypeScript
122 lines
4.0 KiB
TypeScript
// GatewayClient — the typed facade the screens call. Both the real Connect/
|
|
// FlatBuffers transport and the in-memory mock implement it. Domain failures (the
|
|
// gateway's result_code) and edge failures (Connect error codes) are normalised
|
|
// into a thrown GatewayError carrying a stable `code` the UI maps to an i18n
|
|
// message.
|
|
|
|
import type {
|
|
AccountRef,
|
|
ChatMessage,
|
|
EvalResult,
|
|
FriendCode,
|
|
GameList,
|
|
GameView,
|
|
GcgExport,
|
|
History,
|
|
HintResult,
|
|
Invitation,
|
|
InvitationSettings,
|
|
MatchResult,
|
|
MoveResult,
|
|
Profile,
|
|
ProfileUpdate,
|
|
PushEvent,
|
|
Session,
|
|
StateView,
|
|
Stats,
|
|
Tile,
|
|
Variant,
|
|
WordCheckResult,
|
|
} from './model';
|
|
|
|
/** GatewayError carries a stable code (the gateway result_code, or an edge code). */
|
|
export class GatewayError extends Error {
|
|
readonly code: string;
|
|
constructor(code: string, message?: string) {
|
|
super(message ?? code);
|
|
this.name = 'GatewayError';
|
|
this.code = code;
|
|
}
|
|
}
|
|
|
|
/** A tile the player is submitting (rack/blank already resolved to a letter). */
|
|
export interface PlacedTile {
|
|
row: number;
|
|
col: number;
|
|
letter: string;
|
|
blank: boolean;
|
|
}
|
|
|
|
/** Unsubscribe handle for the live stream. */
|
|
export type Unsubscribe = () => void;
|
|
|
|
export interface GatewayClient {
|
|
// --- auth (unauthenticated) ---
|
|
authTelegram(initData: string): Promise<Session>;
|
|
authGuest(locale?: string): Promise<Session>;
|
|
authEmailRequest(email: string): Promise<void>;
|
|
authEmailLogin(email: string, code: string): Promise<Session>;
|
|
|
|
// --- profile / lists ---
|
|
profileGet(): Promise<Profile>;
|
|
gamesList(): Promise<GameList>;
|
|
|
|
// --- lobby ---
|
|
lobbyEnqueue(variant: Variant): Promise<MatchResult>;
|
|
lobbyPoll(): Promise<MatchResult>;
|
|
|
|
// --- game ---
|
|
gameState(gameId: string): Promise<StateView>;
|
|
gameHistory(gameId: string): Promise<History>;
|
|
submitPlay(gameId: string, dir: 'H' | 'V', tiles: PlacedTile[]): Promise<MoveResult>;
|
|
pass(gameId: string): Promise<MoveResult>;
|
|
exchange(gameId: string, tiles: string[]): Promise<MoveResult>;
|
|
resign(gameId: string): Promise<MoveResult>;
|
|
hint(gameId: string): Promise<HintResult>;
|
|
evaluate(gameId: string, dir: 'H' | 'V', tiles: PlacedTile[]): Promise<EvalResult>;
|
|
checkWord(gameId: string, word: string): Promise<WordCheckResult>;
|
|
complaint(gameId: string, word: string, note: string): Promise<void>;
|
|
|
|
// --- chat ---
|
|
chatPost(gameId: string, body: string): Promise<ChatMessage>;
|
|
chatList(gameId: string): Promise<ChatMessage[]>;
|
|
nudge(gameId: string): Promise<ChatMessage>;
|
|
|
|
// --- friends (Stage 8) ---
|
|
friendsList(): Promise<AccountRef[]>;
|
|
friendsIncoming(): Promise<AccountRef[]>;
|
|
friendRequest(accountId: string): Promise<void>;
|
|
friendRespond(requesterId: string, accept: boolean): Promise<void>;
|
|
friendCancel(accountId: string): Promise<void>;
|
|
unfriend(accountId: string): Promise<void>;
|
|
friendCodeIssue(): Promise<FriendCode>;
|
|
friendCodeRedeem(code: string): Promise<AccountRef>;
|
|
|
|
// --- blocks (Stage 8) ---
|
|
blocksList(): Promise<AccountRef[]>;
|
|
block(accountId: string): Promise<void>;
|
|
unblock(accountId: string): Promise<void>;
|
|
|
|
// --- invitations (Stage 8) ---
|
|
invitationsList(): Promise<Invitation[]>;
|
|
invitationCreate(inviteeIds: string[], settings: InvitationSettings): Promise<Invitation>;
|
|
invitationAccept(invitationId: string): Promise<Invitation>;
|
|
invitationDecline(invitationId: string): Promise<Invitation>;
|
|
invitationCancel(invitationId: string): Promise<void>;
|
|
|
|
// --- profile / stats / history (Stage 8) ---
|
|
profileUpdate(p: ProfileUpdate): Promise<Profile>;
|
|
emailBindRequest(email: string): Promise<void>;
|
|
emailBindConfirm(email: string, code: string): Promise<Profile>;
|
|
statsGet(): Promise<Stats>;
|
|
exportGcg(gameId: string): Promise<GcgExport>;
|
|
|
|
// --- live stream ---
|
|
subscribe(onEvent: (e: PushEvent) => void, onError?: (err: unknown) => void): Unsubscribe;
|
|
|
|
/** Set or clear the bearer token used for authenticated calls and the stream. */
|
|
setToken(token: string | null): void;
|
|
}
|
|
|
|
export type { GameView, Tile };
|