@sepveneto/dnde-core 0.6.3 → 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 (48) hide show
  1. package/dist/{Node-B7pDsvZF.d.cts → capability-Ce3qGTm3.d.cts} +198 -127
  2. package/dist/{Node-B7pDsvZF.d.ts → capability-Ce3qGTm3.d.ts} +198 -127
  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-IQ5LOS7W.js +0 -0
  9. package/dist/{chunk-KJZSF66T.js → chunk-RLMXVDJK.js} +1 -16
  10. package/dist/chunk-W7WBD3NX.js +360 -0
  11. package/dist/chunk-XXR7SKZ3.js +132 -0
  12. package/dist/class/Container.d.cts +2 -2
  13. package/dist/class/Container.d.ts +2 -2
  14. package/dist/class/Node.cjs +2 -18
  15. package/dist/class/Node.d.cts +1 -1
  16. package/dist/class/Node.d.ts +1 -1
  17. package/dist/class/Node.js +3 -5
  18. package/dist/class/Widget.d.cts +1 -1
  19. package/dist/class/Widget.d.ts +1 -1
  20. package/dist/class/index.cjs +0 -16
  21. package/dist/class/index.d.cts +2 -2
  22. package/dist/class/index.d.ts +2 -2
  23. package/dist/class/index.js +4 -5
  24. package/dist/dsl.cjs +405 -0
  25. package/dist/dsl.d.cts +85 -0
  26. package/dist/dsl.d.ts +85 -0
  27. package/dist/dsl.js +12 -0
  28. package/dist/helper/index.cjs +2 -0
  29. package/dist/helper/index.d.cts +1 -1
  30. package/dist/helper/index.d.ts +1 -1
  31. package/dist/helper/index.js +1 -1
  32. package/dist/helper/schema.cjs +2 -0
  33. package/dist/helper/schema.d.cts +3 -1
  34. package/dist/helper/schema.d.ts +3 -1
  35. package/dist/helper/schema.js +1 -1
  36. package/dist/helper/widget.d.cts +1 -1
  37. package/dist/helper/widget.d.ts +1 -1
  38. package/dist/index.cjs +693 -0
  39. package/dist/index.d.cts +3 -1
  40. package/dist/index.d.ts +3 -1
  41. package/dist/index.js +34 -1
  42. package/dist/internal.d.cts +2 -2
  43. package/dist/internal.d.ts +2 -2
  44. package/dist/tokens.d.cts +1 -1
  45. package/dist/tokens.d.ts +1 -1
  46. package/dist/types.d.cts +1 -1
  47. package/dist/types.d.ts +1 -1
  48. 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,24 +129,43 @@ 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>;
139
+ }
140
+ interface WidgetCapabilityExecutionContext {
141
+ node: Node;
142
+ args: Record<string, unknown>;
143
+ context: Record<string, unknown>;
19
144
  }
145
+ type WidgetCapabilityAdapter = (input: WidgetCapabilityExecutionContext) => void | Record<string, unknown> | Promise<void | Record<string, unknown>>;
20
146
  interface WidgetAgent {
21
- description: string;
147
+ /**
148
+ * 组件的功能描述。
149
+ * 用于组件检索、用户意图匹配和编辑时的组件定位。
150
+ */
151
+ description?: string;
152
+ /**
153
+ * 初始化页面时使用的布局信息。
154
+ */
22
155
  layout?: {
23
- direction: 'row' | 'column';
24
- density: 'low' | 'medium' | 'high';
25
- priority: 'large';
156
+ /**
157
+ * 组件的布局特征与适用场景。
158
+ */
159
+ description: string;
160
+ estimatedSize: string;
161
+ priority: 'large' | 'medium' | 'small' | 'tiny';
26
162
  };
27
163
  /**
28
164
  * 布局子 Agent 结束、组件创建完成后,由业务侧决定数据如何更新到组件里。
29
165
  *
30
166
  * @param node 已创建的组件节点
31
167
  * @param item 布局结果项(选中的组件 + 元素引用)
168
+ * @param state 当前 Agent Run 的上下文,包含业务工具准备的数据
32
169
  */
33
170
  update?: (node: Node, item: WidgetLayoutItem, state: Record<string, unknown>) => void;
34
171
  }
@@ -154,134 +291,68 @@ interface EditorData {
154
291
  settings?: EditorSettings;
155
292
  }
156
293
 
157
- type Option = InstanceType<typeof ElOption>['$props'];
158
- type RadioOption = InstanceType<typeof ElRadio>['$props'];
159
- type RadioButtonOption = InstanceType<typeof ElRadioButton>['$props'];
160
- interface SchemaItemBase {
161
- /** @private */
162
- _role?: string;
163
- 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';
164
298
  key: string;
165
- formItem?: Partial<FormItemProps>;
166
- rules?: FormItemRule | FormItemRule[];
167
- }
168
- interface SchemaItemInput extends SchemaItemBase {
169
- type: 'input';
170
- attrs?: InputProps;
171
- }
172
- interface SchemaItemSelect extends SchemaItemBase {
173
- type: 'select';
174
- options?: Option[];
175
- attrs?: SelectProps;
176
- link?: Record<string | number, SchemaItem[]>;
177
- }
178
- interface SchemaItemNumber extends SchemaItemBase {
179
- type: 'number';
180
- attrs?: InputNumberProps;
181
- }
182
- interface SchemaItemSwitch extends SchemaItemBase {
183
- type: 'switch';
184
- attrs?: SwitchProps;
185
- }
186
- interface SchemaItemDatetimePicker extends SchemaItemBase {
187
- type: 'datetimePicker';
188
- attrs?: DatePickerProps;
189
- }
190
- interface SchemaItemColorPicker extends SchemaItemBase {
191
- type: 'colorPicker';
192
- attrs?: ColorPickerProps;
193
- }
194
- interface SchemaItemCheckbox extends SchemaItemBase {
195
- type: 'checkbox';
196
- 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;
197
308
  }
