@sepveneto/dnde-core 0.6.4 → 0.6.5

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.
Files changed (43) hide show
  1. package/dist/{Node-CnqlVnWy.d.cts → capability-Ce3qGTm3.d.cts} +184 -107
  2. package/dist/{Node-CnqlVnWy.d.ts → capability-Ce3qGTm3.d.ts} +184 -107
  3. package/dist/capability.cjs +172 -0
  4. package/dist/capability.d.cts +4 -0
  5. package/dist/capability.d.ts +4 -0
  6. package/dist/capability.js +15 -0
  7. package/dist/{chunk-PRK4NPVH.js → chunk-62FPS6PZ.js} +2 -0
  8. package/dist/chunk-W7WBD3NX.js +360 -0
  9. package/dist/chunk-XXR7SKZ3.js +132 -0
  10. package/dist/class/Container.d.cts +2 -2
  11. package/dist/class/Container.d.ts +2 -2
  12. package/dist/class/Node.d.cts +1 -1
  13. package/dist/class/Node.d.ts +1 -1
  14. package/dist/class/Widget.d.cts +1 -1
  15. package/dist/class/Widget.d.ts +1 -1
  16. package/dist/class/index.d.cts +2 -2
  17. package/dist/class/index.d.ts +2 -2
  18. package/dist/class/index.js +3 -3
  19. package/dist/dsl.cjs +405 -0
  20. package/dist/dsl.d.cts +85 -0
  21. package/dist/dsl.d.ts +85 -0
  22. package/dist/dsl.js +12 -0
  23. package/dist/helper/index.cjs +2 -0
  24. package/dist/helper/index.d.cts +1 -1
  25. package/dist/helper/index.d.ts +1 -1
  26. package/dist/helper/index.js +1 -1
  27. package/dist/helper/schema.cjs +2 -0
  28. package/dist/helper/schema.d.cts +3 -1
  29. package/dist/helper/schema.d.ts +3 -1
  30. package/dist/helper/schema.js +1 -1
  31. package/dist/helper/widget.d.cts +1 -1
  32. package/dist/helper/widget.d.ts +1 -1
  33. package/dist/index.cjs +484 -0
  34. package/dist/index.d.cts +3 -2
  35. package/dist/index.d.ts +3 -2
  36. package/dist/index.js +24 -4
  37. package/dist/internal.d.cts +2 -2
  38. package/dist/internal.d.ts +2 -2
  39. package/dist/tokens.d.cts +1 -1
  40. package/dist/tokens.d.ts +1 -1
  41. package/dist/types.d.cts +1 -1
  42. package/dist/types.d.ts +1 -1
  43. package/package.json +1 -1
@@ -1,8 +1,126 @@
1
+ import { FormItemProps, FormItemRule, InputProps, ElOption, SelectProps, InputNumberProps, SwitchProps, RadioGroupProps, ElRadio, ElRadioButton, DatePickerProps, ColorPickerProps, CheckboxProps, UploadRequestOptions } from 'element-plus';
1
2
  import * as vue from 'vue';
2
3
  import { CSSProperties } from 'vue';
3
- import { FormItemRule, UploadRequestOptions, FormItemProps, InputProps, ElOption, SelectProps, InputNumberProps, SwitchProps, RadioGroupProps, ElRadio, ElRadioButton, DatePickerProps, ColorPickerProps, CheckboxProps } from 'element-plus';
4
4
  import Validator from 'async-validator';
5
5
 
