Skip to content

Commit

Permalink
feat(core): enhance some config schema
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jul 30, 2022
1 parent f6f6f60 commit 40c7440
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"dependencies": {
"@koishijs/utils": "^6.0.0",
"@satorijs/core": "^1.0.4",
"@satorijs/core": "^1.0.6",
"cordis": "^2.0.6",
"fastest-levenshtein": "^1.0.12",
"minato": "^1.2.3"
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ export namespace Context {
prefix: Schema.union([
Schema.array(String),
Schema.transform(String, (prefix) => [prefix]),
] as const).default(['']).description('指令前缀字符,可以是字符串或字符串数组。将用于指令前缀的匹配。'),
] as const).default(['']).description('指令前缀字符构成的数组。将被用于指令的匹配。'),
nickname: Schema.union([
Schema.array(String),
Schema.transform(String, (nickname) => [nickname]),
] as const).description('机器人的昵称,可以是字符串或字符串数组。将用于指令前缀的匹配。'),
] as const).description('机器人昵称构成的数组。将被用于指令的匹配。'),
autoAssign: Schema.union([Boolean, Function]).default(true).description('当获取不到频道数据时,是否使用接受者作为代理者。'),
autoAuthorize: Schema.union([Schema.natural(), Function]).default(1).description('当获取不到用户数据时默认使用的权限等级。'),
}).description('基础设置'))
Expand Down
2 changes: 1 addition & 1 deletion packages/koishi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"dependencies": {
"@koishijs/core": "^4.8.2",
"@koishijs/utils": "^6.0.0",
"@satorijs/satori": "^1.0.4",
"@satorijs/satori": "^1.0.6",
"file-type": "^16.5.3",
"ns-require": "^1.1.4"
}
Expand Down
4 changes: 3 additions & 1 deletion packages/koishi/src/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ declare module '@koishijs/core' {
}
}

Context.service('assets')

defineProperty(Context.Config, 'Assets', Schema.object({
whitelist: Schema.array(Schema.string().required().role('url')).description('不处理的白名单 URL 列表。'),
whitelist: Schema.array(Schema.string().required().role('link')).description('不处理的白名单 URL 列表。'),
}).description('资源设置'))

const PROTOCOL_BASE64 = 'base64://'
Expand Down
7 changes: 3 additions & 4 deletions packages/koishi/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ Context.Config.list.push(Schema.object({
assets: Context.Config.Assets,
}))

Context.Config.list.push(Quester.Config)

Context.service('assets')
Context.service('cache')
Context.Config.list.push(Schema.object({
request: Quester.Config,
}))
2 changes: 1 addition & 1 deletion plugins/assets/local/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ namespace LocalAssets {
export const Config: Schema<Config> = Schema.object({
root: Schema.string().description('本地存储资源文件的绝对路径。'),
path: Schema.string().default('/files').description('静态图片暴露在服务器的路径。'),
selfUrl: Schema.string().role('url').description('Koishi 服务暴露在公网的地址。缺省时将使用全局配置。'),
selfUrl: Schema.string().role('link').description('Koishi 服务暴露在公网的地址。缺省时将使用全局配置。'),
secret: Schema.string().description('用于验证上传者的密钥,配合 assets-remote 使用。').role('secret'),
})
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/assets/remote/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace RemoteAssets {
}

export const Config: Schema<Config> = Schema.object({
endpoint: Schema.string().role('url').description('远程服务器地址。').required(),
endpoint: Schema.string().role('link').description('远程服务器地址。').required(),
secret: Schema.string().description('服务器设置的密钥,配合 assets-local 使用。').role('secret'),
})
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/assets/s3/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ namespace S3Assets {

export const Config: Schema<Config> = Schema.object({
region: Schema.string().default('none'),
endpoint: Schema.string().role('url'),
endpoint: Schema.string().role('link'),
credentials: Credentials,
bucket: Schema.string().required(),
pathPrefix: Schema.string().default(''),
Expand Down

0 comments on commit 40c7440

Please sign in to comment.