Skip to content

Commit

Permalink
feat: bundle configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
SaarChaffee committed Dec 5, 2023
1 parent 3f36ca1 commit 4c676a4
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,29 @@ export interface Config {
* @see https://developer.hitokoto.cn/sentence/#%E5%8F%A5%E5%AD%90%E7%B1%BB%E5%9E%8B-%E5%8F%82%E6%95%B0
*/
defaultTypes?: string[]
bundleEndpoint?: { endpoint: string } | string
endpoint?: string
cache?: number
}

export const Config: Schema<Config> = Schema.object({

Check failure on line 21 in src/config.ts

View workflow job for this annotation

GitHub Actions / test (4.11)

Type 'Schema<ObjectS<{ readonly apiUrl: Schema<string, string>; readonly minLength: Schema<number, number>; readonly maxLength: Schema<number, number>; readonly defaultTypes: Schema<...>; readonly bundleEndpoint: Schema<...>; readonly cache: Schema<...>; }>, ObjectT<...>>' is not assignable to type 'Schema<Config>'.

Check failure on line 21 in src/config.ts

View workflow job for this annotation

GitHub Actions / test (4.12)

Type 'Schema<ObjectS<{ readonly apiUrl: Schema<string, string>; readonly minLength: Schema<number, number>; readonly maxLength: Schema<number, number>; readonly defaultTypes: Schema<...>; readonly bundleEndpoint: Schema<...>; readonly cache: Schema<...>; }>, ObjectT<...>>' is not assignable to type 'Schema<Config>'.

Check failure on line 21 in src/config.ts

View workflow job for this annotation

GitHub Actions / test (4.13)

Type 'Schema<ObjectS<{ readonly apiUrl: Schema<string, string>; readonly minLength: Schema<number, number>; readonly maxLength: Schema<number, number>; readonly defaultTypes: Schema<...>; readonly bundleEndpoint: Schema<...>; readonly cache: Schema<...>; }>, ObjectT<...>>' is not assignable to type 'Schema<Config>'.

Check failure on line 21 in src/config.ts

View workflow job for this annotation

GitHub Actions / test (4.14)

Type 'Schema<ObjectS<{ readonly apiUrl: Schema<string, string>; readonly minLength: Schema<number, number>; readonly maxLength: Schema<number, number>; readonly defaultTypes: Schema<...>; readonly bundleEndpoint: Schema<...>; readonly cache: Schema<...>; }>, ObjectT<...>>' is not assignable to type 'Schema<Config>'.

Check failure on line 21 in src/config.ts

View workflow job for this annotation

GitHub Actions / test (4.15)

Type 'Schema<ObjectS<{ readonly apiUrl: Schema<string, string>; readonly minLength: Schema<number, number>; readonly maxLength: Schema<number, number>; readonly defaultTypes: Schema<...>; readonly bundleEndpoint: Schema<...>; readonly cache: Schema<...>; }>, ObjectT<...>>' is not assignable to type 'Schema<Config>'.
apiUrl: Schema.string().description('获取一言的 API 地址').default('https://v1.hitokoto.cn'),
minLength: Schema.number().description('一言的最小长度'),
maxLength: Schema.number().description('一言的最大长度'),
defaultTypes: Schema.array(Schema.string()).description('默认一言类别'),
bundleEndpoint: Schema.union([
Schema.const('https://cdn.jsdelivr.net/gh/hitokoto-osc/sentences-bundle@latest/').description('JSDelivr'),
Schema.const('https://raw.githubusercontent.com/hitokoto-osc/sentences-bundle/master/').description('Github Raw'),
Schema.const('https://ghproxy.com/https://raw.githubusercontent.com/hitokoto-osc/sentences-bundle/master/')
.description('Ghproxy 反代的 Github Raw'),
Schema.const('https://sentences-bundle.hitokoto.cn/').description('一言官网'),
Schema.object({
endpoint: Schema.string().required().description('语料库'),
}).description('自定义'),
]).description('一言语料库来源').default('https://cdn.jsdelivr.net/gh/hitokoto-osc/sentences-bundle@latest/'),
cache: Schema.union([
Schema.const(1).description('使用 cache 服务'),
Schema.const(2).description('使用数据库持久化存储'),
Schema.const(3).description('本地 JSON 文件'),
]).description('语料库缓存策略').default(3),
})

0 comments on commit 4c676a4

Please sign in to comment.