6
+ type Option = InstanceType<typeof ElOption>['$props'];
7
+ type RadioOption = InstanceType<typeof ElRadio>['$props'];
8
+ type RadioButtonOption = InstanceType<typeof ElRadioButton>['$props'];
9
+ interface SchemaItemBase {
10
+ /** @private */
11
+ _role?: string;
12
+ label: string;
13
+ key: string;
14
+ /** Capability range used by DSL scope validation. */
15
+ scope?: FieldScope;
16
+ /** A field may be discovered but not written by the configuration Agent. */
17
+ readOnly?: boolean;
18
+ formItem?: Partial<FormItemProps>;
19
+ rules?: FormItemRule | FormItemRule[];
20
+ }
21
+ interface SchemaItemInput extends SchemaItemBase {
22
+ type: 'input';
23
+ attrs?: InputProps;
24
+ }
25
+ interface SchemaItemSelect extends SchemaItemBase {
26
+ type: 'select';
27
+ options?: Option[];
28
+ attrs?: SelectProps;
29
+ link?: Record<string | number, SchemaItem[]>;
30
+ }
31
+ interface SchemaItemNumber extends SchemaItemBase {
32
+ type: 'number';
33
+ attrs?: InputNumberProps;
34
+ }
35
+ interface SchemaItemSwitch extends SchemaItemBase {
36
+ type: 'switch';
37
+ attrs?: SwitchProps;
38
+ }
39
+ interface SchemaItemDatetimePicker extends SchemaItemBase {
40
+ type: 'datetimePicker';
41
+ attrs?: DatePickerProps;
42
+ }
43
+ interface SchemaItemColorPicker extends SchemaItemBase {
44
+ type: 'colorPicker';
45
+ attrs?: ColorPickerProps;
46
+ }
47
+ interface SchemaItemCheckbox extends SchemaItemBase {
48
+ type: 'checkbox';
49
+ attrs?: CheckboxProps;
50
+ }
51
+ interface SchemaItemCustom extends SchemaItemBase {
52
+ type: 'custom';
53
+ name: string;
54
+ attrs?: Record<string, any>;
55
+ }
56
+ interface SchemaItemStyleNumber extends SchemaItemBase {
57
+ type: 'styleNumber';
58
+ }
59
+ interface SchemaItemRadio extends SchemaItemBase {
60
+ type: 'radio';
61
+ attrs?: RadioGroupProps;
62
+ options?: RadioOption[];
63
+ link?: Record<string | number, SchemaItem[]>;
64
+ }
65
+ interface SchemaItemRadioButton extends SchemaItemBase {
66
+ type: 'radioButton';
67
+ attrs?: RadioGroupProps;
68
+ options?: RadioButtonOption[];
69
+ link?: Record<string | number, SchemaItem[]>;
70
+ }
71
+ type SchemaItem = SchemaItemInput | SchemaItemSelect | SchemaItemNumber | SchemaItemSwitch | SchemaItemCustom | SchemaItemStyleNumber | SchemaItemRadio | SchemaItemRadioButton | SchemaItemDatetimePicker | SchemaItemColorPicker | SchemaItemCheckbox;
72
+ declare class Widget {
73
+ name: string;
74
+ view: string;
75
+ _data: IWidget;
76
+ container: IWidget['container'];
77
+ constructor(widget: IWidget);
78
+ clone(): Widget;
79
+ get icon(): string | undefined;
80
+ get props(): SchemaItem[];
81
+ get style(): SchemaItem[];
82
+ get defaultStyle(): (vue.CSSProperties & WidgetPos) | undefined;
83
+ get defaultData(): any[] | Record<string, any> | undefined;
84
+ get agent(): WidgetAgent | undefined;
85
+ get draggable(): boolean;
86
+ get isFixed(): false | "header" | "footer" | undefined;
87
+ get visible(): boolean;
88
+ get validatorProps(): Validator;
89
+ get validatorStyle(): Validator;
90
+ }
91
+
92
+ declare class Node {
93
+ level: number;
94
+ wid: string;
95
+ widget: Readonly<Widget>;
96
+ parent?: Node;
97
+ list: Node[];
98
+ data: Record<string, any>;
99
+ style: CSSProperties;
100
+ hovering: boolean;
101
+ dragging: boolean;
102
+ constructor(widget: Widget, info?: {
103
+ uuid?: string;
104
+ props?: Node['data'];
105
+ style?: Node['style'];
106
+ list?: Node['list'];
107
+ });
108
+ get info(): {
109
+ style: CSSProperties;
110
+ };
111
+ get isContainer(): boolean;
112
+ get hasList(): boolean;
113
+ get mouseover(): boolean;
114
+ get type(): string;
115
+ get name(): string;
116
+ get visible(): boolean | undefined;
117
+ validate(only?: boolean): Promise<string | undefined>;
118
+ triggerHover(hover: boolean): void;
119
+ setList(list: Node[]): void;
120
+ copy(): Node;
121
+ parse(): Record<string, any>;
122
+ }
123
+
6
124
  interface WidgetPos {
7
125
  x?: number;
8
126
  y?: number;
@@ -11,12 +129,20 @@ interface WidgetPos {
11
129
  }
12
130
  /** 布局子 Agent 的输出项:选中的组件 + 要放进去的元素 */
13
131
  interface WidgetLayoutItem {
14
- widget: string;
15
- items: Array<{
132
+ widget?: string;
133
+ items?: Array<{
16
134
  category: string;
17
135
  id: any;
18
136
  }>;
137
+ componentKey?: string;
138
+ changes?: Record<string, any>;
19
139
  }
140
+ interface WidgetCapabilityExecutionContext {
141
+ node: Node;
142
+ args: Record<string, unknown>;
143
+ context: Record<string, unknown>;
144
+ }
145
+ type WidgetCapabilityAdapter = (input: WidgetCapabilityExecutionContext) => void | Record<string, unknown> | Promise<void | Record<string, unknown>>;
20
146
  interface WidgetAgent {
21
147
  /**
22
148
  * 组件的功能描述。
@@ -39,6 +165,7 @@ interface WidgetAgent {
39
165
  *
40
166
  * @param node 已创建的组件节点
41
167
  * @param item 布局结果项(选中的组件 + 元素引用)
168
+ * @param state 当前 Agent Run 的上下文,包含业务工具准备的数据
42
169
  */
43
170
  update?: (node: Node, item: WidgetLayoutItem, state: Record<string, unknown>) => void;
44
171
  }
@@ -164,118 +291,68 @@ interface EditorData {
164
291
  settings?: EditorSettings;
165
292
  }
166
293
 
167
- type Option = InstanceType<typeof ElOption>['$props'];
168
- type RadioOption = InstanceType<typeof ElRadio>['$props'];
169
- type RadioButtonOption = InstanceType<typeof ElRadioButton>['$props'];
170
- interface SchemaItemBase {
171
- /** @private */
172
- _role?: string;
173
- label: string;
294
+ type FieldScope = 'style' | 'content' | 'layout';
295
+ type CapabilityValueType = 'string' | 'number' | 'integer' | 'boolean' | 'enum' | 'array' | 'object' | 'unknown';
296
+ interface WidgetFieldCapability {
297
+ source: 'prop';
174
298
  key: string;
175
- formItem?: Partial<FormItemProps>;
176
- rules?: FormItemRule | FormItemRule[];
177
- }
178
- interface SchemaItemInput extends SchemaItemBase {
179
- type: 'input';
180
- attrs?: InputProps;
181
- }
182
- interface SchemaItemSelect extends SchemaItemBase {
183
- type: 'select';
184
- options?: Option[];
185
- attrs?: SelectProps;
186
- link?: Record<string | number, SchemaItem[]>;
187
- }
188
- interface SchemaItemNumber extends SchemaItemBase {
189
- type: 'number';
190
- attrs?: InputNumberProps;
191
- }
192
- interface SchemaItemSwitch extends SchemaItemBase {
193
- type: 'switch';
194
- attrs?: SwitchProps;
195
- }
196
- interface SchemaItemDatetimePicker extends SchemaItemBase {
197
- type: 'datetimePicker';
198
- attrs?: DatePickerProps;
199
- }
200
- interface SchemaItemColorPicker extends SchemaItemBase {
201
- type: 'colorPicker';
202
- attrs?: ColorPickerProps;
203
- }
204
- interface SchemaItemCheckbox extends SchemaItemBase {
205
- type: 'checkbox';
206
- attrs?: CheckboxProps;
299
+ label: string;
300
+ valueType: CapabilityValueType;
301
+ scope: FieldScope;
302
+ required: boolean;
303
+ readOnly: boolean;
304
+ enum?: unknown[];
305
+ minimum?: number;
306
+ maximum?: number;
307
+ default?: unknown;
207
308
  }
208
- interface SchemaItemCustom extends SchemaItemBase {
209
- type: 'custom';
309
+ interface WidgetCustomCapability {
210
310
  name: string;
211
- attrs?: Record<string, any>;
311
+ inputSchema?: Record<string, unknown>;
312
+ semantics: 'append' | 'replace' | 'remove' | 'command';
313
+ idempotent: boolean;
314
+ destructive: boolean;
315
+ writableScope: FieldScope;
212
316
  }
213
- interface SchemaItemStyleNumber extends SchemaItemBase {
214
- type: 'styleNumber';
317
+ interface WidgetCustomTypeCapability {
318
+ type: string;
319
+ capabilities: WidgetCustomCapability[];
215
320
  }
216
- interface SchemaItemRadio extends SchemaItemBase {
217
- type: 'radio';
218
- attrs?: RadioGroupProps;
219
- options?: RadioOption[];
220
- link?: Record<string | number, SchemaItem[]>;
321
+ interface StaticOption {
322
+ id: string;
323
+ name: string;
324
+ aliases: string[];
325
+ value: unknown;
326
+ types: string[];
221
327
  }
222
- interface SchemaItemRadioButton extends SchemaItemBase {
223
- type: 'radioButton';
224
- attrs?: RadioGroupProps;
225
- options?: RadioButtonOption[];
226
- link?: Record<string | number, SchemaItem[]>;
328
+ interface WidgetCapabilityRegistration {
329
+ customTypes?: WidgetCustomTypeCapability[];
330
+ staticOptions?: StaticOption[];
227
331
  }
228
- type SchemaItem = SchemaItemInput | SchemaItemSelect | SchemaItemNumber | SchemaItemSwitch | SchemaItemCustom | SchemaItemStyleNumber | SchemaItemRadio | SchemaItemRadioButton | SchemaItemDatetimePicker | SchemaItemColorPicker | SchemaItemCheckbox;
229
- declare class Widget {
332
+ type WidgetCapabilityRegistry = Record<string, WidgetCapabilityRegistration>;
333
+ interface WidgetCapability {
334
+ type: string;
230
335
  name: string;
231
- view: string;
232
- _data: IWidget;
233
- container: IWidget['container'];
234
- constructor(widget: IWidget);
235
- clone(): Widget;
236
- get icon(): string | undefined;
237
- get props(): SchemaItem[];
238
- get style(): SchemaItem[];
239
- get defaultStyle(): (vue.CSSProperties & WidgetPos) | undefined;
240
- get defaultData(): any[] | Record<string, any> | undefined;
241
- get agent(): WidgetAgent | undefined;
242
- get draggable(): boolean;
243
- get isFixed(): false | "header" | "footer" | undefined;
244
- get visible(): boolean;
245
- get validatorProps(): Validator;
246
- get validatorStyle(): Validator;
336
+ description: string;
337
+ defaultData: Record<string, any>;
338
+ defaultStyle: Record<string, any>;
339
+ fields: WidgetFieldCapability[];
340
+ customTypes: WidgetCustomTypeCapability[];
341
+ staticOptions: StaticOption[];
247
342
  }
248
-
249
- declare class Node {
250
- level: number;
251
- wid: string;
252
- widget: Readonly<Widget>;
253
- parent?: Node;
254
- list: Node[];
255
- data: Record<string, any>;
256
- style: CSSProperties;
257
- hovering: boolean;
258
- dragging: boolean;
259
- constructor(widget: Widget, info?: {
260
- uuid?: string;
261
- props?: Node['data'];
262
- style?: Node['style'];
263
- list?: Node['list'];
264
- });
265
- get info(): {
266
- style: CSSProperties;
267
- };
268
- get isContainer(): boolean;
269
- get hasList(): boolean;
270
- get mouseover(): boolean;
271
- get type(): string;
272
- get name(): string;
273
- get visible(): boolean | undefined;
274
- validate(only?: boolean): Promise<string | undefined>;
275
- triggerHover(hover: boolean): void;
276
- setList(list: Node[]): void;
277
- copy(): Node;
278
- parse(): Record<string, any>;
343
+ interface CapabilityCatalog {
344
+ catalogVersion: '1.0';
345
+ widgets: WidgetCapability[];
279
346
  }
347
+ /**
348
+ * Convert live widget declarations into the stable catalog consumed by DSL
349
+ * validation. Custom schema entries are advertised from the schema itself;
350
+ * executable capabilities must be registered by the host.
351
+ */
352
+ declare function createCapabilityCatalog(widgets: IWidget[], registry?: WidgetCapabilityRegistry): CapabilityCatalog;
353
+ declare function findWidgetCapability(catalog: CapabilityCatalog, type: string): WidgetCapability | undefined;
354
+ declare function findFieldCapability(widget: WidgetCapability, key: string): WidgetFieldCapability | undefined;
355
+ declare function findCustomCapability(widget: WidgetCapability, type: string, name: string): WidgetCustomCapability | undefined;
356
+ declare function listStaticOptions(catalog: CapabilityCatalog, widgetTypes?: string[], types?: string[]): StaticOption[];
280
357
 
281
- export { type Base as B, type DisabledItemFn as D, type EditorConfig as E, type IWidget as I, Node as N, type Option as O, type RadioOption as R, type SchemaItemCustom as S, Widget as W, type RadioButtonOption as a, type SchemaItem as b, type WidgetPos as c, type WidgetLayoutItem as d, type WidgetAgent as e, type SchemaOther as f, type SchemaBox as g, type ISchema as h, isBox as i, type EditorSchema as j, type EditorWidget as k, type EditorRoute as l, type EditorWidgets as m, type EditorSettings as n, type EditorData as o };
358
+ export { type EditorRoute as A, type Base as B, type CapabilityValueType as C, type DisabledItemFn as D, type EditorConfig as E, type FieldScope as F, type EditorWidgets as G, type EditorSettings as H, type IWidget as I, type EditorData as J, Node as N, type Option as O, type RadioOption as R, type SchemaItemCustom as S, Widget as W, type RadioButtonOption as a, type SchemaItem as b, type WidgetFieldCapability as c, type WidgetCustomCapability as d, type WidgetCustomTypeCapability as e, type StaticOption as f, type WidgetCapabilityRegistration as g, type WidgetCapabilityRegistry as h, type WidgetCapability as i, type CapabilityCatalog as j, createCapabilityCatalog as k, findWidgetCapability as l, findFieldCapability as m, findCustomCapability as n, listStaticOptions as o, type WidgetPos as p, type WidgetLayoutItem as q, type WidgetCapabilityExecutionContext as r, type WidgetCapabilityAdapter as s, type WidgetAgent as t, type SchemaOther as u, type SchemaBox as v, type ISchema as w, isBox as x, type EditorSchema as y, type EditorWidget as z };
@@ -1,8 +1,126 @@
1
+ import { FormItemProps, FormItemRule, InputProps, ElOption, SelectProps, InputNumberProps, SwitchProps, RadioGroupProps, ElRadio, ElRadioButton, DatePickerProps, ColorPickerProps, CheckboxProps, UploadRequestOptions } from 'element-plus';
1
2
  import * as vue from 'vue';
2
3
  import { CSSProperties } from 'vue';
3
- import { FormItemRule, UploadRequestOptions, FormItemProps, InputProps, ElOption, SelectProps, InputNumberProps, SwitchProps, RadioGroupProps, ElRadio, ElRadioButton, DatePickerProps, ColorPickerProps, CheckboxProps } from 'element-plus';
4
4
  import Validator from 'async-validator';
5
5
 
6
+ type Option = InstanceType<typeof ElOption>['$props'];
7
+ type RadioOption = InstanceType<typeof ElRadio>['$props'];
8
+ type RadioButtonOption = InstanceType<typeof ElRadioButton>['$props'];
9
+ interface SchemaItemBase {
10
+ /** @private */
11
+ _role?: string;
12
+ label: string;
13
+ key: string;
14
+ /** Capability range used by DSL scope validation. */
15
+ scope?: FieldScope;
16
+ /** A field may be discovered but not written by the configuration Agent. */
17
+ readOnly?: boolean;
18
+ formItem?: Partial<FormItemProps>;
19
+ rules?: FormItemRule | FormItemRule[];
20
+ }
21
+ interface SchemaItemInput extends SchemaItemBase {
22
+ type: 'input';
23
+ attrs?: InputProps;
24
+ }
25
+ interface SchemaItemSelect extends SchemaItemBase {
26
+ type: 'select';
27
+ options?: Option[];
28
+ attrs?: SelectProps;
29
+ link?: Record<string | number, SchemaItem[]>;
30
+ }
31
+ interface SchemaItemNumber extends SchemaItemBase {
32
+ type: 'number';
33
+ attrs?: InputNumberProps;
34
+ }
35
+ interface SchemaItemSwitch extends SchemaItemBase {
36
+ type: 'switch';
37
+ attrs?: SwitchProps;
38
+ }
39
+ interface SchemaItemDatetimePicker extends SchemaItemBase {
40
+ type: 'datetimePicker';
41
+ attrs?: DatePickerProps;
42
+ }
43
+ interface SchemaItemColorPicker extends SchemaItemBase {
44
+ type: 'colorPicker';
45
+ attrs?: ColorPickerProps;
46
+ }
47
+ interface SchemaItemCheckbox extends SchemaItemBase {
48
+ type: 'checkbox';
49
+ attrs?: CheckboxProps;
50
+ }
51
+ interface SchemaItemCustom extends SchemaItemBase {
52
+ type: 'custom';
53
+ name: string;
54
+ attrs?: Record<string, any>;
55
+ }
56
+ interface SchemaItemStyleNumber extends SchemaItemBase {
57
+ type: 'styleNumber';
58
+ }
59
+ interface SchemaItemRadio extends SchemaItemBase {
60
+ type: 'radio';
61
+ attrs?: RadioGroupProps;
62
+ options?: RadioOption[];
63
+ link?: Record<string | number, SchemaItem[]>;
64
+ }
65
+ interface SchemaItemRadioButton extends SchemaItemBase {
66
+ type: 'radioButton';
67
+ attrs?: RadioGroupProps;
68
+ options?: RadioButtonOption[];
69
+ link?: Record<string | number, SchemaItem[]>;
70
+ }
71
+ type SchemaItem = SchemaItemInput | SchemaItemSelect | SchemaItemNumber | SchemaItemSwitch | SchemaItemCustom | SchemaItemStyleNumber | SchemaItemRadio | SchemaItemRadioButton | SchemaItemDatetimePicker | SchemaItemColorPicker | SchemaItemCheckbox;
72
+ declare class Widget {
73
+ name: string;
74
+ view: string;
75
+ _data: IWidget;
76
+ container: IWidget['container'];
77
+ constructor(widget: IWidget);
78
+ clone(): Widget;
79
+ get icon(): string | undefined;
80
+ get props(): SchemaItem[];
81
+ get style(): SchemaItem[];
82
+ get defaultStyle(): (vue.CSSProperties & WidgetPos) | undefined;
83
+ get defaultData(): any[] | Record<string, any> | undefined;
84
+ get agent(): WidgetAgent | undefined;
85
+ get draggable(): boolean;
86
+ get isFixed(): false | "header" | "footer" | undefined;
87
+ get visible(): boolean;
88
+ get validatorProps(): Validator;
89
+ get validatorStyle(): Validator;
90
+ }
91
+
92
+ declare class Node {
93
+ level: number;
94
+ wid: string;
95
+ widget: Readonly<Widget>;
96
+ parent?: Node;
97
+ list: Node[];
98
+ data: Record<string, any>;
99
+ style: CSSProperties;
100
+ hovering: boolean;
101
+ dragging: boolean;
102
+ constructor(widget: Widget, info?: {
103
+ uuid?: string;
104
+ props?: Node['data'];
105
+ style?: Node['style'];
106
+ list?: Node['list'];
107
+ });
108
+ get info(): {
109
+ style: CSSProperties;
110
+ };
111
+ get isContainer(): boolean;
112
+ get hasList(): boolean;
113
+ get mouseover(): boolean;
114
+ get type(): string;
115
+ get name(): string;
116
+ get visible(): boolean | undefined;
117
+ validate(only?: boolean): Promise<string | undefined>;
118
+ triggerHover(hover: boolean): void;
119
+ setList(list: Node[]): void;
120
+ copy(): Node;
121
+ parse(): Record<string, any>;
122
+ }
123
+
6
124
  interface WidgetPos {
7
125
  x?: number;
8
126
  y?: number;
@@ -11,12 +129,20 @@ interface WidgetPos {
11
129
  }
12
130
  /** 布局子 Agent 的输出项:选中的组件 + 要放进去的元素 */
13
131
  interface WidgetLayoutItem {
14
- widget: string;
15
- items: Array<{
132
+ widget?: string;
133
+ items?: Array<{
16
134
  category: string;
17
135
  id: any;
18
136
  }>;
137
+ componentKey?: string;
138
+ changes?: Record<string, any>;
19
139
  }
140
+ interface WidgetCapabilityExecutionContext {
141
+ node: Node;
142
+ args: Record<string, unknown>;
143
+ context: Record<string, unknown>;
144
+ }
145
+ type WidgetCapabilityAdapter = (input: WidgetCapabilityExecutionContext) => void | Record<string, unknown> | Promise<void | Record<string, unknown>>;
20
146
  interface WidgetAgent {
21
147
  /**
22
148
  * 组件的功能描述。
@@ -39,6 +165,7 @@ interface WidgetAgent {
39
165
  *
40
166
  * @param node 已创建的组件节点
41
167
  * @param item 布局结果项(选中的组件 + 元素引用)
168
+ * @param state 当前 Agent Run 的上下文,包含业务工具准备的数据
42
169
  */
43
170
  update?: (node: Node, item: WidgetLayoutItem, state: Record<string, unknown>) => void;
44
171
  }
@@ -164,118 +291,68 @@ interface EditorData {
164
291
  settings?: EditorSettings;
165
292
  }
166
293
 
167
- type Option = InstanceType<typeof ElOption>['$props'];
168
- type RadioOption = InstanceType<typeof ElRadio>['$props'];
169
- type RadioButtonOption = InstanceType<typeof ElRadioButton>['$props'];
170
- interface SchemaItemBase {
171
- /** @private */
172
- _role?: string;
173
- label: string;
294
+ type FieldScope = 'style' | 'content' | 'layout';
295
+ type CapabilityValueType = 'string' | 'number' | 'integer' | 'boolean' | 'enum' | 'array' | 'object' | 'unknown';
296
+ interface WidgetFieldCapability {
297
+ source: 'prop';
174
298
  key: string;
175
- formItem?: Partial<FormItemProps>;
176
- rules?: FormItemRule | FormItemRule[];
177
- }
178
- interface SchemaItemInput extends SchemaItemBase {
179
- type: 'input';
180
- attrs?: InputProps;
181
- }
182
- interface SchemaItemSelect extends SchemaItemBase {
183
- type: 'select';
184
- options?: Option[];
185
- attrs?: SelectProps;
186
- link?: Record<string | number, SchemaItem[]>;
187
- }
188
- interface SchemaItemNumber extends SchemaItemBase {
189
- type: 'number';
190
- attrs?: InputNumberProps;
191
- }
192
- interface SchemaItemSwitch extends SchemaItemBase {
193
- type: 'switch';
194
- attrs?: SwitchProps;
195
- }
196
- interface SchemaItemDatetimePicker extends SchemaItemBase {
197
- type: 'datetimePicker';
198
- attrs?: DatePickerProps;
199
- }
200
- interface SchemaItemColorPicker extends SchemaItemBase {
201
- type: 'colorPicker';
202
- attrs?: ColorPickerProps;
203
- }
204
- interface SchemaItemCheckbox extends SchemaItemBase {
205
- type: 'checkbox';
206
- attrs?: CheckboxProps;
299
+ label: string;
300
+ valueType: CapabilityValueType;
301
+ scope: FieldScope;
302
+ required: boolean;
303
+ readOnly: boolean;
304
+ enum?: unknown[];
305
+ minimum?: number;
306
+ maximum?: number;
307
+ default?: unknown;
207
308
  }
208
- interface SchemaItemCustom extends SchemaItemBase {
209
- type: 'custom';
309
+ interface WidgetCustomCapability {
210
310
  name: string;
211
- attrs?: Record<string, any>;
311
+ inputSchema?: Record<string, unknown>;
312
+ semantics: 'append' | 'replace' | 'remove' | 'command';
313
+ idempotent: boolean;
314
+ destructive: boolean;
315
+ writableScope: FieldScope;
212
316
  }
213
- interface SchemaItemStyleNumber extends SchemaItemBase {
214
- type: 'styleNumber';
317
+ interface WidgetCustomTypeCapability {
318
+ type: string;
319
+ capabilities: WidgetCustomCapability[];
215
320
  }
216
- interface SchemaItemRadio extends SchemaItemBase {
217
- type: 'radio';
218
- attrs?: RadioGroupProps;
219
- options?: RadioOption[];
220
- link?: Record<string | number, SchemaItem[]>;
321
+ interface StaticOption {
322
+ id: string;
323
+ name: string;
324
+ aliases: string[];
325
+ value: unknown;
326
+ types: string[];
221
327
  }
222
- interface SchemaItemRadioButton extends SchemaItemBase {
223
- type: 'radioButton';
224
- attrs?: RadioGroupProps;
225
- options?: RadioButtonOption[];
226
- link?: Record<string | number, SchemaItem[]>;
328
+ interface WidgetCapabilityRegistration {
329
+ customTypes?: WidgetCustomTypeCapability[];
330
+ staticOptions?: StaticOption[];
227
331
  }
228
- type SchemaItem = SchemaItemInput | SchemaItemSelect | SchemaItemNumber | SchemaItemSwitch | SchemaItemCustom | SchemaItemStyleNumber | SchemaItemRadio | SchemaItemRadioButton | SchemaItemDatetimePicker | SchemaItemColorPicker | SchemaItemCheckbox;
229
- declare class Widget {
332
+ type WidgetCapabilityRegistry = Record<string, WidgetCapabilityRegistration>;
333
+ interface WidgetCapability {
334
+ type: string;
230
335
  name: string;
231
- view: string;
232
- _data: IWidget;
233
- container: IWidget['container'];
234
- constructor(widget: IWidget);
235
- clone(): Widget;
236
- get icon(): string | undefined;
237
- get props(): SchemaItem[];
238
- get style(): SchemaItem[];
239
- get defaultStyle(): (vue.CSSProperties & WidgetPos) | undefined;
240
- get defaultData(): any[] | Record<string, any> | undefined;
241
- get agent(): WidgetAgent | undefined;
242
- get draggable(): boolean;
243
- get isFixed(): false | "header" | "footer" | undefined;
244
- get visible(): boolean;
245
- get validatorProps(): Validator;
246
- get validatorStyle(): Validator;
336
+ description: string;
337
+ defaultData: Record<string, any>;
338
+ defaultStyle: Record<string, any>;
339
+ fields: WidgetFieldCapability[];
340
+ customTypes: WidgetCustomTypeCapability[];
341
+ staticOptions: StaticOption[];
247
342
  }
248
-
249
- declare class Node {
250
- level: number;
251
- wid: string;
252
- widget: Readonly<Widget>;
253
- parent?: Node;
254
- list: Node[];
255
- data: Record<string, any>;
256
- style: CSSProperties;
257
- hovering: boolean;
258
- dragging: boolean;
259
- constructor(widget: Widget, info?: {
260
- uuid?: string;
261
- props?: Node['data'];
262
- style?: Node['style'];
263
- list?: Node['list'];
264
- });
265
- get info(): {
266
- style: CSSProperties;
267
- };
268
- get isContainer(): boolean;
269
- get hasList(): boolean;
270
- get mouseover(): boolean;
271
- get type(): string;
272
- get name(): string;
273
- get visible(): boolean | undefined;
274
- validate(only?: boolean): Promise<string | undefined>;
275
- triggerHover(hover: boolean): void;
276
- setList(list: Node[]): void;
277
- copy(): Node;
278
- parse(): Record<string, any>;
343
+ interface CapabilityCatalog {
344
+ catalogVersion: '1.0';
345
+ widgets: WidgetCapability[];
279
346
  }
347
+ /**
348
+ * Convert live widget declarations into the stable catalog consumed by DSL
349
+ * validation. Custom schema entries are advertised from the schema itself;
350
+ * executable capabilities must be registered by the host.
351
+ */
352
+ declare function createCapabilityCatalog(widgets: IWidget[], registry?: WidgetCapabilityRegistry): CapabilityCatalog;
353
+ declare function findWidgetCapability(catalog: CapabilityCatalog, type: string): WidgetCapability | undefined;
354
+ declare function findFieldCapability(widget: WidgetCapability, key: string): WidgetFieldCapability | undefined;
355
+ declare function findCustomCapability(widget: WidgetCapability, type: string, name: string): WidgetCustomCapability | undefined;
356
+ declare function listStaticOptions(catalog: CapabilityCatalog, widgetTypes?: string[], types?: string[]): StaticOption[];
280
357
 
281
- export { type Base as B, type DisabledItemFn as D, type EditorConfig as E, type IWidget as I, Node as N, type Option as O, type RadioOption as R, type SchemaItemCustom as S, Widget as W, type RadioButtonOption as a, type SchemaItem as b, type WidgetPos as c, type WidgetLayoutItem as d, type WidgetAgent as e, type SchemaOther as f, type SchemaBox as g, type ISchema as h, isBox as i, type EditorSchema as j, type EditorWidget as k, type EditorRoute as l, type EditorWidgets as m, type EditorSettings as n, type EditorData as o };
358
+ export { type EditorRoute as A, type Base as B, type CapabilityValueType as C, type DisabledItemFn as D, type EditorConfig as E, type FieldScope as F, type EditorWidgets as G, type EditorSettings as H, type IWidget as I, type EditorData as J, Node as N, type Option as O, type RadioOption as R, type SchemaItemCustom as S, Widget as W, type RadioButtonOption as a, type SchemaItem as b, type WidgetFieldCapability as c, type WidgetCustomCapability as d, type WidgetCustomTypeCapability as e, type StaticOption as f, type WidgetCapabilityRegistration as g, type WidgetCapabilityRegistry as h, type WidgetCapability as i, type CapabilityCatalog as j, createCapabilityCatalog as k, findWidgetCapability as l, findFieldCapability as m, findCustomCapability as n, listStaticOptions as o, type WidgetPos as p, type WidgetLayoutItem as q, type WidgetCapabilityExecutionContext as r, type WidgetCapabilityAdapter as s, type WidgetAgent as t, type SchemaOther as u, type SchemaBox as v, type ISchema as w, isBox as x, type EditorSchema as y, type EditorWidget as z };