@aalis/schema-config 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ace Nyan <ace@acenyan.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # @aalis/schema-config
2
+
3
+ 配置表单 Schema 词汇契约包:`ConfigSchema` / `SchemaField` / `SchemaGroup` / `SchemaArray` 及 `SchemaFieldTypes` 扩展点。
4
+
5
+ `@aalis/core` 把插件的 `configSchema` 当作 opaque 数据透传、不解释任何字段;表单词汇(label / options / textarea …)属呈现层,统一住在本包。插件用它给自己的 `configSchema` 做形状检查,渲染宿主(WebUI)与宿主政策(runtime 的配置同步)用它消费 schema。
6
+
7
+ 零依赖、纯类型 + 纯数据。字段类型可由其他 api 包经 declaration merging 扩展(如 `api-llm` 注入 `'llm-ref'`)。
8
+
9
+ ## 消费方式:用宽区间,别用 caret
10
+
11
+ 仓内五十余个包这样依赖本包(与 `@aalis/core` 的 peerDep 同一风格):
12
+
13
+ ```jsonc
14
+ "dependencies": { "@aalis/schema-config": "workspace:>=0.9.0 <1.0.0" }
15
+ ```
16
+
17
+ 发布时该区间**原样保留**(实测 `pnpm pack` 产物即 `>=0.9.0 <1.0.0`),本地仍照常 link 到 workspace。
18
+
19
+ **不要用 caret。** 0.x 的 caret(`^0.9.0` = `>=0.9.0 <0.10.0`)锁死 minor:本包加一个字段类型
20
+ 就是一次 minor,届时所有已发布消费者的范围会拒收新版,node_modules 里出现两份副本——而
21
+ declaration merging 是按模块副本生效的,`SchemaFieldTypes` / `SchemaField` 的合并面会就此裂开
22
+ (一份合并了 `'llm-ref'`,另一份没有)。宽区间让整个 0.x 段自由流动,加词汇零级联。
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Schema 字段类型注册表 —— declaration merging 扩展点。
3
+ *
4
+ * 本包只内置基础类型;带业务语义的类型由对应 api 包合并声明
5
+ * (如 `'llm-ref'` 由 @aalis/api-llm 注入)。key 即类型名,value 恒为 true。
6
+ *
7
+ * ```ts
8
+ * declare module '@aalis/schema-config' {
9
+ * interface SchemaFieldTypes {
10
+ * 'llm-ref': true;
11
+ * }
12
+ * }
13
+ * ```
14
+ */
15
+ export interface SchemaFieldTypes {
16
+ string: true;
17
+ number: true;
18
+ boolean: true;
19
+ select: true;
20
+ multiselect: true;
21
+ textarea: true;
22
+ }
23
+ export type SchemaFieldType = keyof SchemaFieldTypes & string;
24
+ /**
25
+ * 单个配置字段。
26
+ *
27
+ * 只声明所有渲染宿主共需的字段;单一宿主的交互属性
28
+ * (如 `secret` / `dynamicOptions` / `allowCustom`)由消费它们的宿主 api 包
29
+ * (@aalis/api-webui)通过 declaration merging 注入。
30
+ */
31
+ export interface SchemaField {
32
+ type: SchemaFieldType;
33
+ label: string;
34
+ description?: string;
35
+ default?: unknown;
36
+ required?: boolean;
37
+ /** select / multiselect 类型的静态选项 */
38
+ options?: Array<{
39
+ label: string;
40
+ value: string | number;
41
+ }>;
42
+ }
43
+ export interface SchemaGroup {
44
+ label?: string;
45
+ description?: string;
46
+ fields: Record<string, SchemaField>;
47
+ }
48
+ /** 数组 Schema:对象数组,每个元素用 items 描述其字段结构 */
49
+ export interface SchemaArray {
50
+ type: 'array';
51
+ label: string;
52
+ description?: string;
53
+ /** 数组每个元素的字段定义 */
54
+ items: Record<string, SchemaField>;
55
+ default?: unknown[];
56
+ }
57
+ /** 配置 Schema:顶层 key 可以是字段、分组或数组 */
58
+ export type ConfigSchema = Record<string, SchemaField | SchemaGroup | SchemaArray>;
59
+ /**
60
+ * core 基础设施配置(name / logLevel)的表单描述。
61
+ *
62
+ * core 自身不持有任何 schema——这份呈现层描述由本包代管,
63
+ * 渲染宿主(webui-server 设置页)从这里取。
64
+ */
65
+ export declare const CORE_CONFIG_SCHEMA: ConfigSchema;
66
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,IAAI,CAAC;IACb,MAAM,EAAE,IAAI,CAAC;IACb,OAAO,EAAE,IAAI,CAAC;IACd,MAAM,EAAE,IAAI,CAAC;IACb,WAAW,EAAE,IAAI,CAAC;IAClB,QAAQ,EAAE,IAAI,CAAC;CAChB;AAED,MAAM,MAAM,eAAe,GAAG,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAE9D;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,eAAe,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mCAAmC;IACnC,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC,CAAC;CAC5D;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;CACrC;AAED,yCAAyC;AACzC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;CACrB;AAED,mCAAmC;AACnC,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,GAAG,WAAW,CAAC,CAAC;AAEnF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,EAAE,YAchC,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,36 @@
1
+ // ============================================================
2
+ // @aalis/schema-config — 配置表单 Schema 词汇契约
3
+ //
4
+ // 这里的类型描述"配置如何呈现为表单"(label / options / textarea …),
5
+ // 是**呈现层词汇**,因此不属于 @aalis/core——core 只把 `PluginModule.configSchema`
6
+ // 当作 opaque 数据透传,不解释任何字段。
7
+ //
8
+ // 消费方:
9
+ // - 插件:`export const configSchema: ConfigSchema = {...}` 获得形状检查
10
+ // - 渲染宿主(webui-server/client 等):读取并渲染表单
11
+ // - 宿主政策(@aalis/runtime 的 config-sync):按 schema 裁剪未知字段
12
+ //
13
+ // 本包零依赖、纯类型 + 纯数据,不 import @aalis/core。
14
+ // ============================================================
15
+ /**
16
+ * core 基础设施配置(name / logLevel)的表单描述。
17
+ *
18
+ * core 自身不持有任何 schema——这份呈现层描述由本包代管,
19
+ * 渲染宿主(webui-server 设置页)从这里取。
20
+ */
21
+ export const CORE_CONFIG_SCHEMA = {
22
+ name: { type: 'string', label: '应用名称', description: '应用显示名称,用于日志和界面展示', default: 'Aalis' },
23
+ logLevel: {
24
+ type: 'select',
25
+ label: '日志等级',
26
+ description: '日志输出等级',
27
+ default: 'info',
28
+ options: [
29
+ { label: 'debug', value: 'debug' },
30
+ { label: 'info', value: 'info' },
31
+ { label: 'warn', value: 'warn' },
32
+ { label: 'error', value: 'error' },
33
+ ],
34
+ },
35
+ };
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,0CAA0C;AAC1C,EAAE;AACF,oDAAoD;AACpD,oEAAoE;AACpE,0BAA0B;AAC1B,EAAE;AACF,OAAO;AACP,gEAAgE;AAChE,wCAAwC;AACxC,uDAAuD;AACvD,EAAE;AACF,wCAAwC;AACxC,+DAA+D;AA+D/D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAiB;IAC9C,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,kBAAkB,EAAE,OAAO,EAAE,OAAO,EAAE;IAC1F,QAAQ,EAAE;QACR,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,MAAM;QACb,WAAW,EAAE,QAAQ;QACrB,OAAO,EAAE,MAAM;QACf,OAAO,EAAE;YACP,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;YAClC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;YAChC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;YAChC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;SACnC;KACF;CACF,CAAC"}
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@aalis/schema-config",
3
+ "version": "0.9.0",
4
+ "license": "MIT",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/AalisLabs/Aalis.git",
8
+ "directory": "packages/schema-config"
9
+ },
10
+ "author": "Ace Nyan <ace@acenyan.com>",
11
+ "bugs": {
12
+ "url": "https://github.com/AalisLabs/Aalis/issues"
13
+ },
14
+ "homepage": "https://github.com/AalisLabs/Aalis#readme",
15
+ "type": "module",
16
+ "main": "dist/index.js",
17
+ "types": "dist/index.d.ts",
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "devDependencies": {
22
+ "typescript": "^5.7.0"
23
+ },
24
+ "aalis": {
25
+ "types": true
26
+ },
27
+ "keywords": [
28
+ "aalis",
29
+ "aalis-schema"
30
+ ],
31
+ "scripts": {
32
+ "build": "tsc",
33
+ "dev": "tsc --watch"
34
+ }
35
+ }