Read RTS publications through CultMesh documents
This commit is contained in:
parent
4be3b2ffb8
commit
ed2e547aeb
2 changed files with 34 additions and 14 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import { decode } from "@msgpack/msgpack";
|
||||
import { SingleFileMessagePackBackingStore } from "cultcache-ts";
|
||||
import { CultMesh } from "cultmesh-ts";
|
||||
|
||||
export class AetheriaLocalPublicationReader {
|
||||
public constructor(private readonly statePath: string) {}
|
||||
|
|
@ -9,28 +8,41 @@ export class AetheriaLocalPublicationReader {
|
|||
}
|
||||
|
||||
public readDaemonFrame(): Promise<unknown> {
|
||||
return this.readSingleDocument(`${this.statePath}.daemon.frame.cc`, "gamecult.aetheria.daemon_frame.v1");
|
||||
return this.readSingleDocument(
|
||||
`${this.statePath}.daemon.frame.cc`,
|
||||
"gamecult.aetheria.daemon_frame.v1",
|
||||
"daemon:aetheria.frame.latest.v1");
|
||||
}
|
||||
|
||||
public readDaemonHealth(): Promise<unknown> {
|
||||
return this.readSingleDocument(`${this.statePath}.daemon.health.cc`, "gamecult.aetheria.daemon_health.v1");
|
||||
return this.readSingleDocument(
|
||||
`${this.statePath}.daemon.health.cc`,
|
||||
"gamecult.aetheria.daemon_health.v1",
|
||||
"daemon:aetheria.health.latest.v1");
|
||||
}
|
||||
|
||||
public readAuthorityPolicy(): Promise<unknown> {
|
||||
return this.readSingleDocument(`${this.statePath}.authority.policy.cc`, "gamecult.aetheria.verse_authority_policy.v1");
|
||||
return this.readSingleDocument(
|
||||
`${this.statePath}.authority.policy.cc`,
|
||||
"gamecult.aetheria.verse_authority_policy.v1",
|
||||
"daemon:aetheria.authority.policy.latest.v1");
|
||||
}
|
||||
|
||||
public readStarbridgeSessionSummary(): Promise<unknown> {
|
||||
return this.readSingleDocument(
|
||||
`${this.statePath}.daemon.starbridge.session.cc`,
|
||||
"gamecult.aetheria.starbridge_session_summary.v1");
|
||||
"gamecult.aetheria.starbridge_session_summary.v1",
|
||||
"daemon:aetheria.starbridge.session.latest.v1");
|
||||
}
|
||||
|
||||
private async readSingleDocument(path: string, schemaId: string): Promise<unknown> {
|
||||
const records = await new SingleFileMessagePackBackingStore(path).pullAll();
|
||||
const record = records.find(candidate => candidate.schemaId === schemaId);
|
||||
if (!record)
|
||||
throw new Error(`Aetheria local publication ${path} did not contain schema ${schemaId}.`);
|
||||
return decode(record.payload);
|
||||
private readSingleDocument(
|
||||
path: string,
|
||||
schemaId: string,
|
||||
documentId: string,
|
||||
): Promise<unknown> {
|
||||
return CultMesh.documentFromSingleFile(path, schemaId, {
|
||||
documentId,
|
||||
sourceId: documentId,
|
||||
}).latest();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -473,9 +473,17 @@ foreach ($symbol in $requiredProjectionSymbols) {
|
|||
}
|
||||
}
|
||||
|
||||
& rg -q 'SingleFileMessagePackBackingStore' Electron/aetheria-local-publication-reader.ts
|
||||
& rg -q 'CultMesh.documentFromSingleFile' Electron/aetheria-local-publication-reader.ts
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Error "Stage 7B verifier failed: local CultCache publication reader was not found."
|
||||
Write-Error "Stage 7B verifier failed: local publications should be read through CultMesh document handles."
|
||||
}
|
||||
|
||||
$forbiddenLocalPublicationReaderPlumbing = & rg -n 'SingleFileMessagePackBackingStore|decode\(|pullAll\(' Electron/aetheria-local-publication-reader.ts 2>$null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Error "Stage 7B verifier failed: local publication reader still owns backing-store or MessagePack plumbing.`n$forbiddenLocalPublicationReaderPlumbing"
|
||||
}
|
||||
if ($LASTEXITCODE -gt 1) {
|
||||
Write-Error "Stage 7B verifier could not run rg for local publication reader plumbing checks."
|
||||
}
|
||||
|
||||
& rg -q 'readStarbridgeSessionSummary' Electron/aetheria-local-publication-reader.ts
|
||||
|
|
|
|||
Loading…
Reference in a new issue