198
- interface SchemaItemCustom extends SchemaItemBase {
199
- type: 'custom';
309
+ interface WidgetCustomCapability {
200
310
  name: string;
201
- attrs?: Record<string, any>;
311
+ inputSchema?: Record<string, unknown>;
312
+ semantics: 'append' | 'replace' | 'remove' | 'command';
313
+ idempotent: boolean;
314
+ destructive: boolean;
315
+ writableScope: FieldScope;
202
316
  }
203
- interface SchemaItemStyleNumber extends SchemaItemBase {
204
- type: 'styleNumber';
317
+ interface WidgetCustomTypeCapability {
318
+ type: string;
319
+ capabilities: WidgetCustomCapability[];
205
320
  }
206
- interface SchemaItemRadio extends SchemaItemBase {
207
- type: 'radio';
208
- attrs?: RadioGroupProps;
209
- options?: RadioOption[];
210
- link?: Record<string | number, SchemaItem[]>;
321
+ interface StaticOption {
322
+ id: string;
323
+ name: string;
324
+ aliases: string[];
325
+ value: unknown;
326
+ types: string[];
211
327
  }
212
- interface SchemaItemRadioButton extends SchemaItemBase {
213
- type: 'radioButton';
214
- attrs?: RadioGroupProps;
215
- options?: RadioButtonOption[];
216
- link?: Record<string | number, SchemaItem[]>;
328
+ interface WidgetCapabilityRegistration {
329
+ customTypes?: WidgetCustomTypeCapability[];
330
+ staticOptions?: StaticOption[];
217
331
  }
218
- type SchemaItem = SchemaItemInput | SchemaItemSelect | SchemaItemNumber | SchemaItemSwitch | SchemaItemCustom | SchemaItemStyleNumber | SchemaItemRadio | SchemaItemRadioButton | SchemaItemDatetimePicker | SchemaItemColorPicker | SchemaItemCheckbox;
219
- declare class Widget {
332
+ type WidgetCapabilityRegistry = Record<string, WidgetCapabilityRegistration>;
333
+ interface WidgetCapability {
334
+ type: string;
220
335
  name: string;
221
- view: string;
222
- _data: IWidget;
223
- container: IWidget['container'];
224
- constructor(widget: IWidget);
225
- clone(): Widget;
226
- get icon(): string | undefined;
227
- get props(): SchemaItem[];
228
- get style(): SchemaItem[];
229
- get defaultStyle(): (vue.CSSProperties & WidgetPos) | undefined;
230
- get defaultData(): any[] | Record<string, any> | undefined;
231
- get agent(): WidgetAgent | undefined;
232
- get draggable(): boolean;
233
- get isFixed(): false | "header" | "footer" | undefined;
234
- get visible(): boolean;
235
- get validatorProps(): Validator;
236
- get validatorStyle(): Validator;
237
- }
238
-
239
- declare class Node {
240
- level: number;
241
- wid: string;
242
- widget: Readonly<Widget>;
243
- parent?: Node;
244
- list: Node[];
245
- data: Record<string, any>;
246
- style: CSSProperties;
247
- hovering: boolean;
248
- dragging: boolean;
249
- constructor(widget: Widget, info?: {
250
- uuid?: string;
251
- props?: Node['data'];
252
- style?: Node['style'];
253
- list?: Node['list'];
254
- });
255
- get info(): {
256
- style: CSSProperties;
257
- };
258
- get isContainer(): boolean;
259
- get hasList(): boolean;
260
- get mouseover(): boolean;
261
- get type(): string;
262
- get name(): string;
263
- get visible(): boolean | undefined;
264
- validate(only?: boolean): Promise<string | undefined>;
265
- triggerHover(hover: boolean): void;
266
- setList(list: Node[]): void;
267
- copy(): Node;
268
- parse(): Record<string, any>;
336
+ description: string;
337
+ defaultData: Record<string, any>;
338
+ defaultStyle: Record<string, any>;
339
+ fields: WidgetFieldCapability[];
340
+ customTypes: WidgetCustomTypeCapability[];
341
+ staticOptions: StaticOption[];
269
342
  }
270
- declare class RootNode {
271
- level: number;
272
- wid: string;
273
- widget: Readonly<Widget>;
274
- parent?: Node;
275
- list: any[];
276
- data: Record<string, any>;
277
- style: CSSProperties;
278
- hovering: boolean;
279
- dragging: boolean;
280
- constructor(widget: Widget, info?: {
281
- props?: Node['data'];
282
- style?: Node['style'];
283
- list?: Node['list'];
284
- });
343
+ interface CapabilityCatalog {
344
+ catalogVersion: '1.0';
345
+ widgets: WidgetCapability[];
285
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[];
286
357
 
287
- 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 SchemaOther as S, type WidgetPos as W, type WidgetLayoutItem as a, type WidgetAgent as b, type SchemaBox as c, type ISchema as d, type EditorSchema as e, type EditorWidget as f, type EditorRoute as g, type EditorWidgets as h, isBox as i, type EditorSettings as j, type EditorData as k, type SchemaItem as l, type RadioButtonOption as m, Widget as n, RootNode as o, type SchemaItemCustom as p };
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 };