import type { ExpressionOrValue } from '../expression.js'; import type { ConditionExpression } from './argument.js'; /** 参数界面装饰 */ export interface ParameterDecorationBase { /** 参数装饰类型 */ type: T; /** 布局时占用的位置 */ span?: number; /** 装饰可见的条件表达式 */ condition?: ConditionExpression; } /** 参数标签装饰 */ export interface ParameterLabelDecoration extends ParameterDecorationBase<'label'> { /** 标签文本 */ label: ExpressionOrValue; } /** 参数界面装饰映射 */ export interface ParameterDecorationMap { /** 参数标签装饰 */ label: ParameterLabelDecoration; } /** 参数界面装饰 type */ export type ParameterDecorationType = keyof ParameterDecorationMap; /** 参数界面装饰 */ export type ParameterDecoration = ParameterDecorationMap[ParameterDecorationType]; /** 是否为参数界面装饰 */ export function isParameterDecoration(value: unknown): value is ParameterDecoration { if (value == null || typeof value != 'object') return false; const v = value as ParameterDecoration; if ('key' in v || 'name' in v || 'description' in v) return false; return typeof v.type == 'string' && v.type.length > 0; }