import type { ConditionExpression } from './argument.js'; import type { ParameterDecoration } from './parameter-decoration.js'; import type { Parameter } from './parameter.js'; /** 参数分组的公共属性 */ interface ParameterGroupBase { /** 分组可见的条件表达式 */ condition?: ConditionExpression; /** 布局时占用的位置 */ span?: number; } /** 装饰分组 */ export interface ParameterDecorationGroup extends ParameterGroupBase { /** 装饰列表 */ items: ParameterDecoration[]; } /** 判断是否为装饰分组 */ export function isParameterDecorationGroup(value: unknown): value is ParameterDecorationGroup { if (value == null || typeof value !== 'object') return false; const v = value as ParameterDecorationGroup; if ('key' in v || 'name' in v || 'description' in v || 'value' in v) return false; return Array.isArray(v.items); } /** 参数分组 */ export interface ParameterGroup extends ParameterGroupBase { /** 名称 */ name: string; /** 详细描述 */ description: string; /** 包含的参数列表 */ items: Parameter[]; /** 装饰 */ before?: ParameterDecorationGroup; /** 装饰 */ after?: ParameterDecorationGroup; } /** 判断是否为参数分组 */ export function isParameterGroup(item: unknown): item is ParameterGroup { if (item == null || typeof item !== 'object') return false; const v = item as ParameterGroup; if ('key' in v || 'value' in v) return false; return typeof v.name === 'string' && typeof v.description === 'string' && Array.isArray(v.items); }