expose and/or modify signatures from lib package

This commit is contained in:
Luciole committed 2023-08-13 16:53:03 +02:00
1 parent b72fa25d3f
commit e011625a2d
5 files changed
+72 -11

No files matched your search

+62 -3
View File
@@ -140,7 +140,27 @@ ControllerGroup.finalize();
* Controller Config class
* @extends classes.Config
*/
export class ControllerConfig extends classes.Config { }
export class ControllerConfig extends classes.Config {
get(name: "controller.name"): string;
get(name: "controller.mods_directory"): string;
get(name: "controller.database_directory"): string;
get(name: "controller.http_port"): number | null;
get(name: "controller.https_port"): number | null;
get(name: "controller.bind_address"): string | null;
get(name: "controller.external_address"): string | null;
get(name: "controller.tls_certificate"): string | null;
get(name: "controller.tls_private_key"): string | null;
get(name: "controller.auth_secret"): string | null;
get(name: "controller.heartbeat_interval"): number;
get(name: "controller.session_timeout"): number;
get(name: "controller.metrics_timeout"): number;
get(name: "controller.proxy_stream_timeout"): number;
get(name: "controller.default_mod_pack_id"): number | null;
get(name: "controller.default_role_id"): number | null;
get(name: string) {
return super.get(name);
}
}
ControllerConfig.registerGroup(ControllerGroup);
@@ -230,7 +250,22 @@ HostGroup.finalize();
* Host Config class
* @extends classes.Config
*/
export class HostConfig extends classes.Config { }
export class HostConfig extends classes.Config {
get(name: "host.name"): string;
get(name: "host.id"): number;
get(name: "host.factorio_directory"): string;
get(name: "host.mods_directory"): string;
get(name: "host.mods_directory_is_shared"): boolean;
get(name: "host.instances_directory"): string;
get(name: "host.controller_url"): string;
get(name: "host.controller_token"): string;
get(name: "host.tls_ca"): string | null;
get(name: "host.public_address"): string;
get(name: "host.max_reconnect_delay"): number;
get(name: string) {
return super.get(name);
}
}
HostConfig.registerGroup(HostGroup);
@@ -393,7 +428,31 @@ FactorioGroup.finalize();
* Instance config class
* @extends classes.Config
*/
export class InstanceConfig extends classes.Config { }
export class InstanceConfig extends classes.Config {
get(name: "instance.name"): string;
get(name: "instance.id"): number;
get(name: "instance.assigned_host"): number | null;
get(name: "instance.auto_start"): boolean;
get(name: "factorio.version"): string;
get(name: "factorio.game_port"): number | null;
get(name: "factorio.rcon_port"): number | null;
get(name: "factorio.rcon_password"): string | null;
get(name: "factorio.player_online_autosave_slots"): number;
get(name: "factorio.mod_pack"): string | null;
get(name: "factorio.enable_save_patching"): boolean;
get(name: "factorio.enable_whitelist"): boolean;
get(name: "factorio.enable_authserver_bans"): boolean;
get(name: "factorio.settings"): Object;
get(name: "factorio.verbose_logging"): boolean;
get(name: "factorio.strip_paths"): boolean;
get(name: "factorio.sync_adminlist"): boolean;
get(name: "factorio.sync_whitelist"): boolean;
get(name: "factorio.max_concurrent_commands"): number;
get(name: string) {
return super.get(name);
}
}
InstanceConfig.registerGroup(InstanceGroup);
InstanceConfig.registerGroup(FactorioGroup);
+2 -2
View File
@@ -80,7 +80,7 @@ export class HostGenerateTokenRequest {
static permission = "core.host.generate_token" as const;
constructor(
public hostId?: number,
public hostId: number | null = null,
) { }
static jsonSchema = Type.Object({
@@ -202,7 +202,7 @@ export class LogMessageEvent {
static dst = ["controller", "control"] as const;
constructor(
public info: object,
public info: { level: string, message: string },
) { }
static jsonSchema = Type.Object({
+3 -1
View File
@@ -48,7 +48,7 @@ export class Address {
* Shorthand to translate with.
* @returns Translated address.
*/
static fromShorthand(shorthand: AddressShorthand) {
static fromShorthand(shorthand: AddressShorthand | Address) {
if (shorthand instanceof Address) { return shorthand; }
if (shorthand === "controller") { return new Address(Address.controller, 0); }
if (shorthand === "allHosts") { return new Address(Address.broadcast, Address.host); }
@@ -172,6 +172,8 @@ export class Message {
}
}
export type MessageSrcDst = MessageRequest | MessageResponse | MessageResponseError | MessageEvent;
export class HelloData {
constructor(
public version: string,
+4 -4
View File
@@ -37,7 +37,7 @@ export interface Event<T> {
}
export type EventClass<T> = Event<T>["constructor"];
interface RequestEntry {
export interface RequestEntry {
Request: RequestClass<unknown, unknown>;
name: string,
allowedSrcTypes: Set<number>;
@@ -60,15 +60,15 @@ interface ForwardedRequest {
dst: libData.Address;
}
interface EventEntry {
export interface EventEntry {
Event: EventClass<unknown>;
name: string,
allowedSrcTypes: Set<number>;
allowedDstTypes: Set<number>;
eventFromJSON: (json: any) => Event<unknown>;
}
type RequestHandler<Req, Res> = (request: Req, src: libData.Address, dst: libData.Address) => Promise<Res>;
type EventHandler<T> = (event: T, src: libData.Address, dst: libData.Address) => Promise<void>;
export type RequestHandler<Req, Res> = (request: Req, src: libData.Address, dst: libData.Address) => Promise<Res>;
export type EventHandler<T> = (event: T, src: libData.Address, dst: libData.Address) => Promise<void>;
interface Router {
forwardMessage(origin: Link, message: Message, fallback: boolean): boolean,
+1 -1
View File
@@ -451,7 +451,7 @@ export interface QueryLogFilter {
* Index to speed up query with.
* @returns log entries matching the filter
*/
export async function queryLog(logDirectory: string, filter: QueryLogFilter, index: LogIndex) {
export async function queryLog(logDirectory: string, filter: QueryLogFilter, index: LogIndex | null) {
let files = (await fs.readdir(logDirectory)).filter(entry => logFileGlob.test(entry));
filter = {