/** * Default value of {@link ScreepsRawServerConfig | ScreepsRawServerConfig.hostname} * @category Common */ export declare const DEFAULT_SERVER_HOST = "screeps.com"; /** * Default value of {@link ScreepsRawServerConfig | ScreepsRawServerConfig.path} * @category Common */ export declare const DEFAULT_SERVER_PATH = "/"; /** * Defaults for {@link ScreepsClientConfig} * @category Common */ export declare const DEFAULT_CLIENT_CONFIG: { readonly retry429Global: true; readonly retry429InitDelay: 60000; readonly retry429MaxDelay: 10800000; readonly retry429MaxRetries: 0; readonly wsKeepAlive: true; readonly wsKeepAliveInterval: 10000; readonly wsReconnect: true; readonly wsReconnectInitDelay: 100; readonly wsReconnectMaxDelay: 60000; readonly wsReconnectMaxRetries: 10; readonly wsResubscribe: true; }; /** * Provides features to find and load save configuration files. * * This class supports the {@link ScreepsYamlConfig | SS3 Unified Credentials File} * format as well as the {@link ScreepsJsonConfig | screeps.json format} * used by many Screeps code upload tools. * @document ../guides/configuration.md * @category Common */ export declare class ScreepsConfigManager { private _defaultPaths?; /** * List all paths that will be searched by default for config files. * * If the `SCREEPS_CONFIG` environment variable is defined, this path * defined there will always be searched first. */ get defaultPaths(): readonly string[]; /** * Search for config files and load the first one found. * * If {@link LoadConfigOptions.file} is defined and non-empty, that path * will always be checked first. Otherwise, {@link defaultPaths} will be * checked in order until. * @param serverName the name of the server to use from the credential file * @param opts see {@link LoadConfigOptions} * @returns a valid {@link ScreepsHttpConfig} if one was found * @throws {@link node!Error | Error} if a file exists but the contents are invalid/malformed */ loadConfig(serverName: string, opts?: LoadConfigOptions): Promise; loadNormalizedConfig(file: string, serverName: string, opts?: LoadConfigOptions): Promise; loadFile(file: string): Promise; normalizeServersConfig(parsed: ScreepsJsonConfig | ScreepsYamlConfig, serverName: string): ScreepsServerConfig; normalizeServerConfig(rawServer: ScreepsRawServerConfig): ScreepsServerConfig; normalizeClientConfig(parsed: ScreepsJsonConfig | ScreepsYamlConfig, clientOpts?: string | Partial): ScreepsAppConfig; } /** * Configuration and options for {@link ScreepsHttpClient} * @category Common */ export interface ScreepsHttpConfig { /** @see {@link ScreepsAppConfig} */ app: ScreepsAppConfig; /** * Configuration for the Screeps World server to which this client * should connect */ server: Readonly; /** * The config file parsed (but not normalized) by {@link ScreepsConfigManager}. * Apps can use this to determine which other server names and client * configs are available. */ parsed?: ScreepsJsonConfig | ScreepsYamlConfig; } /** * Options used by {@link ScreepsConfigManager.loadConfig} * @category Common */ export interface LoadConfigOptions { /** * Specifies the path of the screeps YAML or JSON credential file to use. * If defined, this takes precedence over the `SCREEPS_CONFIG` env var. */ file?: string; /** * If this is a string and a YAML credential file is used, * {@link ScreepsClientConfig} will be pulled from the `configs[app]` key * in that file. */ app?: string | Partial; } /** * Normalized configuration for a single Screeps World server * @see {@link ScreepsRawServerConfig} for the pre-normalized schema * @category Common */ export interface ScreepsServerConfig { /** * The base URL for the API. Do not include `/api` in the path; * it will be appended automatically */ url: string; /** * The API authentication token to use with this server. * * If this is not provided, {@link email} and {@link password} must be set * instead. */ token?: string; /** * The email address or username with which to authenticate on this server. * * This is ignored if {@link token} is defined. * * If the server does not support email/pasword authentication * (ex: official servers), {@link token} must be used instead. */ email?: string; /** * The password with which to authenticate on this server. * * This is ignored if {@link token} is defined. * * If the server does not support email/pasword authentication * (ex: official servers), {@link token} must be used instead. */ password?: string; } /** * User-configurable options for {@link ScreepsHttpClient} and {@link ScreepsSocketClient}. * @see {@link DEFAULT_CLIENT_CONFIG} for default values * @category Common */ export interface ScreepsClientConfig { /** * Specifies a default shard name to use when one is not provided * as an argument to a {@link ScreepsHttpClient} endpoint function. */ defaultShard?: string; /** * Wait for a short period of time before automatically retriing * requests that fail due to the global 120 requests/minute rate limit. */ retry429Global: boolean; /** * Delay (in milliseconds) before the first retry attempt. * Only applies to retries for endpoint-specific rate limits. */ retry429InitDelay: number; /** * Maximum delay (in milliseconds) between retry attempts. * Only applies to retries for endpoint-specific rate limits. */ retry429MaxDelay: number; /** * Maximum number of retry attempts. Exponential backoff is used * to increase the delay between subsequent retry attempts. * Only applies to retries for endpoint-specific rate limits. */ retry429MaxRetries: number; /** * If enabled, {@link ScreepsSocketClient} will call {@link reconnect} * automatically when disconnected. */ wsReconnect: boolean; /** * If enabled, all previous subscriptions will be recreated * after successfully connecting (automatically or manually). */ wsResubscribe: boolean; /** * If enabled, ping the server every {@link wsKeepAliveInterval} to prevent * the connection from being closed. */ wsKeepAlive: boolean; /** Time (in milliseconds) between {@link wsKeepAlive} pings */ wsKeepAliveInterval: number; /** * The delay (in milliseconds) before the first retry attempt * in {@link ScreepsSocketClient.reconnect}. */ wsReconnectInitDelay: number; /** * The maximum delay (in milliseconds) before a retry attempt * in {@link ScreepsSocketClient.reconnect}. */ wsReconnectMaxDelay: number; /** * The maximum number of times {@link ScreepsSocketClient.connect} will be * called from {@link ScreepsSocketClient.reconnect} before giving up and * throwing an error. */ wsReconnectMaxRetries: number; } /** * An extension of {@link ScreepsClientConfig} that may contain properties * intended for the app using {@link ScreepsHttpClient}. * @category Common */ export type ScreepsAppConfig = ScreepsClientConfig & { [propertyName: string]: unknown; }; /** * Server configuration schema from {@link ScreepsJsonConfig}/{@link ScreepsYamlConfig}. * * {@link ScreepsConfigManager} will convert this into its normalized * form {@link ScreepsServerConfig} before using it. * @category Common */ export interface ScreepsRawServerConfig { /** * @see {@link ScreepsServerConfig.token} */ token?: string; /** * @see {@link ScreepsServerConfig.email} */ email?: string; /** * Treated as an alias of {@link email}. */ username?: string; /** * @see {@link ScreepsServerConfig.password} */ password?: string; /** * Protocol portion of {@link url}. * * This is ignored if {@link url} is defined. * @see {@link https://nodejs.org/api/url.html#urlprotocol | URL.protocol} */ protocol?: 'http' | 'https'; /** * If this is set and {@link protocol} is undefined, sets `protocol` to `https`. * * This is ignored if {@link url} is defined. */ secure?: boolean; /** * Treated as an alias of {@link hostname}. */ host?: string; /** * Host name portion of {@link url}. * * This is ignored if {@link url} is defined. * @see {@link https://nodejs.org/api/url.html#urlhostname | URL.hostname} */ hostname?: string; /** * Port portion of {@link url}. * * This is ignored if {@link url} is defined. * @see {@link https://nodejs.org/api/url.html#urlport | URL.port} */ port?: number | string; /** * Treated as an alias of {@link pathname}. */ path?: string; /** * Path portion of {@link url}. * * This is ignored if {@link url} is defined. * @see {@link https://nodejs.org/api/url.html#urlpathname | URL.pathname} */ pathname?: string; /** * @see {@link ScreepsServerConfig.url} */ url?: string; /** * Sets {@link pathname} to `/ptr`. On the screeps.com host, this is the path * of the Public Test Realm (PTR) server. * * This is ignored if {@link url}, {@link path}, or {@link pathname} is defined. */ ptr?: boolean; /** * Sets {@link pathname} to `/season`. On the screeps.com host, this is the path * of the Seasonal World server. * * This is ignored if {@link url}, {@link path}, or {@link pathname} is defined. */ season?: boolean; } /** * Format of a Screeps Unified Credentials File: * https://github.com/screepers/screepers-standards/blob/3877e86f38caed9891ef6270aa9690df556e6c22/SS3-Unified_Credentials_File.md * @category Common */ export interface ScreepsYamlConfig { servers: { [serverName: string]: ScreepsRawServerConfig | undefined; }; configs?: { [appName: string]: ScreepsClientConfig | undefined; }; } /** * Format of a Screeps JSON credentials file: * https://github.com/screepers/screeps-typescript-starter/blob/master/screeps.sample.json * @category Common */ export interface ScreepsJsonConfig { [serverName: string]: ScreepsRawServerConfig | undefined; } //# sourceMappingURL=ScreepsConfigManager.d.ts.map