@a2ui-sdk/types 0.0.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/dist/0.8/index.d.ts +316 -0
- package/dist/0.8/index.js +7 -0
- package/dist/0.9/index.d.ts +391 -0
- package/dist/0.9/index.js +7 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +36 -0
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2UI React Renderer - Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Core type definitions for the A2UI React renderer.
|
|
5
|
+
* Based on the A2UI specification documents.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Represents a value source - either a literal value or a reference to a data model path.
|
|
9
|
+
*/
|
|
10
|
+
export type ValueSource = {
|
|
11
|
+
literalString: string;
|
|
12
|
+
} | {
|
|
13
|
+
literalNumber: number;
|
|
14
|
+
} | {
|
|
15
|
+
literalBoolean: boolean;
|
|
16
|
+
} | {
|
|
17
|
+
literalArray: string[];
|
|
18
|
+
} | {
|
|
19
|
+
path: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Primitive values that can be stored in the data model.
|
|
23
|
+
*/
|
|
24
|
+
export type DataModelValue = string | number | boolean | null | DataModel | unknown[];
|
|
25
|
+
/**
|
|
26
|
+
* The data model is a hierarchical key-value store.
|
|
27
|
+
* Components reference data using paths like "/user/name".
|
|
28
|
+
*/
|
|
29
|
+
export interface DataModel {
|
|
30
|
+
[key: string]: DataModelValue;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Data entry from server messages (dataModelUpdate).
|
|
34
|
+
*/
|
|
35
|
+
export interface DataEntry {
|
|
36
|
+
key: string;
|
|
37
|
+
valueString?: string;
|
|
38
|
+
valueNumber?: number;
|
|
39
|
+
valueBoolean?: boolean;
|
|
40
|
+
valueMap?: DataEntry[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Surface styles configuration.
|
|
44
|
+
*/
|
|
45
|
+
export interface SurfaceStyles {
|
|
46
|
+
font?: string;
|
|
47
|
+
primaryColor?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A Surface is the top-level container for A2UI rendering.
|
|
51
|
+
*/
|
|
52
|
+
export interface Surface {
|
|
53
|
+
surfaceId: string;
|
|
54
|
+
root: string;
|
|
55
|
+
components: Map<string, ComponentDefinition>;
|
|
56
|
+
styles?: SurfaceStyles;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Base component properties that all components share.
|
|
60
|
+
*/
|
|
61
|
+
export interface ComponentDefinition {
|
|
62
|
+
id: string;
|
|
63
|
+
weight?: number;
|
|
64
|
+
component: {
|
|
65
|
+
[componentType: string]: ComponentProps;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Generic component properties type.
|
|
70
|
+
*/
|
|
71
|
+
export type ComponentProps = Record<string, unknown>;
|
|
72
|
+
/**
|
|
73
|
+
* Template binding for dynamic child generation.
|
|
74
|
+
*/
|
|
75
|
+
export interface TemplateBinding {
|
|
76
|
+
componentId: string;
|
|
77
|
+
dataBinding: string;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Children definition for container components.
|
|
81
|
+
*/
|
|
82
|
+
export interface ChildrenDefinition {
|
|
83
|
+
explicitList?: string[];
|
|
84
|
+
template?: TemplateBinding;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* A single item in the action context.
|
|
88
|
+
*/
|
|
89
|
+
export interface ActionContextItem {
|
|
90
|
+
key: string;
|
|
91
|
+
value: ValueSource;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Action definition (attached to Button components).
|
|
95
|
+
*/
|
|
96
|
+
export interface Action {
|
|
97
|
+
name: string;
|
|
98
|
+
context?: ActionContextItem[];
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Resolved action payload sent to the action handler.
|
|
102
|
+
*/
|
|
103
|
+
export interface ActionPayload {
|
|
104
|
+
surfaceId: string;
|
|
105
|
+
name: string;
|
|
106
|
+
context: Record<string, unknown>;
|
|
107
|
+
sourceComponentId: string;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Action handler callback type.
|
|
111
|
+
*/
|
|
112
|
+
export type ActionHandler = (action: ActionPayload) => void;
|
|
113
|
+
/**
|
|
114
|
+
* BeginRendering message payload - initializes a new Surface.
|
|
115
|
+
*/
|
|
116
|
+
export interface BeginRenderingPayload {
|
|
117
|
+
surfaceId: string;
|
|
118
|
+
root: string;
|
|
119
|
+
catalogId?: string;
|
|
120
|
+
styles?: SurfaceStyles;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* SurfaceUpdate message payload - updates the component tree.
|
|
124
|
+
*/
|
|
125
|
+
export interface SurfaceUpdatePayload {
|
|
126
|
+
surfaceId: string;
|
|
127
|
+
components: ComponentDefinition[];
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* DataModelUpdate message payload - updates the data model.
|
|
131
|
+
*/
|
|
132
|
+
export interface DataModelUpdatePayload {
|
|
133
|
+
surfaceId: string;
|
|
134
|
+
path?: string;
|
|
135
|
+
contents: DataEntry[];
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* DeleteSurface message payload - removes a Surface.
|
|
139
|
+
*/
|
|
140
|
+
export interface DeleteSurfacePayload {
|
|
141
|
+
surfaceId: string;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* A2UI message from server to client.
|
|
145
|
+
* Only one of the fields should be set per message.
|
|
146
|
+
*/
|
|
147
|
+
export interface A2UIMessage {
|
|
148
|
+
beginRendering?: BeginRenderingPayload;
|
|
149
|
+
surfaceUpdate?: SurfaceUpdatePayload;
|
|
150
|
+
dataModelUpdate?: DataModelUpdatePayload;
|
|
151
|
+
deleteSurface?: DeleteSurfacePayload;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Base props shared by all A2UI components.
|
|
155
|
+
*/
|
|
156
|
+
export interface BaseComponentProps {
|
|
157
|
+
surfaceId: string;
|
|
158
|
+
componentId: string;
|
|
159
|
+
weight?: number;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Text component properties.
|
|
163
|
+
*/
|
|
164
|
+
export interface TextComponentProps extends BaseComponentProps {
|
|
165
|
+
text?: ValueSource;
|
|
166
|
+
usageHint?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'caption' | 'body';
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Image component properties.
|
|
170
|
+
*/
|
|
171
|
+
export interface ImageComponentProps extends BaseComponentProps {
|
|
172
|
+
url?: ValueSource;
|
|
173
|
+
fit?: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down';
|
|
174
|
+
usageHint?: 'icon' | 'avatar' | 'smallFeature' | 'mediumFeature' | 'largeFeature' | 'header';
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Icon component properties.
|
|
178
|
+
*/
|
|
179
|
+
export interface IconComponentProps extends BaseComponentProps {
|
|
180
|
+
name?: ValueSource;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Video component properties.
|
|
184
|
+
*/
|
|
185
|
+
export interface VideoComponentProps extends BaseComponentProps {
|
|
186
|
+
url?: ValueSource;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* AudioPlayer component properties.
|
|
190
|
+
*/
|
|
191
|
+
export interface AudioPlayerComponentProps extends BaseComponentProps {
|
|
192
|
+
url?: ValueSource;
|
|
193
|
+
description?: ValueSource;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Divider component properties.
|
|
197
|
+
*/
|
|
198
|
+
export interface DividerComponentProps extends BaseComponentProps {
|
|
199
|
+
axis?: 'horizontal' | 'vertical';
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Distribution values for flex layouts.
|
|
203
|
+
*/
|
|
204
|
+
export type Distribution = 'start' | 'center' | 'end' | 'spaceBetween' | 'spaceAround' | 'spaceEvenly';
|
|
205
|
+
/**
|
|
206
|
+
* Alignment values for flex layouts.
|
|
207
|
+
*/
|
|
208
|
+
export type Alignment = 'start' | 'center' | 'end' | 'stretch';
|
|
209
|
+
/**
|
|
210
|
+
* Row component properties.
|
|
211
|
+
*/
|
|
212
|
+
export interface RowComponentProps extends BaseComponentProps {
|
|
213
|
+
children?: ChildrenDefinition;
|
|
214
|
+
distribution?: Distribution;
|
|
215
|
+
alignment?: Alignment;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Column component properties.
|
|
219
|
+
*/
|
|
220
|
+
export interface ColumnComponentProps extends BaseComponentProps {
|
|
221
|
+
children?: ChildrenDefinition;
|
|
222
|
+
distribution?: Distribution;
|
|
223
|
+
alignment?: Alignment;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* List component properties.
|
|
227
|
+
*/
|
|
228
|
+
export interface ListComponentProps extends BaseComponentProps {
|
|
229
|
+
children?: ChildrenDefinition;
|
|
230
|
+
direction?: 'vertical' | 'horizontal';
|
|
231
|
+
alignment?: Alignment;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Card component properties.
|
|
235
|
+
*/
|
|
236
|
+
export interface CardComponentProps extends BaseComponentProps {
|
|
237
|
+
child?: string;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Tab item definition.
|
|
241
|
+
*/
|
|
242
|
+
export interface TabItem {
|
|
243
|
+
title?: ValueSource;
|
|
244
|
+
child: string;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Tabs component properties.
|
|
248
|
+
*/
|
|
249
|
+
export interface TabsComponentProps extends BaseComponentProps {
|
|
250
|
+
tabItems?: TabItem[];
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Modal component properties.
|
|
254
|
+
*/
|
|
255
|
+
export interface ModalComponentProps extends BaseComponentProps {
|
|
256
|
+
entryPointChild?: string;
|
|
257
|
+
contentChild?: string;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Button component properties.
|
|
261
|
+
*/
|
|
262
|
+
export interface ButtonComponentProps extends BaseComponentProps {
|
|
263
|
+
child?: string;
|
|
264
|
+
primary?: boolean;
|
|
265
|
+
action?: Action;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* CheckBox component properties.
|
|
269
|
+
*/
|
|
270
|
+
export interface CheckBoxComponentProps extends BaseComponentProps {
|
|
271
|
+
label?: ValueSource;
|
|
272
|
+
value?: ValueSource;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* TextField component properties.
|
|
276
|
+
*/
|
|
277
|
+
export interface TextFieldComponentProps extends BaseComponentProps {
|
|
278
|
+
label?: ValueSource;
|
|
279
|
+
text?: ValueSource;
|
|
280
|
+
textFieldType?: 'date' | 'longText' | 'number' | 'shortText' | 'obscured';
|
|
281
|
+
validationRegexp?: string;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* DateTimeInput component properties.
|
|
285
|
+
*/
|
|
286
|
+
export interface DateTimeInputComponentProps extends BaseComponentProps {
|
|
287
|
+
label?: ValueSource;
|
|
288
|
+
value?: ValueSource;
|
|
289
|
+
enableDate?: boolean;
|
|
290
|
+
enableTime?: boolean;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* MultipleChoice option definition.
|
|
294
|
+
*/
|
|
295
|
+
export interface MultipleChoiceOption {
|
|
296
|
+
label?: ValueSource;
|
|
297
|
+
value: string;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* MultipleChoice component properties.
|
|
301
|
+
*/
|
|
302
|
+
export interface MultipleChoiceComponentProps extends BaseComponentProps {
|
|
303
|
+
label?: ValueSource;
|
|
304
|
+
selections?: ValueSource;
|
|
305
|
+
options?: MultipleChoiceOption[];
|
|
306
|
+
maxAllowedSelections?: number;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Slider component properties.
|
|
310
|
+
*/
|
|
311
|
+
export interface SliderComponentProps extends BaseComponentProps {
|
|
312
|
+
label?: ValueSource;
|
|
313
|
+
value?: ValueSource;
|
|
314
|
+
minValue?: number;
|
|
315
|
+
maxValue?: number;
|
|
316
|
+
}
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2UI 0.9 React Renderer - Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Core type definitions for the A2UI 0.9 React renderer.
|
|
5
|
+
* Based on the A2UI 0.9 protocol specification.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* A2UI message from server to client.
|
|
9
|
+
* Each message contains exactly one of the four message types.
|
|
10
|
+
*/
|
|
11
|
+
export type A2UIMessage = {
|
|
12
|
+
createSurface: CreateSurfacePayload;
|
|
13
|
+
} | {
|
|
14
|
+
updateComponents: UpdateComponentsPayload;
|
|
15
|
+
} | {
|
|
16
|
+
updateDataModel: UpdateDataModelPayload;
|
|
17
|
+
} | {
|
|
18
|
+
deleteSurface: DeleteSurfacePayload;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* CreateSurface message payload - initializes a new Surface.
|
|
22
|
+
*/
|
|
23
|
+
export interface CreateSurfacePayload {
|
|
24
|
+
surfaceId: string;
|
|
25
|
+
catalogId: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* UpdateComponents message payload - adds/updates components in the surface's component tree.
|
|
29
|
+
*/
|
|
30
|
+
export interface UpdateComponentsPayload {
|
|
31
|
+
surfaceId: string;
|
|
32
|
+
components: Component[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* UpdateDataModel message payload - updates the data model at a specific path.
|
|
36
|
+
*/
|
|
37
|
+
export interface UpdateDataModelPayload {
|
|
38
|
+
surfaceId: string;
|
|
39
|
+
/** JSON Pointer path (RFC 6901), defaults to "/" (root) */
|
|
40
|
+
path?: string;
|
|
41
|
+
/** If omitted, data at path is removed */
|
|
42
|
+
value?: unknown;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* DeleteSurface message payload - removes a Surface.
|
|
46
|
+
*/
|
|
47
|
+
export interface DeleteSurfacePayload {
|
|
48
|
+
surfaceId: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A function call expression.
|
|
52
|
+
*/
|
|
53
|
+
export interface FunctionCall {
|
|
54
|
+
call: string;
|
|
55
|
+
args?: Record<string, DynamicValue>;
|
|
56
|
+
returnType?: 'string' | 'number' | 'boolean' | 'array' | 'object' | 'any';
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Logic expression for boolean evaluation.
|
|
60
|
+
*/
|
|
61
|
+
export type LogicExpression = {
|
|
62
|
+
and: LogicExpression[];
|
|
63
|
+
} | {
|
|
64
|
+
or: LogicExpression[];
|
|
65
|
+
} | {
|
|
66
|
+
not: LogicExpression;
|
|
67
|
+
} | FunctionCall | {
|
|
68
|
+
true: true;
|
|
69
|
+
} | {
|
|
70
|
+
false: false;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Generic dynamic value (any type).
|
|
74
|
+
*/
|
|
75
|
+
export type DynamicValue = string | number | boolean | {
|
|
76
|
+
path: string;
|
|
77
|
+
} | FunctionCall;
|
|
78
|
+
/**
|
|
79
|
+
* Dynamic string value.
|
|
80
|
+
*/
|
|
81
|
+
export type DynamicString = string | {
|
|
82
|
+
path: string;
|
|
83
|
+
} | FunctionCall;
|
|
84
|
+
/**
|
|
85
|
+
* Dynamic number value.
|
|
86
|
+
*/
|
|
87
|
+
export type DynamicNumber = number | {
|
|
88
|
+
path: string;
|
|
89
|
+
} | FunctionCall;
|
|
90
|
+
/**
|
|
91
|
+
* Dynamic boolean value.
|
|
92
|
+
*/
|
|
93
|
+
export type DynamicBoolean = boolean | {
|
|
94
|
+
path: string;
|
|
95
|
+
} | LogicExpression;
|
|
96
|
+
/**
|
|
97
|
+
* Dynamic string list value.
|
|
98
|
+
*/
|
|
99
|
+
export type DynamicStringList = string[] | {
|
|
100
|
+
path: string;
|
|
101
|
+
} | FunctionCall;
|
|
102
|
+
/**
|
|
103
|
+
* Union of all bindable value types (for form binding hooks).
|
|
104
|
+
* Used by useFormBinding to accept any dynamic value type.
|
|
105
|
+
*/
|
|
106
|
+
export type FormBindableValue = DynamicValue | DynamicString | DynamicNumber | DynamicBoolean | DynamicStringList;
|
|
107
|
+
/**
|
|
108
|
+
* Template binding for dynamic child generation.
|
|
109
|
+
*/
|
|
110
|
+
export interface TemplateBinding {
|
|
111
|
+
componentId: string;
|
|
112
|
+
path: string;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Children definition for container components.
|
|
116
|
+
*/
|
|
117
|
+
export type ChildList = string[] | TemplateBinding;
|
|
118
|
+
/**
|
|
119
|
+
* Check rule for validation.
|
|
120
|
+
*/
|
|
121
|
+
export interface CheckRule {
|
|
122
|
+
message: string;
|
|
123
|
+
call?: string;
|
|
124
|
+
args?: Record<string, DynamicValue>;
|
|
125
|
+
and?: CheckRule[];
|
|
126
|
+
or?: CheckRule[];
|
|
127
|
+
not?: CheckRule;
|
|
128
|
+
true?: true;
|
|
129
|
+
false?: false;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Mixin interface for components that support validation checks.
|
|
133
|
+
*/
|
|
134
|
+
export interface Checkable {
|
|
135
|
+
checks?: CheckRule[];
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Base component properties that all components share.
|
|
139
|
+
*/
|
|
140
|
+
export interface ComponentBase {
|
|
141
|
+
id: string;
|
|
142
|
+
/** Discriminator: "Text", "Button", etc. */
|
|
143
|
+
component: string;
|
|
144
|
+
/** flex-grow for Row/Column children */
|
|
145
|
+
weight?: number;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Text component.
|
|
149
|
+
*/
|
|
150
|
+
export interface TextComponent extends ComponentBase {
|
|
151
|
+
component: 'Text';
|
|
152
|
+
text: DynamicString;
|
|
153
|
+
variant?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'caption' | 'body';
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Image component.
|
|
157
|
+
*/
|
|
158
|
+
export interface ImageComponent extends ComponentBase {
|
|
159
|
+
component: 'Image';
|
|
160
|
+
url: DynamicString;
|
|
161
|
+
fit?: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down';
|
|
162
|
+
variant?: 'icon' | 'avatar' | 'smallFeature' | 'mediumFeature' | 'largeFeature' | 'header';
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Icon component.
|
|
166
|
+
*/
|
|
167
|
+
export interface IconComponent extends ComponentBase {
|
|
168
|
+
component: 'Icon';
|
|
169
|
+
name: DynamicString;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Video component.
|
|
173
|
+
*/
|
|
174
|
+
export interface VideoComponent extends ComponentBase {
|
|
175
|
+
component: 'Video';
|
|
176
|
+
url: DynamicString;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* AudioPlayer component.
|
|
180
|
+
*/
|
|
181
|
+
export interface AudioPlayerComponent extends ComponentBase {
|
|
182
|
+
component: 'AudioPlayer';
|
|
183
|
+
url: DynamicString;
|
|
184
|
+
description?: DynamicString;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Divider component.
|
|
188
|
+
*/
|
|
189
|
+
export interface DividerComponent extends ComponentBase {
|
|
190
|
+
component: 'Divider';
|
|
191
|
+
axis?: 'horizontal' | 'vertical';
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Justify values for flex layouts (main axis distribution).
|
|
195
|
+
*/
|
|
196
|
+
export type Justify = 'start' | 'center' | 'end' | 'spaceBetween' | 'spaceAround' | 'spaceEvenly' | 'stretch';
|
|
197
|
+
/**
|
|
198
|
+
* Align values for flex layouts (cross axis alignment).
|
|
199
|
+
*/
|
|
200
|
+
export type Align = 'start' | 'center' | 'end' | 'stretch';
|
|
201
|
+
/**
|
|
202
|
+
* Row component.
|
|
203
|
+
*/
|
|
204
|
+
export interface RowComponent extends ComponentBase {
|
|
205
|
+
component: 'Row';
|
|
206
|
+
children: ChildList;
|
|
207
|
+
justify?: Justify;
|
|
208
|
+
align?: Align;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Column component.
|
|
212
|
+
*/
|
|
213
|
+
export interface ColumnComponent extends ComponentBase {
|
|
214
|
+
component: 'Column';
|
|
215
|
+
children: ChildList;
|
|
216
|
+
justify?: Justify;
|
|
217
|
+
align?: Align;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* List component.
|
|
221
|
+
*/
|
|
222
|
+
export interface ListComponent extends ComponentBase {
|
|
223
|
+
component: 'List';
|
|
224
|
+
children: ChildList;
|
|
225
|
+
direction?: 'vertical' | 'horizontal';
|
|
226
|
+
align?: Align;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Card component.
|
|
230
|
+
*/
|
|
231
|
+
export interface CardComponent extends ComponentBase {
|
|
232
|
+
component: 'Card';
|
|
233
|
+
/** Single child component ID */
|
|
234
|
+
child: string;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Tab item definition.
|
|
238
|
+
*/
|
|
239
|
+
export interface TabItem {
|
|
240
|
+
title: DynamicString;
|
|
241
|
+
/** Component ID */
|
|
242
|
+
child: string;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Tabs component.
|
|
246
|
+
*/
|
|
247
|
+
export interface TabsComponent extends ComponentBase {
|
|
248
|
+
component: 'Tabs';
|
|
249
|
+
tabs: TabItem[];
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Modal component.
|
|
253
|
+
*/
|
|
254
|
+
export interface ModalComponent extends ComponentBase {
|
|
255
|
+
component: 'Modal';
|
|
256
|
+
/** Component ID for trigger */
|
|
257
|
+
trigger: string;
|
|
258
|
+
/** Component ID for content */
|
|
259
|
+
content: string;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Action definition (attached to Button components).
|
|
263
|
+
*/
|
|
264
|
+
export interface Action {
|
|
265
|
+
name: string;
|
|
266
|
+
context?: Record<string, DynamicValue>;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Button component.
|
|
270
|
+
*/
|
|
271
|
+
export interface ButtonComponent extends ComponentBase, Checkable {
|
|
272
|
+
component: 'Button';
|
|
273
|
+
/** Component ID (typically Text or Icon) */
|
|
274
|
+
child: string;
|
|
275
|
+
primary?: boolean;
|
|
276
|
+
action: Action;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* TextField component.
|
|
280
|
+
*/
|
|
281
|
+
export interface TextFieldComponent extends ComponentBase, Checkable {
|
|
282
|
+
component: 'TextField';
|
|
283
|
+
label: DynamicString;
|
|
284
|
+
/** Two-way binding path */
|
|
285
|
+
value?: DynamicString;
|
|
286
|
+
variant?: 'longText' | 'number' | 'shortText' | 'obscured';
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* CheckBox component.
|
|
290
|
+
*/
|
|
291
|
+
export interface CheckBoxComponent extends ComponentBase, Checkable {
|
|
292
|
+
component: 'CheckBox';
|
|
293
|
+
label: DynamicString;
|
|
294
|
+
/** Two-way binding path */
|
|
295
|
+
value: DynamicBoolean;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Choice option definition.
|
|
299
|
+
*/
|
|
300
|
+
export interface ChoiceOption {
|
|
301
|
+
label: DynamicString;
|
|
302
|
+
value: string;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* ChoicePicker component (renamed from MultipleChoice).
|
|
306
|
+
*/
|
|
307
|
+
export interface ChoicePickerComponent extends ComponentBase, Checkable {
|
|
308
|
+
component: 'ChoicePicker';
|
|
309
|
+
label?: DynamicString;
|
|
310
|
+
variant?: 'multipleSelection' | 'mutuallyExclusive';
|
|
311
|
+
options: ChoiceOption[];
|
|
312
|
+
/** Two-way binding path */
|
|
313
|
+
value: DynamicStringList;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Slider component.
|
|
317
|
+
*/
|
|
318
|
+
export interface SliderComponent extends ComponentBase, Checkable {
|
|
319
|
+
component: 'Slider';
|
|
320
|
+
label?: DynamicString;
|
|
321
|
+
min: number;
|
|
322
|
+
max: number;
|
|
323
|
+
/** Two-way binding path */
|
|
324
|
+
value: DynamicNumber;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* DateTimeInput component.
|
|
328
|
+
*/
|
|
329
|
+
export interface DateTimeInputComponent extends ComponentBase, Checkable {
|
|
330
|
+
component: 'DateTimeInput';
|
|
331
|
+
/** Two-way binding path (ISO 8601) */
|
|
332
|
+
value: DynamicString;
|
|
333
|
+
enableDate?: boolean;
|
|
334
|
+
enableTime?: boolean;
|
|
335
|
+
outputFormat?: string;
|
|
336
|
+
label?: DynamicString;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Union type of all standard catalog components.
|
|
340
|
+
*/
|
|
341
|
+
export type Component = TextComponent | ImageComponent | IconComponent | VideoComponent | AudioPlayerComponent | DividerComponent | RowComponent | ColumnComponent | ListComponent | CardComponent | TabsComponent | ModalComponent | ButtonComponent | TextFieldComponent | CheckBoxComponent | ChoicePickerComponent | SliderComponent | DateTimeInputComponent;
|
|
342
|
+
/**
|
|
343
|
+
* Data model type (hierarchical key-value store).
|
|
344
|
+
*/
|
|
345
|
+
export type DataModel = Record<string, unknown>;
|
|
346
|
+
/**
|
|
347
|
+
* Surface state.
|
|
348
|
+
*/
|
|
349
|
+
export interface SurfaceState {
|
|
350
|
+
surfaceId: string;
|
|
351
|
+
catalogId: string;
|
|
352
|
+
components: Map<string, Component>;
|
|
353
|
+
dataModel: DataModel;
|
|
354
|
+
created: boolean;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Provider state managing multiple surfaces.
|
|
358
|
+
*/
|
|
359
|
+
export interface ProviderState {
|
|
360
|
+
surfaces: Map<string, SurfaceState>;
|
|
361
|
+
messageBuffer: Map<string, A2UIMessage[]>;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Scope value for collection scopes.
|
|
365
|
+
*/
|
|
366
|
+
export interface ScopeValue {
|
|
367
|
+
/** null = root scope, otherwise the base path for relative resolution */
|
|
368
|
+
basePath: string | null;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Validation result.
|
|
372
|
+
*/
|
|
373
|
+
export interface ValidationResult {
|
|
374
|
+
valid: boolean;
|
|
375
|
+
/** List of failed check messages */
|
|
376
|
+
errors: string[];
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Resolved action payload sent to the action handler.
|
|
380
|
+
*/
|
|
381
|
+
export interface ActionPayload {
|
|
382
|
+
name: string;
|
|
383
|
+
surfaceId: string;
|
|
384
|
+
sourceComponentId: string;
|
|
385
|
+
timestamp: string;
|
|
386
|
+
context: Record<string, unknown>;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Action handler callback type.
|
|
390
|
+
*/
|
|
391
|
+
export type ActionHandler = (action: ActionPayload) => void;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../src/index.ts","../src/0.8/index.ts","../src/0.9/index.ts"],"version":"5.9.3"}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@a2ui-sdk/types",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "A2UI types",
|
|
5
|
+
"homepage": "https://easyops-cn.github.io/a2ui-sdk/",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git@github.com:easyops-cn/a2ui-sdk.git",
|
|
9
|
+
"directory": "packages/types"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./0.8": {
|
|
20
|
+
"types": "./dist/0.8/index.d.ts",
|
|
21
|
+
"default": "./dist/0.8/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./0.9": {
|
|
24
|
+
"types": "./dist/0.9/index.d.ts",
|
|
25
|
+
"default": "./dist/0.9/index.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"dev": "tsc -b --watch",
|
|
33
|
+
"build": "tsc -b"
|
|
34
|
+
},
|
|
35
|
+
"license": "Apache-2.0"
|
|
36
|
+
}
|