UNPKG

onebots

Version:

OneBots 整合适配器和协议,提供HTTP/WebSocket服务

81 lines 4.53 kB
import { BaseAppConfigSchema, AdapterRegistry, ProtocolRegistry } from '@onebots/core'; import { ADAPTER_SCHEMA_PRESETS } from './adapter-schema-presets.js'; /** * App 层配置 Schema(可在此扩展) */ const base = BaseAppConfigSchema; const withLabel = (key, label, description) => { return { ...base[key], label, description, }; }; const general = { 'onebot.v11': { use_http: { type: 'boolean', default: true, label: '启用 HTTP' }, use_ws: { type: 'boolean', default: true, label: '启用 WebSocket' }, access_token: { type: 'string', default: '', label: 'Access Token' }, secret: { type: 'string', default: '', label: 'Secret' }, enable_cors: { type: 'boolean', default: true, label: '启用 CORS' }, heartbeat_interval: { type: 'number', default: 5, min: 1, label: '心跳间隔(秒)' }, http_reverse: { type: 'array', default: [], label: 'HTTP 反向上报地址' }, ws_reverse: { type: 'array', default: [], label: 'WS 反向连接地址' }, }, 'onebot.v12': { use_http: { type: 'boolean', default: true, label: '启用 HTTP' }, use_ws: { type: 'boolean', default: true, label: '启用 WebSocket' }, access_token: { type: 'string', default: '', label: 'Access Token' }, secret: { type: 'string', default: '', label: 'Secret' }, enable_cors: { type: 'boolean', default: true, label: '启用 CORS' }, heartbeat_interval: { type: 'number', default: 5, min: 1, label: '心跳间隔(秒)' }, webhooks: { type: 'array', default: [], label: 'Webhook 上报地址' }, ws_reverse: { type: 'array', default: [], label: 'WS 反向连接地址' }, request_timeout: { type: 'number', default: 15, min: 1, label: '请求超时(秒)' }, }, 'satori.v1': { use_http: { type: 'boolean', default: true, label: '启用 HTTP' }, use_ws: { type: 'boolean', default: true, label: '启用 WebSocket' }, token: { type: 'string', default: '', label: 'Token' }, platform: { type: 'string', default: 'unknown', label: '平台标识' }, webhooks: { type: 'array', default: [], label: 'Webhook 上报地址' }, }, 'milky.v1': { use_http: { type: 'boolean', default: true, label: '启用 HTTP' }, use_ws: { type: 'boolean', default: true, label: '启用 WebSocket' }, access_token: { type: 'string', default: '', label: 'Access Token' }, secret: { type: 'string', default: '', label: 'Secret' }, heartbeat: { type: 'number', default: 5, min: 1, label: '心跳间隔(秒)' }, http_reverse: { type: 'array', default: [], label: 'HTTP 反向上报地址' }, ws_reverse: { type: 'array', default: [], label: 'WS 反向连接地址' }, }, }; const baseWithLabels = { port: withLabel('port', '监听端口', '服务监听端口,范围 1-65535'), path: withLabel('path', '服务路径前缀', 'HTTP 服务前缀路径,可为空'), database: withLabel('database', '数据库文件', '数据库文件名或路径'), timeout: withLabel('timeout', '登录超时(秒)', '账号登录超时秒数'), username: withLabel('username', '管理端用户名', 'Web 管理端登录用户名(与鉴权码二选一)'), password: withLabel('password', '管理端密码', 'Web 管理端登录密码(与鉴权码二选一)'), access_token: withLabel('access_token', '管理端鉴权码', 'Bearer 鉴权码,配置后可使用 Authorization: Bearer <鉴权码> 访问 API,无需用户名密码'), log_level: withLabel('log_level', '日志等级', 'trace | debug | info | warn | error | fatal | mark | off'), public_static_dir: withLabel('public_static_dir', '站点根静态目录', '相对配置文件目录或绝对路径,用于企业微信等可信域名校验文件(站点根路径 GET);留空不启用。Docker:配置 static 并将校验文件放入挂载卷内 /data/static'), }; export const getAppConfigSchema = () => { const protocols = { ...general, ...ProtocolRegistry.getAllSchemas(), }; // 预设补全未 -r 加载的适配器 schema,供 Web 配置页使用;已加载时以 Registry 为准(覆盖预设) const adapters = { ...ADAPTER_SCHEMA_PRESETS, ...AdapterRegistry.getAllSchemas(), }; return { base: baseWithLabels, general, protocols, adapters, }; }; //# sourceMappingURL=config-schema.js.map