battle-fetch: migrate to user.games.battle ConnectRPC command
Tests · UI / test (push) Has been cancelled
Tests · Go / test (pull_request) Successful in 2m6s
Tests · Go / test (push) Successful in 2m7s
Tests · Integration / integration (pull_request) Successful in 1m47s
Tests · UI / test (pull_request) Failing after 3m42s
Tests · UI / test (push) Has been cancelled
Tests · Go / test (pull_request) Successful in 2m6s
Tests · Go / test (push) Successful in 2m7s
Tests · Integration / integration (pull_request) Successful in 1m47s
Tests · UI / test (pull_request) Failing after 3m42s
The Phase 27 BattleViewer was the last UI surface still issuing raw
fetch() against the backend REST contract (`/api/v1/user/games/...
/battles/...`). The dev-deploy gateway never proxied that path, so
the viewer worked only in tools/local-dev/. Move it onto the signed
ConnectRPC channel every other authenticated surface already uses.
Wire pieces:
- FBS GameBattleRequest in pkg/schema/fbs/battle.fbs, regenerated
Go + TS bindings.
- MessageTypeUserGamesBattle constant + GameBattleRequest struct in
pkg/model/report/messages.go.
- pkg/transcoder/battle.go gains GameBattleRequestToPayload and
PayloadToGameBattleRequest helpers.
- gateway games_commands.go switches on the new message type and
GETs /api/v1/user/games/{id}/battles/{turn}/{battle_id}; the JSON
response is re-encoded as a FlatBuffers BattleReport before being
returned. 404 from backend surfaces as the canonical `not_found`
gateway error.
- ui/frontend/src/api/battle-fetch.ts now builds the FBS request,
calls GalaxyClient.executeCommand, and decodes the FBS response
into the existing UI shape (Record<string,string> race/ship maps,
string-form UUID). BattleFetchError carries an HTTP-style status
derived from the result code so the active-view's not_found branch
keeps working.
- battle.svelte pulls the GalaxyClient from the in-game shell
context. While the layout's boot Promise.all is in flight the
effect stays in `loading` until the client handle becomes
non-null.
- ui/Makefile FBS_INPUTS gains battle.fbs.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,201 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
import { TechEntry, TechEntryT } from '../battle/tech-entry.js';
|
||||
|
||||
|
||||
export class BattleReportGroup implements flatbuffers.IUnpackableObject<BattleReportGroupT> {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb_pos = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):BattleReportGroup {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
static getRootAsBattleReportGroup(bb:flatbuffers.ByteBuffer, obj?:BattleReportGroup):BattleReportGroup {
|
||||
return (obj || new BattleReportGroup()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static getSizePrefixedRootAsBattleReportGroup(bb:flatbuffers.ByteBuffer, obj?:BattleReportGroup):BattleReportGroup {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new BattleReportGroup()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
inBattle():boolean {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
|
||||
}
|
||||
|
||||
number():bigint {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 6);
|
||||
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
|
||||
}
|
||||
|
||||
numberLeft():bigint {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 8);
|
||||
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
|
||||
}
|
||||
|
||||
loadQuantity():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 10);
|
||||
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
|
||||
}
|
||||
|
||||
tech(index: number, obj?:TechEntry):TechEntry|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 12);
|
||||
return offset ? (obj || new TechEntry()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
|
||||
}
|
||||
|
||||
techLength():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 12);
|
||||
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
race():string|null
|
||||
race(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
|
||||
race(optionalEncoding?:any):string|Uint8Array|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 14);
|
||||
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
|
||||
}
|
||||
|
||||
className():string|null
|
||||
className(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
|
||||
className(optionalEncoding?:any):string|Uint8Array|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 16);
|
||||
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
|
||||
}
|
||||
|
||||
loadType():string|null
|
||||
loadType(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
|
||||
loadType(optionalEncoding?:any):string|Uint8Array|null {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 18);
|
||||
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
|
||||
}
|
||||
|
||||
static startBattleReportGroup(builder:flatbuffers.Builder) {
|
||||
builder.startObject(8);
|
||||
}
|
||||
|
||||
static addInBattle(builder:flatbuffers.Builder, inBattle:boolean) {
|
||||
builder.addFieldInt8(0, +inBattle, +false);
|
||||
}
|
||||
|
||||
static addNumber(builder:flatbuffers.Builder, number:bigint) {
|
||||
builder.addFieldInt64(1, number, BigInt('0'));
|
||||
}
|
||||
|
||||
static addNumberLeft(builder:flatbuffers.Builder, numberLeft:bigint) {
|
||||
builder.addFieldInt64(2, numberLeft, BigInt('0'));
|
||||
}
|
||||
|
||||
static addLoadQuantity(builder:flatbuffers.Builder, loadQuantity:number) {
|
||||
builder.addFieldFloat32(3, loadQuantity, 0.0);
|
||||
}
|
||||
|
||||
static addTech(builder:flatbuffers.Builder, techOffset:flatbuffers.Offset) {
|
||||
builder.addFieldOffset(4, techOffset, 0);
|
||||
}
|
||||
|
||||
static createTechVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
|
||||
builder.startVector(4, data.length, 4);
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
builder.addOffset(data[i]!);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
|
||||
static startTechVector(builder:flatbuffers.Builder, numElems:number) {
|
||||
builder.startVector(4, numElems, 4);
|
||||
}
|
||||
|
||||
static addRace(builder:flatbuffers.Builder, raceOffset:flatbuffers.Offset) {
|
||||
builder.addFieldOffset(5, raceOffset, 0);
|
||||
}
|
||||
|
||||
static addClassName(builder:flatbuffers.Builder, classNameOffset:flatbuffers.Offset) {
|
||||
builder.addFieldOffset(6, classNameOffset, 0);
|
||||
}
|
||||
|
||||
static addLoadType(builder:flatbuffers.Builder, loadTypeOffset:flatbuffers.Offset) {
|
||||
builder.addFieldOffset(7, loadTypeOffset, 0);
|
||||
}
|
||||
|
||||
static endBattleReportGroup(builder:flatbuffers.Builder):flatbuffers.Offset {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
|
||||
static createBattleReportGroup(builder:flatbuffers.Builder, inBattle:boolean, number:bigint, numberLeft:bigint, loadQuantity:number, techOffset:flatbuffers.Offset, raceOffset:flatbuffers.Offset, classNameOffset:flatbuffers.Offset, loadTypeOffset:flatbuffers.Offset):flatbuffers.Offset {
|
||||
BattleReportGroup.startBattleReportGroup(builder);
|
||||
BattleReportGroup.addInBattle(builder, inBattle);
|
||||
BattleReportGroup.addNumber(builder, number);
|
||||
BattleReportGroup.addNumberLeft(builder, numberLeft);
|
||||
BattleReportGroup.addLoadQuantity(builder, loadQuantity);
|
||||
BattleReportGroup.addTech(builder, techOffset);
|
||||
BattleReportGroup.addRace(builder, raceOffset);
|
||||
BattleReportGroup.addClassName(builder, classNameOffset);
|
||||
BattleReportGroup.addLoadType(builder, loadTypeOffset);
|
||||
return BattleReportGroup.endBattleReportGroup(builder);
|
||||
}
|
||||
|
||||
unpack(): BattleReportGroupT {
|
||||
return new BattleReportGroupT(
|
||||
this.inBattle(),
|
||||
this.number(),
|
||||
this.numberLeft(),
|
||||
this.loadQuantity(),
|
||||
this.bb!.createObjList<TechEntry, TechEntryT>(this.tech.bind(this), this.techLength()),
|
||||
this.race(),
|
||||
this.className(),
|
||||
this.loadType()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
unpackTo(_o: BattleReportGroupT): void {
|
||||
_o.inBattle = this.inBattle();
|
||||
_o.number = this.number();
|
||||
_o.numberLeft = this.numberLeft();
|
||||
_o.loadQuantity = this.loadQuantity();
|
||||
_o.tech = this.bb!.createObjList<TechEntry, TechEntryT>(this.tech.bind(this), this.techLength());
|
||||
_o.race = this.race();
|
||||
_o.className = this.className();
|
||||
_o.loadType = this.loadType();
|
||||
}
|
||||
}
|
||||
|
||||
export class BattleReportGroupT implements flatbuffers.IGeneratedObject {
|
||||
constructor(
|
||||
public inBattle: boolean = false,
|
||||
public number: bigint = BigInt('0'),
|
||||
public numberLeft: bigint = BigInt('0'),
|
||||
public loadQuantity: number = 0.0,
|
||||
public tech: (TechEntryT)[] = [],
|
||||
public race: string|Uint8Array|null = null,
|
||||
public className: string|Uint8Array|null = null,
|
||||
public loadType: string|Uint8Array|null = null
|
||||
){}
|
||||
|
||||
|
||||
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
||||
const tech = BattleReportGroup.createTechVector(builder, builder.createObjectOffsetList(this.tech));
|
||||
const race = (this.race !== null ? builder.createString(this.race!) : 0);
|
||||
const className = (this.className !== null ? builder.createString(this.className!) : 0);
|
||||
const loadType = (this.loadType !== null ? builder.createString(this.loadType!) : 0);
|
||||
|
||||
return BattleReportGroup.createBattleReportGroup(builder,
|
||||
this.inBattle,
|
||||
this.number,
|
||||
this.numberLeft,
|
||||
this.loadQuantity,
|
||||
tech,
|
||||
race,
|
||||
className,
|
||||
loadType
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user