Skip to content

Commit

Permalink
refa: upgrade schema, removing as const
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jun 19, 2023
1 parent 5710bf2 commit c290fd5
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions adapters/discord/src/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,14 +327,14 @@ export namespace DiscordMessenger {

export const Config: Schema<DiscordMessenger.Config> = Schema.object({
handleExternalAsset: Schema.union([
Schema.const('download' as const).description('先下载后发送'),
Schema.const('direct' as const).description('直接发送链接'),
Schema.const('auto' as const).description('发送一个 HEAD 请求,根据返回的 Content-Type 决定发送方式'),
Schema.const('download').description('先下载后发送'),
Schema.const('direct').description('直接发送链接'),
Schema.const('auto').description('发送一个 HEAD 请求,根据返回的 Content-Type 决定发送方式'),
]).role('radio').description('发送外链资源时采用的方式。').default('auto'),
handleMixedContent: Schema.union([
Schema.const('separate' as const).description('将每个不同形式的内容分开发送'),
Schema.const('attach' as const).description('图片前如果有文本内容,则将文本作为图片的附带信息进行发送'),
Schema.const('auto' as const).description('如果图片本身采用直接发送则与前面的文本分开,否则将文本作为图片的附带信息发送'),
Schema.const('separate').description('将每个不同形式的内容分开发送'),
Schema.const('attach').description('图片前如果有文本内容,则将文本作为图片的附带信息进行发送'),
Schema.const('auto').description('如果图片本身采用直接发送则与前面的文本分开,否则将文本作为图片的附带信息发送'),
]).role('radio').description('发送图文等混合内容时采用的方式。').default('auto'),
}).description('发送设置')
}
2 changes: 1 addition & 1 deletion adapters/kook/src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export namespace HttpServer {
}

export const Config: Schema<Config> = Schema.object({
protocol: Schema.const('http' as const).required(),
protocol: Schema.const('http').required(),
path: Schema.string().description('服务器监听的路径。').default('/kook'),
token: Schema.string().description('机器人的用户令牌。').role('secret').required(),
verifyToken: Schema.string().description('机器人的验证令牌。').role('secret').required(),
Expand Down
6 changes: 3 additions & 3 deletions adapters/kook/src/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ export namespace KookMessenger {

export const Config: Schema<KookMessenger.Config> = Schema.object({
handleMixedContent: Schema.union([
Schema.const('separate' as const).description('将每个不同形式的内容分开发送'),
Schema.const('card' as const).description('使用卡片发送内容'),
Schema.const('mixed' as const).description('使用混合模式发送内容'),
Schema.const('separate').description('将每个不同形式的内容分开发送'),
Schema.const('card').description('使用卡片发送内容'),
Schema.const('mixed').description('使用混合模式发送内容'),
]).role('radio').description('发送图文等混合内容时采用的方式。').default('separate'),
}).description('发送设置')
}
2 changes: 1 addition & 1 deletion adapters/kook/src/ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export namespace WsClient {

export const Config: Schema<Config> = Schema.intersect([
Schema.object({
protocol: Schema.const('ws' as const).required(process.env.KOISHI_ENV !== 'browser'),
protocol: Schema.const('ws').required(process.env.KOISHI_ENV !== 'browser'),
token: Schema.string().description('机器人的用户令牌。').role('secret').required(),
}),
Adapter.WsClient.Config,
Expand Down
2 changes: 1 addition & 1 deletion adapters/onebot/src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export namespace HttpServer {

export const Config: Schema<Config> = Schema.intersect([
Schema.object({
protocol: Schema.const('http' as const).required(),
protocol: Schema.const('http').required(),
path: Schema.string().description('服务器监听的路径。').default('/onebot'),
secret: Schema.string().description('接收事件推送时用于验证的字段,应该与 OneBot 的 secret 配置保持一致。').role('secret'),
}).description('连接设置'),
Expand Down
4 changes: 2 additions & 2 deletions adapters/onebot/src/ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export namespace WsClient {

export const Config: Schema<Config> = Schema.intersect([
Schema.object({
protocol: Schema.const('ws' as const).required(process.env.KOISHI_ENV !== 'browser'),
protocol: Schema.const('ws').required(process.env.KOISHI_ENV !== 'browser'),
responseTimeout: Schema.natural().role('time').default(Time.minute).description('等待响应的时间 (单位为毫秒)。'),
}).description('连接设置'),
Quester.createConfig(true),
Expand Down Expand Up @@ -71,7 +71,7 @@ export namespace WsServer {
}

export const Config: Schema<Config> = Schema.object({
protocol: Schema.const('ws-reverse' as const).required(process.env.KOISHI_ENV === 'browser'),
protocol: Schema.const('ws-reverse').required(process.env.KOISHI_ENV === 'browser'),
path: Schema.string().description('服务器监听的路径。').default('/onebot'),
responseTimeout: Schema.natural().role('time').default(Time.minute).description('等待响应的时间 (单位为毫秒)。'),
}).description('连接设置')
Expand Down
2 changes: 1 addition & 1 deletion adapters/telegram/src/polling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export namespace HttpPolling {
}

export const Config: Schema<Config> = Schema.object({
protocol: Schema.const('polling' as const).required(process.env.KOISHI_ENV !== 'browser'),
protocol: Schema.const('polling').required(process.env.KOISHI_ENV !== 'browser'),
pollingTimeout: Schema.natural().role('ms').default(Time.second * 25).description('通过长轮询获取更新时请求的超时 (单位为毫秒)。'),
retryTimes: Schema.natural().description('初次连接时的最大重试次数。').default(6),
retryInterval: Schema.natural().role('ms').default(Time.second * 5).description('长轮询断开后的重试时间间隔 (单位为毫秒)。'),
Expand Down
2 changes: 1 addition & 1 deletion adapters/telegram/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export namespace HttpServer {
}

export const Config: Schema<Config> = Schema.object({
protocol: Schema.const('server' as const).required(),
protocol: Schema.const('server').required(),
path: Schema.string().description('服务器监听的路径。').default('/telegram'),
selfUrl: Schema.string().role('link').description('服务器暴露在公网的地址。缺省时将使用全局配置。'),
})
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@
"cosmokit": "^1.4.2",
"ws": "^8.13.0",
"reggol": "^1.4.2",
"schemastery": "^3.9.0"
"schemastery": "^3.10.0"
}
}

0 comments on commit c290fd5

Please sign in to comment.