mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 07:04:52 +09:00
Export validators on Config class as static
This commit is contained in:
2 files changed
+35
-31
No files matched your search
@@ -8,6 +8,7 @@ import { basicType } from "../helpers";
|
||||
import * as libSchema from "../schema";
|
||||
import { StringEnum } from "../data/composites";
|
||||
import { safeOutputFile } from "../file_ops";
|
||||
import * as validators from "./validators";
|
||||
|
||||
const ConfigLocation = StringEnum(["controller", "host", "control"]);
|
||||
export type ConfigLocation = Static<typeof ConfigLocation>;
|
||||
@@ -203,6 +204,9 @@ export class Config<
|
||||
declare static fieldDefinitions: ConfigDefs<any>;
|
||||
declare ["constructor"]: typeof Config;
|
||||
|
||||
/** A set of common validators and validator factories */
|
||||
static validators = validators;
|
||||
|
||||
/**
|
||||
* Handle migration between clusterio versions
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Core definitions for the configuration system
|
||||
import * as classes from "./classes";
|
||||
import * as validate from "./validators";
|
||||
import * as validators from "./validators";
|
||||
import type { PluginNodeEnvInfo, PluginWebpackEnvInfo } from "../plugin";
|
||||
import { Static } from "@sinclair/typebox";
|
||||
import { isTargetVersion } from "../data/version";
|
||||
@@ -75,21 +75,21 @@ export class ControllerConfig extends classes.Config<ControllerConfigFields> {
|
||||
restartRequired: true,
|
||||
type: "string",
|
||||
initialValue: "mods",
|
||||
extendedValidation: validate.filePath,
|
||||
extendedValidation: validators.filePath,
|
||||
},
|
||||
"controller.database_directory": {
|
||||
title: "Database directory",
|
||||
description: "Directory where item and configuration data is stored.",
|
||||
type: "string",
|
||||
initialValue: "database",
|
||||
extendedValidation: validate.filePath,
|
||||
extendedValidation: validators.filePath,
|
||||
},
|
||||
"controller.autosave_interval": {
|
||||
title: "Autosave Interval",
|
||||
description: "Interval in seconds to autosave data in memory to disk.",
|
||||
type: "number",
|
||||
initialValue: 60,
|
||||
extendedValidation: validate.greaterThanZero,
|
||||
extendedValidation: validators.greaterThanZero,
|
||||
},
|
||||
"controller.http_port": {
|
||||
title: "HTTP Port",
|
||||
@@ -98,9 +98,9 @@ export class ControllerConfig extends classes.Config<ControllerConfigFields> {
|
||||
type: "number",
|
||||
optional: true,
|
||||
initialValue: 8080,
|
||||
extendedValidation: validate.optional(validate.all(
|
||||
validate.integer,
|
||||
validate.greaterThanZero
|
||||
extendedValidation: validators.optional(validators.all(
|
||||
validators.integer,
|
||||
validators.greaterThanZero
|
||||
)),
|
||||
},
|
||||
"controller.https_port": {
|
||||
@@ -109,9 +109,9 @@ export class ControllerConfig extends classes.Config<ControllerConfigFields> {
|
||||
restartRequired: true,
|
||||
type: "number",
|
||||
optional: true,
|
||||
extendedValidation: validate.optional(validate.all(
|
||||
validate.integer,
|
||||
validate.greaterThanZero
|
||||
extendedValidation: validators.optional(validators.all(
|
||||
validators.integer,
|
||||
validators.greaterThanZero
|
||||
)),
|
||||
},
|
||||
"controller.bind_address": {
|
||||
@@ -143,7 +143,7 @@ export class ControllerConfig extends classes.Config<ControllerConfigFields> {
|
||||
restartRequired: true,
|
||||
type: "string",
|
||||
optional: true,
|
||||
extendedValidation: validate.optional(validate.filePath),
|
||||
extendedValidation: validators.optional(validators.filePath),
|
||||
},
|
||||
"controller.tls_private_key": {
|
||||
title: "TLS Private Key",
|
||||
@@ -151,7 +151,7 @@ export class ControllerConfig extends classes.Config<ControllerConfigFields> {
|
||||
restartRequired: true,
|
||||
type: "string",
|
||||
optional: true,
|
||||
extendedValidation: validate.optional(validate.filePath),
|
||||
extendedValidation: validators.optional(validators.filePath),
|
||||
},
|
||||
"controller.auth_secret": {
|
||||
access: ["controller"],
|
||||
@@ -169,35 +169,35 @@ export class ControllerConfig extends classes.Config<ControllerConfigFields> {
|
||||
description: "Interval heartbeats are sent out on WebSocket connections.",
|
||||
type: "number",
|
||||
initialValue: 15,
|
||||
extendedValidation: validate.greaterThanZero,
|
||||
extendedValidation: validators.greaterThanZero,
|
||||
},
|
||||
"controller.session_timeout": {
|
||||
title: "Session Timeout",
|
||||
description: "Time in seconds before giving up resuming a dropped WebSocket session.",
|
||||
type: "number",
|
||||
initialValue: 60,
|
||||
extendedValidation: validate.greaterThanZero,
|
||||
extendedValidation: validators.greaterThanZero,
|
||||
},
|
||||
"controller.metrics_timeout": {
|
||||
title: "Metrics Timeout",
|
||||
description: "Timeout in seconds for metrics gathering from hosts.",
|
||||
type: "number",
|
||||
initialValue: 8,
|
||||
extendedValidation: validate.greaterThanZero,
|
||||
extendedValidation: validators.greaterThanZero,
|
||||
},
|
||||
"controller.system_metrics_interval": {
|
||||
title: "System Metrics Interval",
|
||||
description: "Interval in seconds to collect and update system metrics for the Web UI",
|
||||
type: "number",
|
||||
initialValue: 10,
|
||||
extendedValidation: validate.greaterThanZero,
|
||||
extendedValidation: validators.greaterThanZero,
|
||||
},
|
||||
"controller.proxy_stream_timeout": {
|
||||
title: "Proxy Stream Timeout",
|
||||
description: "Timeout in seconds for proxy streams to start flowing.",
|
||||
type: "number",
|
||||
initialValue: 15,
|
||||
extendedValidation: validate.greaterThanZero,
|
||||
extendedValidation: validators.greaterThanZero,
|
||||
},
|
||||
"controller.factorio_username": {
|
||||
title: "Factorio Username",
|
||||
@@ -243,14 +243,14 @@ export class ControllerConfig extends classes.Config<ControllerConfigFields> {
|
||||
description: "Duration in minutes to cache mod portal API responses.",
|
||||
type: "number",
|
||||
initialValue: 30,
|
||||
extendedValidation: validate.greaterThanEqualZero, // Zero is allowed here to disable cache
|
||||
extendedValidation: validators.greaterThanEqualZero, // Zero is allowed here to disable cache
|
||||
},
|
||||
"controller.mod_portal_page_size": {
|
||||
title: "Mod Portal Page Size",
|
||||
description: "Maximum number of results per page when querying the Factorio mod portal API.",
|
||||
type: "number",
|
||||
initialValue: 1000,
|
||||
extendedValidation: validate.greaterThanZero,
|
||||
extendedValidation: validators.greaterThanZero,
|
||||
},
|
||||
"controller.allow_remote_updates": {
|
||||
description: "When true, allows a remote event to trigger a clusterio update via npm",
|
||||
@@ -326,7 +326,7 @@ export class HostConfig extends classes.Config<HostConfigFields> {
|
||||
description: "Path to directory to look for factorio installs",
|
||||
type: "string",
|
||||
initialValue: "factorio",
|
||||
extendedValidation: validate.filePath,
|
||||
extendedValidation: validators.filePath,
|
||||
},
|
||||
"host.mods_directory": {
|
||||
title: "Mods Directory",
|
||||
@@ -334,14 +334,14 @@ export class HostConfig extends classes.Config<HostConfigFields> {
|
||||
restartRequired: true,
|
||||
type: "string",
|
||||
initialValue: "mods",
|
||||
extendedValidation: validate.filePath,
|
||||
extendedValidation: validators.filePath,
|
||||
},
|
||||
"host.instances_directory": {
|
||||
description: "Path to directory to store instances in.",
|
||||
restartRequired: true,
|
||||
type: "string",
|
||||
initialValue: "instances",
|
||||
extendedValidation: validate.filePath,
|
||||
extendedValidation: validators.filePath,
|
||||
},
|
||||
"host.controller_url": {
|
||||
description: "URL to connect to the controller at",
|
||||
@@ -363,7 +363,7 @@ export class HostConfig extends classes.Config<HostConfigFields> {
|
||||
restartRequired: true,
|
||||
type: "string",
|
||||
optional: true,
|
||||
extendedValidation: validate.optional(validate.filePath),
|
||||
extendedValidation: validators.optional(validators.filePath),
|
||||
},
|
||||
"host.public_address": {
|
||||
description: "Public facing address players should connect to in order to join instances on this host",
|
||||
@@ -404,7 +404,7 @@ export class HostConfig extends classes.Config<HostConfigFields> {
|
||||
description: "Maximum delay to wait before attempting to reconnect WebSocket",
|
||||
type: "number",
|
||||
initialValue: 60,
|
||||
extendedValidation: validate.greaterThanZero,
|
||||
extendedValidation: validators.greaterThanZero,
|
||||
},
|
||||
"host.allow_remote_updates": {
|
||||
description: "When true, allows a remote event to trigger a clusterio update via npm",
|
||||
@@ -529,7 +529,7 @@ export class InstanceConfig extends classes.Config<InstanceConfigFields> {
|
||||
restartRequired: true,
|
||||
type: "string",
|
||||
optional: true,
|
||||
extendedValidation: validate.optional(validate.filePath),
|
||||
extendedValidation: validators.optional(validators.filePath),
|
||||
},
|
||||
"factorio.shutdown_timeout": {
|
||||
description:
|
||||
@@ -537,14 +537,14 @@ export class InstanceConfig extends classes.Config<InstanceConfigFields> {
|
||||
"the process. Set to 0 to disable.",
|
||||
type: "number",
|
||||
initialValue: 300,
|
||||
extendedValidation: validate.greaterThanEqualZero,
|
||||
extendedValidation: validators.greaterThanEqualZero,
|
||||
},
|
||||
"factorio.game_port": {
|
||||
description: "UDP port to run game on, uses a port in host.factorio_port_range if null",
|
||||
restartRequired: true,
|
||||
type: "number",
|
||||
optional: true,
|
||||
extendedValidation: validate.optional(validate.greaterThanZero),
|
||||
extendedValidation: validators.optional(validators.greaterThanZero),
|
||||
},
|
||||
"factorio.host_assigned_game_port": {
|
||||
access: ["host"],
|
||||
@@ -557,7 +557,7 @@ export class InstanceConfig extends classes.Config<InstanceConfigFields> {
|
||||
restartRequired: true,
|
||||
type: "number",
|
||||
optional: true,
|
||||
extendedValidation: validate.optional(validate.greaterThanZero),
|
||||
extendedValidation: validators.optional(validators.greaterThanZero),
|
||||
},
|
||||
"factorio.rcon_password": {
|
||||
credential: ["host", "controller"],
|
||||
@@ -670,7 +670,7 @@ export class InstanceConfig extends classes.Config<InstanceConfigFields> {
|
||||
restartRequired: true,
|
||||
type: "number",
|
||||
initialValue: 5,
|
||||
extendedValidation: validate.greaterThanZero,
|
||||
extendedValidation: validators.greaterThanZero,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -705,14 +705,14 @@ export class ControlConfig extends classes.Config<ControlConfigFields> {
|
||||
description: "Path to Certificate Authority to validate TLS connection to controller against.",
|
||||
type: "string",
|
||||
optional: true,
|
||||
extendedValidation: validate.optional(validate.filePath),
|
||||
extendedValidation: validators.optional(validators.filePath),
|
||||
},
|
||||
"control.max_reconnect_delay": {
|
||||
title: "Max Reconnect Delay",
|
||||
description: "Maximum delay to wait before attempting to reconnect WebSocket",
|
||||
type: "number",
|
||||
initialValue: 60,
|
||||
extendedValidation: validate.greaterThanEqualZero,
|
||||
extendedValidation: validators.greaterThanEqualZero,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user