@opentiny/tiny-vue-mcp 0.0.1 → 0.0.2
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/src/grid/index.js +45 -32
- package/dist/src/lang/en.d.ts +1 -0
- package/dist/src/lang/en.js +15 -14
- package/dist/src/lang/zh-CN.d.ts +1 -0
- package/dist/src/lang/zh-CN.js +5 -4
- package/package.json +1 -1
- package/src/grid/index.ts +23 -14
- package/src/lang/en.ts +16 -15
- package/src/lang/zh-CN.ts +5 -5
package/dist/src/grid/index.js
CHANGED
|
@@ -1,61 +1,74 @@
|
|
|
1
1
|
import { z as o } from "zod";
|
|
2
2
|
import { defineComponentTool as s } from "../utils/defineComponentTool.js";
|
|
3
|
-
import { t as
|
|
4
|
-
const
|
|
3
|
+
import { t as a } from "../utils/locale.js";
|
|
4
|
+
const p = () => s({
|
|
5
5
|
name: "grid_component_tools",
|
|
6
|
-
description:
|
|
6
|
+
description: a("ai.grid.description"),
|
|
7
7
|
tools: {
|
|
8
8
|
scrollToRow: {
|
|
9
|
-
paramsSchema: o.
|
|
10
|
-
cb: (
|
|
11
|
-
const
|
|
12
|
-
if (
|
|
13
|
-
return
|
|
9
|
+
paramsSchema: o.record(o.any()).optional().describe(a("ai.grid.scrollToRow")),
|
|
10
|
+
cb: (e, t) => {
|
|
11
|
+
const r = e.getRowById(t._RID);
|
|
12
|
+
if (r)
|
|
13
|
+
return e.scrollToRow(r), { type: "text", text: "success" };
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
getColumns: {
|
|
17
|
+
paramsSchema: o.boolean().optional().describe(a("ai.grid.getColumns")),
|
|
18
|
+
cb: (e) => {
|
|
19
|
+
const r = e.getColumns().filter((i) => i.property && i.title).map((i) => ({
|
|
20
|
+
property: i.property,
|
|
21
|
+
title: i.title
|
|
22
|
+
}));
|
|
23
|
+
return { type: "text", text: JSON.stringify(r) };
|
|
14
24
|
}
|
|
15
25
|
},
|
|
16
26
|
getTableData: {
|
|
17
|
-
paramsSchema: o.boolean().optional().describe(
|
|
18
|
-
cb: (
|
|
19
|
-
const
|
|
20
|
-
return { type: "text", text: JSON.stringify(
|
|
27
|
+
paramsSchema: o.boolean().optional().describe(a("ai.grid.getTableData")),
|
|
28
|
+
cb: (e) => {
|
|
29
|
+
const t = e.getTableData().tableData;
|
|
30
|
+
return { type: "text", text: JSON.stringify(t) };
|
|
21
31
|
}
|
|
22
32
|
},
|
|
23
33
|
setSelection: {
|
|
24
|
-
paramsSchema: o.
|
|
25
|
-
cb: (
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
28
|
-
return
|
|
34
|
+
paramsSchema: o.record(o.any()).optional().describe(a("ai.grid.setSelection")),
|
|
35
|
+
cb: (e, t) => {
|
|
36
|
+
const r = e.getRowById(t._RID);
|
|
37
|
+
if (r)
|
|
38
|
+
return e.setSelection(r, !0), { type: "text", text: "success" };
|
|
29
39
|
}
|
|
30
40
|
},
|
|
31
41
|
setAllSelection: {
|
|
32
|
-
paramsSchema: o.boolean().optional().describe(
|
|
33
|
-
cb: (
|
|
42
|
+
paramsSchema: o.boolean().optional().describe(a("ai.grid.setAllSelection")),
|
|
43
|
+
cb: (e, t) => (e.setAllSelection(t), { type: "text", text: "success" })
|
|
34
44
|
},
|
|
35
45
|
insertRow: {
|
|
36
|
-
paramsSchema: o.record(o.any()).optional().describe(
|
|
37
|
-
cb: (
|
|
46
|
+
paramsSchema: o.record(o.any()).optional().describe(a("ai.grid.insertRow")),
|
|
47
|
+
cb: (e, t) => (e.insert(t), { type: "text", text: "success" })
|
|
38
48
|
},
|
|
39
49
|
updateRow: {
|
|
40
|
-
paramsSchema: o.record(o.any()).optional().describe(
|
|
41
|
-
cb: (
|
|
42
|
-
if (
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
45
|
-
return Object.assign(
|
|
50
|
+
paramsSchema: o.record(o.any()).optional().describe(a("ai.grid.updateRow")),
|
|
51
|
+
cb: (e, t) => {
|
|
52
|
+
if (t) {
|
|
53
|
+
const r = e.getRowById(t._RID);
|
|
54
|
+
if (r)
|
|
55
|
+
return Object.assign(r, t), { type: "text", text: "success" };
|
|
46
56
|
}
|
|
47
57
|
return { type: "text", text: "failed" };
|
|
48
58
|
}
|
|
49
59
|
},
|
|
50
60
|
removeRow: {
|
|
51
|
-
paramsSchema: o.
|
|
52
|
-
cb: (
|
|
53
|
-
|
|
54
|
-
|
|
61
|
+
paramsSchema: o.record(o.any()).optional().describe(a("ai.grid.removeRow")),
|
|
62
|
+
cb: (e, t) => {
|
|
63
|
+
if (t) {
|
|
64
|
+
const r = e.getRowById(t._RID);
|
|
65
|
+
return e.remove(r), { type: "text", text: "success" };
|
|
66
|
+
}
|
|
67
|
+
return { type: "text", text: "failed" };
|
|
55
68
|
}
|
|
56
69
|
}
|
|
57
70
|
}
|
|
58
71
|
});
|
|
59
72
|
export {
|
|
60
|
-
|
|
73
|
+
p as getGridConfig
|
|
61
74
|
};
|
package/dist/src/lang/en.d.ts
CHANGED
package/dist/src/lang/en.js
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
const e = {
|
|
2
2
|
ai: {
|
|
3
3
|
grid: {
|
|
4
|
-
description: "Grid component related tool set, including scrolling to
|
|
5
|
-
scrollToRow:
|
|
6
|
-
getTableData: "Get
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
description: "Grid component related tool set, including scrolling to specified row, table full selection and other functions",
|
|
5
|
+
scrollToRow: 'Scroll to specified row, need to pass the data of the row to scroll to, requirement: the data must contain the "_RID" field',
|
|
6
|
+
getTableData: "Get table data",
|
|
7
|
+
getColumns: 'Get table column configuration, "property" field represents the field property of table data, "title" represents the column title',
|
|
8
|
+
setSelection: 'Select a row in the table, need to pass the data to be selected, requirement: scroll to the row before selecting, requirement: the data must contain the "_RID" field',
|
|
9
|
+
setAllSelection: "Set table full selection status, true: select all, false: cancel all selection",
|
|
10
|
+
insertRow: "Insert or add a row of data, need to get table data first, then add corresponding data according to the table data format",
|
|
11
|
+
updateRow: 'Update specified row data in the table, need to pass the data to be updated, requirement: the data must contain the "_RID" field',
|
|
12
|
+
removeRow: 'Remove specified row in the table, need to pass the data to be removed, requirement: the data must contain the "_RID" field'
|
|
12
13
|
},
|
|
13
14
|
baseSelect: {
|
|
14
|
-
description: "
|
|
15
|
-
openMenu: "Open
|
|
16
|
-
selectByLabel: "
|
|
17
|
-
clearValue: "
|
|
18
|
-
getOptions: "
|
|
15
|
+
description: "Dropdown component related tool set, including getting dropdown data, selecting dropdown data, clearing selected value and other functions",
|
|
16
|
+
openMenu: "Open dropdown panel",
|
|
17
|
+
selectByLabel: "Select dropdown data by label",
|
|
18
|
+
clearValue: "Clear dropdown value",
|
|
19
|
+
getOptions: "Query all option values of the dropdown select"
|
|
19
20
|
},
|
|
20
21
|
button: {
|
|
21
22
|
description: "Button component related tool set",
|
|
22
|
-
triggerClick: "
|
|
23
|
+
triggerClick: "Button click, click the button"
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
};
|
package/dist/src/lang/zh-CN.d.ts
CHANGED
package/dist/src/lang/zh-CN.js
CHANGED
|
@@ -2,13 +2,14 @@ const e = {
|
|
|
2
2
|
ai: {
|
|
3
3
|
grid: {
|
|
4
4
|
description: "表格组件相关工具集合,包含滚动到指定行、表格全选等功能",
|
|
5
|
-
scrollToRow: "
|
|
5
|
+
scrollToRow: '滚动到指定行,需要传递需要滚动的行的数据,要求数据中包含"_RID"字段',
|
|
6
6
|
getTableData: "获取表格数据",
|
|
7
|
-
|
|
7
|
+
getColumns: '获取表格列配置,"property" 字段代表表格数据的字段属性,"title" 代表表格列的标题',
|
|
8
|
+
setSelection: '选中或者选择表格一条数据,需要传递需要选中的数据,要求:选中之前先滚动到选中行,要求数据中包含"_RID"字段',
|
|
8
9
|
setAllSelection: "用来设置表格全选状态,true:全选,false:取消全选",
|
|
9
10
|
insertRow: "插入或者新增一行数据,需要先获取表格数据,根据表格数据的格式新增对应的数据",
|
|
10
|
-
updateRow: '
|
|
11
|
-
removeRow: "
|
|
11
|
+
updateRow: '更新修改表格中指定行数据,需要传递需要更新的数据,要求数据中包含"_RID"字段',
|
|
12
|
+
removeRow: '删除表格中指定行,需要传递需要删除的数据,要求数据中包含"_RID"字段'
|
|
12
13
|
},
|
|
13
14
|
baseSelect: {
|
|
14
15
|
description: "下拉组件相关工具集合,包含获取下拉数据、选中下拉数据,清除选中值等功能",
|
package/package.json
CHANGED
package/src/grid/index.ts
CHANGED
|
@@ -15,16 +15,28 @@ export const getGridConfig = () =>
|
|
|
15
15
|
description: t('ai.grid.description'),
|
|
16
16
|
tools: {
|
|
17
17
|
scrollToRow: {
|
|
18
|
-
paramsSchema: z.
|
|
18
|
+
paramsSchema: z.record(z.any()).optional().describe(t('ai.grid.scrollToRow')),
|
|
19
19
|
cb: (instance, value) => {
|
|
20
|
-
const
|
|
21
|
-
const targetRow = tableData[value]
|
|
20
|
+
const targetRow = instance.getRowById(value._RID)
|
|
22
21
|
if (targetRow) {
|
|
23
22
|
instance.scrollToRow(targetRow)
|
|
24
23
|
return { type: 'text', text: 'success' }
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
26
|
},
|
|
27
|
+
getColumns: {
|
|
28
|
+
paramsSchema: z.boolean().optional().describe(t('ai.grid.getColumns')),
|
|
29
|
+
cb: (instance) => {
|
|
30
|
+
const columns = instance.getColumns()
|
|
31
|
+
const result = columns
|
|
32
|
+
.filter((col: any) => col.property && col.title)
|
|
33
|
+
.map((column: any) => ({
|
|
34
|
+
property: column.property,
|
|
35
|
+
title: column.title
|
|
36
|
+
}))
|
|
37
|
+
return { type: 'text', text: JSON.stringify(result) }
|
|
38
|
+
}
|
|
39
|
+
},
|
|
28
40
|
getTableData: {
|
|
29
41
|
paramsSchema: z.boolean().optional().describe(t('ai.grid.getTableData')),
|
|
30
42
|
cb: (instance) => {
|
|
@@ -34,10 +46,9 @@ export const getGridConfig = () =>
|
|
|
34
46
|
}
|
|
35
47
|
},
|
|
36
48
|
setSelection: {
|
|
37
|
-
paramsSchema: z.
|
|
49
|
+
paramsSchema: z.record(z.any()).optional().describe(t('ai.grid.setSelection')),
|
|
38
50
|
cb: (instance, value) => {
|
|
39
|
-
const
|
|
40
|
-
const targetRow = tableData[value]
|
|
51
|
+
const targetRow = instance.getRowById(value._RID)
|
|
41
52
|
if (targetRow) {
|
|
42
53
|
instance.setSelection(targetRow, true)
|
|
43
54
|
return { type: 'text', text: 'success' }
|
|
@@ -61,9 +72,8 @@ export const getGridConfig = () =>
|
|
|
61
72
|
updateRow: {
|
|
62
73
|
paramsSchema: z.record(z.any()).optional().describe(t('ai.grid.updateRow')),
|
|
63
74
|
cb: (instance, value) => {
|
|
64
|
-
if (value
|
|
65
|
-
const
|
|
66
|
-
const targetRow = tableData[value.tiny_mcp_index]
|
|
75
|
+
if (value) {
|
|
76
|
+
const targetRow = instance.getRowById(value._RID)
|
|
67
77
|
if (targetRow) {
|
|
68
78
|
Object.assign(targetRow, value)
|
|
69
79
|
return { type: 'text', text: 'success' }
|
|
@@ -73,12 +83,11 @@ export const getGridConfig = () =>
|
|
|
73
83
|
}
|
|
74
84
|
},
|
|
75
85
|
removeRow: {
|
|
76
|
-
paramsSchema: z.
|
|
86
|
+
paramsSchema: z.record(z.any()).optional().describe(t('ai.grid.removeRow')),
|
|
77
87
|
cb: (instance, value) => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
instance.remove(targetRow)
|
|
88
|
+
if (value) {
|
|
89
|
+
const row = instance.getRowById(value._RID)
|
|
90
|
+
instance.remove(row)
|
|
82
91
|
return { type: 'text', text: 'success' }
|
|
83
92
|
}
|
|
84
93
|
return { type: 'text', text: 'failed' }
|
package/src/lang/en.ts
CHANGED
|
@@ -2,32 +2,33 @@ export default {
|
|
|
2
2
|
ai: {
|
|
3
3
|
grid: {
|
|
4
4
|
description:
|
|
5
|
-
'Grid component related tool set, including scrolling to
|
|
5
|
+
'Grid component related tool set, including scrolling to specified row, table full selection and other functions',
|
|
6
6
|
scrollToRow:
|
|
7
|
-
'Scroll to
|
|
8
|
-
getTableData: 'Get
|
|
7
|
+
'Scroll to specified row, need to pass the data of the row to scroll to, requirement: the data must contain the "_RID" field',
|
|
8
|
+
getTableData: 'Get table data',
|
|
9
|
+
getColumns:
|
|
10
|
+
'Get table column configuration, "property" field represents the field property of table data, "title" represents the column title',
|
|
9
11
|
setSelection:
|
|
10
|
-
'Select
|
|
11
|
-
setAllSelection:
|
|
12
|
-
'Set the table all selection status,true:all selection,false:cancel all selection,requirement:scroll to the selected row before selecting',
|
|
12
|
+
'Select a row in the table, need to pass the data to be selected, requirement: scroll to the row before selecting, requirement: the data must contain the "_RID" field',
|
|
13
|
+
setAllSelection: 'Set table full selection status, true: select all, false: cancel all selection',
|
|
13
14
|
insertRow:
|
|
14
|
-
'Insert or add a row of data,need to get
|
|
15
|
+
'Insert or add a row of data, need to get table data first, then add corresponding data according to the table data format',
|
|
15
16
|
updateRow:
|
|
16
|
-
'Update
|
|
17
|
+
'Update specified row data in the table, need to pass the data to be updated, requirement: the data must contain the "_RID" field',
|
|
17
18
|
removeRow:
|
|
18
|
-
'Remove
|
|
19
|
+
'Remove specified row in the table, need to pass the data to be removed, requirement: the data must contain the "_RID" field'
|
|
19
20
|
},
|
|
20
21
|
baseSelect: {
|
|
21
22
|
description:
|
|
22
|
-
'
|
|
23
|
-
openMenu: 'Open
|
|
24
|
-
selectByLabel: '
|
|
25
|
-
clearValue: '
|
|
26
|
-
getOptions: '
|
|
23
|
+
'Dropdown component related tool set, including getting dropdown data, selecting dropdown data, clearing selected value and other functions',
|
|
24
|
+
openMenu: 'Open dropdown panel',
|
|
25
|
+
selectByLabel: 'Select dropdown data by label',
|
|
26
|
+
clearValue: 'Clear dropdown value',
|
|
27
|
+
getOptions: 'Query all option values of the dropdown select'
|
|
27
28
|
},
|
|
28
29
|
button: {
|
|
29
30
|
description: 'Button component related tool set',
|
|
30
|
-
triggerClick: '
|
|
31
|
+
triggerClick: 'Button click, click the button'
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
}
|
package/src/lang/zh-CN.ts
CHANGED
|
@@ -2,15 +2,15 @@ export default {
|
|
|
2
2
|
ai: {
|
|
3
3
|
grid: {
|
|
4
4
|
description: '表格组件相关工具集合,包含滚动到指定行、表格全选等功能',
|
|
5
|
-
scrollToRow: '
|
|
5
|
+
scrollToRow: '滚动到指定行,需要传递需要滚动的行的数据,要求数据中包含"_RID"字段',
|
|
6
6
|
getTableData: '获取表格数据',
|
|
7
|
+
getColumns: '获取表格列配置,"property" 字段代表表格数据的字段属性,"title" 代表表格列的标题',
|
|
7
8
|
setSelection:
|
|
8
|
-
'
|
|
9
|
+
'选中或者选择表格一条数据,需要传递需要选中的数据,要求:选中之前先滚动到选中行,要求数据中包含"_RID"字段',
|
|
9
10
|
setAllSelection: '用来设置表格全选状态,true:全选,false:取消全选',
|
|
10
11
|
insertRow: '插入或者新增一行数据,需要先获取表格数据,根据表格数据的格式新增对应的数据',
|
|
11
|
-
updateRow:
|
|
12
|
-
|
|
13
|
-
removeRow: '删除表格中指定行,需要先获取表格数据,根据表格数据中的数组下标索引删除对应的数据'
|
|
12
|
+
updateRow: '更新修改表格中指定行数据,需要传递需要更新的数据,要求数据中包含"_RID"字段',
|
|
13
|
+
removeRow: '删除表格中指定行,需要传递需要删除的数据,要求数据中包含"_RID"字段'
|
|
14
14
|
},
|
|
15
15
|
baseSelect: {
|
|
16
16
|
description: '下拉组件相关工具集合,包含获取下拉数据、选中下拉数据,清除选中值等功能',
|