Update schema documentation

This commit is contained in:
FoxxMD
2021-08-20 14:52:51 -04:00
parent 82a1a393de
commit cfb228de73
2 changed files with 65 additions and 5 deletions

View File

@@ -807,8 +807,19 @@ export interface ManagerStateChangeOption {
suppressNotification?: boolean
}
/**
* Configuration required to connect to a CM Server
* */
export interface BotConnection {
/**
* The hostname and port the CM Server is listening on EX `localhost:8085`
* */
host: string
/**
* The **shared secret** used to sign API calls from the Client to the Server.
*
* This value should be the same as what is specified in the target CM's `api.secret` configuration
* */
secret: string
}
@@ -864,7 +875,7 @@ export interface RedditCredentials {
/**
* Separate credentials for the web interface can be provided when also running the api.
*
* All properties not specified will default to values given in the top-level `credentials` property.
* All properties not specified will default to values given in ENV/ARG credential properties
*
* Refer to the [required credentials table](https://github.com/FoxxMD/context-mod/blob/master/docs/operatorConfiguration.md#minimum-required-configuration) to see what is necessary for the web interface.
*
@@ -900,7 +911,12 @@ export interface WebCredentials {
}
/**
* The configuration for an **individual reddit account** ContextMod will run as a bot
* The configuration for an **individual reddit account** ContextMod will run as a bot.
*
* Multiple bot configs may be specified (one per reddit account).
*
* **NOTE:** If `bots` is not specified in a `FILE` then a default `bot` is generated using `ENV/ARG` values IE `CLIENT_ID`, etc...but if `bots` IS specified the default is not generated.
*
* */
export interface BotInstanceJsonConfig {
credentials?: RedditCredentials
@@ -1251,6 +1267,13 @@ export interface OperatorJsonConfig {
* @examples [200]
* */
maxLogs?: number,
/**
* A list of CM Servers this Client should connect to.
*
* If not specified a default `BotConnection` for this instance is generated
*
* @examples [[{"host": "localhost:8095", "secret": "aRandomString"}]]
* */
clients?: BotConnection[]
credentials?: WebCredentials
@@ -1267,9 +1290,26 @@ export interface OperatorJsonConfig {
* */
operators?: string[]
}
/**
* Configuration for the **Server** application. See [Architecture Documentation](https://github.com/FoxxMD/context-mod/blob/master/docs/serverClientArchitecture.md) for more info
* */
api?: {
/**
* The port the server listens on for API requests
*
* @default 8095
* @examples [8095]
* */
port?: number,
/**
* The **shared secret** used to verify API requests come from an authenticated client.
*
* Use this same value for the `secret` value in a `BotConnection` object to connect to this Server
* */
secret?: string,
/**
* A friendly name for this server. This will override `friendly` in `BotConnection` if specified.
* */
friendly?: string,
}
}

View File

@@ -2,11 +2,14 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"BotConnection": {
"description": "Configuration required to connect to a CM Server",
"properties": {
"host": {
"description": "The hostname and port the CM Server is listening on EX `localhost:8085`",
"type": "string"
},
"secret": {
"description": "The **shared secret** used to sign API calls from the Client to the Server.\n\nThis value should be the same as what is specified in the target CM's `api.secret` configuration",
"type": "string"
}
},
@@ -17,7 +20,7 @@
"type": "object"
},
"BotInstanceJsonConfig": {
"description": "The configuration for an **individual reddit account** ContextMod will run as a bot",
"description": "The configuration for an **individual reddit account** ContextMod will run as a bot.\n\nMultiple bot configs may be specified (one per reddit account).\n\n**NOTE:** If `bots` is not specified in a `FILE` then a default `bot` is generated using `ENV/ARG` values IE `CLIENT_ID`, etc...but if `bots` IS specified the default is not generated.",
"properties": {
"caching": {
"description": "Settings to configure the default caching behavior for each suberddit",
@@ -460,7 +463,7 @@
"type": "object"
},
"WebCredentials": {
"description": "Separate credentials for the web interface can be provided when also running the api.\n\nAll properties not specified will default to values given in the top-level `credentials` property.\n\nRefer to the [required credentials table](https://github.com/FoxxMD/context-mod/blob/master/docs/operatorConfiguration.md#minimum-required-configuration) to see what is necessary for the web interface.",
"description": "Separate credentials for the web interface can be provided when also running the api.\n\nAll properties not specified will default to values given in ENV/ARG credential properties\n\nRefer to the [required credentials table](https://github.com/FoxxMD/context-mod/blob/master/docs/operatorConfiguration.md#minimum-required-configuration) to see what is necessary for the web interface.",
"examples": [
{
"clientId": "f4b4df1_9oiu",
@@ -497,14 +500,22 @@
"description": "Configuration for application-level settings IE for running the bot instance\n\n* To load a JSON configuration **from the command line** use the `-c` cli argument EX: `node src/index.js -c /path/to/JSON/config.json`\n* To load a JSON configuration **using an environmental variable** use `OPERATOR_CONFIG` EX: `OPERATOR_CONFIG=/path/to/JSON/config.json`",
"properties": {
"api": {
"description": "Configuration for the **Server** application. See [Architecture Documentation](https://github.com/FoxxMD/context-mod/blob/master/docs/serverClientArchitecture.md) for more info",
"properties": {
"friendly": {
"description": "A friendly name for this server. This will override `friendly` in `BotConnection` if specified.",
"type": "string"
},
"port": {
"default": 8095,
"description": "The port the server listens on for API requests",
"examples": [
8095
],
"type": "number"
},
"secret": {
"description": "The **shared secret** used to verify API requests come from an authenticated client.\n\nUse this same value for the `secret` value in a `BotConnection` object to connect to this Server",
"type": "string"
}
},
@@ -595,6 +606,15 @@
"description": "Settings for the web interface",
"properties": {
"clients": {
"description": "A list of CM Servers this Client should connect to.\n\nIf not specified a default `BotConnection` for this instance is generated",
"examples": [
[
{
"host": "localhost:8095",
"secret": "aRandomString"
}
]
],
"items": {
"$ref": "#/definitions/BotConnection"
},
@@ -602,7 +622,7 @@
},
"credentials": {
"$ref": "#/definitions/WebCredentials",
"description": "Separate credentials for the web interface can be provided when also running the api.\n\nAll properties not specified will default to values given in the top-level `credentials` property.\n\nRefer to the [required credentials table](https://github.com/FoxxMD/context-mod/blob/master/docs/operatorConfiguration.md#minimum-required-configuration) to see what is necessary for the web interface.",
"description": "Separate credentials for the web interface can be provided when also running the api.\n\nAll properties not specified will default to values given in ENV/ARG credential properties\n\nRefer to the [required credentials table](https://github.com/FoxxMD/context-mod/blob/master/docs/operatorConfiguration.md#minimum-required-configuration) to see what is necessary for the web interface.",
"examples": [
{
"clientId": "f4b4df1_9oiu",