mirror of
https://github.com/Yuyi-Oak/BlueArchiveToolkit.git
synced 2026-09-18 08:54:55 +08:00
fix(api): 补齐 bat-api 控制与后端 RPC
This commit is contained in:
@@ -23,6 +23,21 @@ type Backend interface {
|
||||
ResourceManifest(ctx context.Context, offset int, limit int) (*backendrpc.ResourceManifestPage, error)
|
||||
}
|
||||
|
||||
// ControlBackend is the explicitly allowlisted mutation subset exposed through
|
||||
// the authenticated bat-api admin control surface.
|
||||
//
|
||||
// It intentionally does not include daemon.stop, cleanup, or generic RPC calls.
|
||||
// Restart is forwarded only to Rust's lifecycle RPC; Go never execs bat itself.
|
||||
type ControlBackend interface {
|
||||
DaemonRestart(ctx context.Context) (*backendrpc.Ack, error)
|
||||
DaemonReload(ctx context.Context) (*backendrpc.Ack, error)
|
||||
DaemonRefresh(ctx context.Context, force bool) (*backendrpc.Ack, error)
|
||||
ResourceSync(ctx context.Context, force bool) (*backendrpc.TaskAccepted, error)
|
||||
ResourceVerify(ctx context.Context) (*backendrpc.TaskAccepted, error)
|
||||
ResourceRepair(ctx context.Context) (*backendrpc.TaskAccepted, error)
|
||||
CatalogRefresh(ctx context.Context, force bool) (*backendrpc.TaskAccepted, error)
|
||||
}
|
||||
|
||||
// RPCClient adapts *backendrpc.Client to Backend.
|
||||
type RPCClient struct {
|
||||
Client *backendrpc.Client
|
||||
@@ -43,6 +58,48 @@ func (r RPCClient) CatalogStatus(ctx context.Context) (json.RawMessage, error) {
|
||||
func (r RPCClient) ResourceManifest(ctx context.Context, offset int, limit int) (*backendrpc.ResourceManifestPage, error) {
|
||||
return r.Client.ResourceManifest(ctx, offset, limit)
|
||||
}
|
||||
func (r RPCClient) DaemonRestart(ctx context.Context) (*backendrpc.Ack, error) {
|
||||
return r.Client.DaemonRestart(ctx)
|
||||
}
|
||||
func (r RPCClient) DaemonReload(ctx context.Context) (*backendrpc.Ack, error) {
|
||||
return r.Client.DaemonReload(ctx)
|
||||
}
|
||||
func (r RPCClient) DaemonRefresh(ctx context.Context, force bool) (*backendrpc.Ack, error) {
|
||||
return r.Client.DaemonRefresh(ctx, force)
|
||||
}
|
||||
func (r RPCClient) ResourceSync(ctx context.Context, force bool) (*backendrpc.TaskAccepted, error) {
|
||||
return r.Client.ResourceSync(ctx, force)
|
||||
}
|
||||
func (r RPCClient) ResourceVerify(ctx context.Context) (*backendrpc.TaskAccepted, error) {
|
||||
return r.Client.ResourceVerify(ctx)
|
||||
}
|
||||
func (r RPCClient) ResourceRepair(ctx context.Context) (*backendrpc.TaskAccepted, error) {
|
||||
return r.Client.ResourceRepair(ctx)
|
||||
}
|
||||
func (r RPCClient) CatalogRefresh(ctx context.Context, force bool) (*backendrpc.TaskAccepted, error) {
|
||||
return r.Client.CatalogRefresh(ctx, force)
|
||||
}
|
||||
func (r RPCClient) ParseStatus(ctx context.Context) (json.RawMessage, error) {
|
||||
return r.Client.ParseStatus(ctx)
|
||||
}
|
||||
func (r RPCClient) ParseTextUnits(ctx context.Context, query backendrpc.TextUnitQueryParams) (json.RawMessage, error) {
|
||||
return r.Client.ParseTextUnits(ctx, query)
|
||||
}
|
||||
func (r RPCClient) ParseErrors(ctx context.Context, query backendrpc.TextUnitQueryParams) (json.RawMessage, error) {
|
||||
return r.Client.ParseErrors(ctx, query)
|
||||
}
|
||||
func (r RPCClient) LocalizedStatus(ctx context.Context) (json.RawMessage, error) {
|
||||
return r.Client.LocalizedStatus(ctx)
|
||||
}
|
||||
func (r RPCClient) UnityFSPatchTextAsset(ctx context.Context, params backendrpc.UnityFSTextAssetPatchParams) (json.RawMessage, error) {
|
||||
return r.Client.UnityFSPatchTextAsset(ctx, params)
|
||||
}
|
||||
func (r RPCClient) UnityFSPatchStringField(ctx context.Context, params backendrpc.UnityFSStringFieldPatchParams) (json.RawMessage, error) {
|
||||
return r.Client.UnityFSPatchStringField(ctx, params)
|
||||
}
|
||||
func (r RPCClient) UnityFSPatchField(ctx context.Context, params backendrpc.UnityFSFieldPatchParams) (json.RawMessage, error) {
|
||||
return r.Client.UnityFSPatchField(ctx, params)
|
||||
}
|
||||
|
||||
// DiscoverResult is the outcome of talking to the bat daemon.
|
||||
type DiscoverResult struct {
|
||||
|
||||
Reference in New Issue
Block a user