@ a2ui- sdk/ 类型
A2UI协议的TypeScript类型定义. 这个包提供了与A2UI消息,组件和数据模型合作所需的所有类型定义.
安装
npm install @a2ui-sdk/types
使用量
v0.9 (最晚) (中文(简体) )
import type {
// Message types
A2UIMessage,
CreateSurfacePayload,
UpdateComponentsPayload,
UpdateDataModelPayload,
DeleteSurfacePayload,
// Component types
Component,
TextComponent,
ImageComponent,
IconComponent,
VideoComponent,
AudioPlayerComponent,
DividerComponent,
RowComponent,
ColumnComponent,
ListComponent,
CardComponent,
TabsComponent,
ModalComponent,
ButtonComponent,
TextFieldComponent,
CheckBoxComponent,
ChoicePickerComponent,
SliderComponent,
DateTimeInputComponent,
// Value types
DynamicValue,
DynamicString,
DynamicNumber,
DynamicBoolean,
DynamicStringList,
ChildList,
TemplateBinding,
// Action types
Action,
ActionPayload,
ActionHandler,
// Validation types
CheckRule,
Checkable,
ValidationResult,
// State types
ScopeValue,
DataModel,
} from '@a2ui-sdk/types/0.9'
v. 0.8 (中文(简体) )
import type {
// Message types
A2UIMessage,
BeginRenderingPayload,
SurfaceUpdatePayload,
DataModelUpdatePayload,
DeleteSurfacePayload,
// Core types
Surface,
SurfaceStyles,
ComponentDefinition,
ComponentProps,
ValueSource,
DataModel,
DataModelValue,
DataEntry,
// Children types
ChildrenDefinition,
TemplateBinding,
// Action types
Action,
ActionPayload,
ActionHandler,
ActionContextItem,
// Component props
BaseComponentProps,
TextComponentProps,
ImageComponentProps,
IconComponentProps,
VideoComponentProps,
AudioPlayerComponentProps,
DividerComponentProps,
RowComponentProps,
ColumnComponentProps,
ListComponentProps,
CardComponentProps,
TabsComponentProps,
ModalComponentProps,
ButtonComponentProps,
CheckBoxComponentProps,
TextFieldComponentProps,
DateTimeInputComponentProps,
MultipleChoiceComponentProps,
SliderComponentProps,
// Layout types
Distribution,
Alignment,
// State types
ScopeValue,
} from '@a2ui-sdk/types/0.8'
命名空间导入
import { v0_8, v0_9 } from '@a2ui-sdk/types'
// Use v0.9 types
type Message = v0_9.A2UIMessage
密钥类型
A2UIMessage (v0.9) (英语)
从服务器发送到客户端的信件 :
type A2UIMessage =
| { createSurface: CreateSurfacePayload }
| { updateComponents: UpdateComponentsPayload }
| { updateDataModel: UpdateDataModelPayload }
| { deleteSurface: DeleteSurfacePayload }
动态值( v0. 9)
可以静态或数据绑定的值:
// Static string or path reference
type DynamicString = string | { path: string } | FunctionCall
// Static number or path reference
type DynamicNumber = number | { path: string } | FunctionCall
// Static boolean or logic expression
type DynamicBoolean = boolean | { path: string } | LogicExpression
数值来源(v0.8)
遗留值绑定 :
type ValueSource =
| { literalString: string }
| { literalNumber: number }
| { literalBoolean: boolean }
| { literalArray: string[] }
| { path: string }
动作付费负荷
从客户端发送到服务器的动作 :
interface ActionPayload {
name: string
surfaceId: string
sourceComponentId: string
timestamp: string // ISO 8601
context: Record<string, unknown>
}
范围值(v0.8+)
收集项目渲染的范围:
interface ScopeValue {
/**
* Base path for relative path resolution.
* null = root scope (no scoping)
* string = scoped to a specific data path (e.g., "/items/0")
*/
basePath: string | null
}
内部用于支持模板交接子的相对路径(列表,行,有模板绑定的列).
许可证
阿帕奇 - 2.0