@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.
@@ -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 r } from "../utils/locale.js";
4
- const b = () => s({
3
+ import { t as a } from "../utils/locale.js";
4
+ const p = () => s({
5
5
  name: "grid_component_tools",
6
- description: r("ai.grid.description"),
6
+ description: a("ai.grid.description"),
7
7
  tools: {
8
8
  scrollToRow: {
9
- paramsSchema: o.number().optional().describe(r("ai.grid.scrollToRow")),
10
- cb: (t, e) => {
11
- const a = t.getTableData().tableData[e];
12
- if (a)
13
- return t.scrollToRow(a), { type: "text", text: "success" };
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(r("ai.grid.getTableData")),
18
- cb: (t) => {
19
- const e = t.getTableData().tableData;
20
- return { type: "text", text: JSON.stringify(e) };
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.number().optional().describe(r("ai.grid.setSelection")),
25
- cb: (t, e) => {
26
- const a = t.getTableData().tableData[e];
27
- if (a)
28
- return t.setSelection(a, !0), { type: "text", text: "success" };
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(r("ai.grid.setAllSelection")),
33
- cb: (t, e) => (t.setAllSelection(e), { type: "text", text: "success" })
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(r("ai.grid.insertRow")),
37
- cb: (t, e) => (t.insert(e), { type: "text", text: "success" })
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(r("ai.grid.updateRow")),
41
- cb: (t, e) => {
42
- if (e && typeof e.tiny_mcp_index == "number") {
43
- const a = t.getTableData().tableData[e.tiny_mcp_index];
44
- if (a)
45
- return Object.assign(a, e), { type: "text", text: "success" };
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.number().optional().describe(r("ai.grid.removeRow")),
52
- cb: (t, e) => {
53
- const a = t.getTableData().tableData[e];
54
- return a ? (t.remove(a), { type: "text", text: "success" }) : { type: "text", text: "failed" };
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
- b as getGridConfig
73
+ p as getGridConfig
61
74
  };
@@ -4,6 +4,7 @@ declare const _default: {
4
4
  description: string;
5
5
  scrollToRow: string;
6
6
  getTableData: string;
7
+ getColumns: string;
7
8
  setSelection: string;
8
9
  setAllSelection: string;
9
10
  insertRow: string;
@@ -1,25 +1,26 @@
1
1
  const e = {
2
2
  ai: {
3
3
  grid: {
4
- description: "Grid component related tool set, including scrolling to the specified row, table full selection, etc.",
5
- scrollToRow: "Scroll to the specified row,need to get the table data first,then scroll to the row according to the index of the data in the table data",
6
- getTableData: "Get the table data",
7
- setSelection: "Select the specified row,need to get the table data first,then select the data according to the index of the data in the table data,requirement:scroll to the selected row before selecting",
8
- setAllSelection: "Set the table all selection status,true:all selection,false:cancel all selection,requirement:scroll to the selected row before selecting",
9
- insertRow: "Insert or add a row of data,need to get the table data first,then add the corresponding data according to the format of the table data",
10
- updateRow: 'Update the specified row data in the table,need to get the table data first,then update the corresponding data according to the index of the data in the table data,requirement:the index of the data in the table data is passed in as the "tiny_mcp_index" field',
11
- removeRow: "Remove the specified row in the table,need to get the table data first,then remove the corresponding data according to the index of the data in the table data"
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: "Base select component related tool set, including opening the drop-down panel,set selected value or clear selected value and get selected options",
15
- openMenu: "Open the drop-down panel",
16
- selectByLabel: "update select value by label",
17
- clearValue: "clear select value,remove value",
18
- getOptions: "get all options of the select component"
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: "trigger button click,click self"
23
+ triggerClick: "Button click, click the button"
23
24
  }
24
25
  }
25
26
  };
@@ -4,6 +4,7 @@ declare const _default: {
4
4
  description: string;
5
5
  scrollToRow: string;
6
6
  getTableData: string;
7
+ getColumns: string;
7
8
  setSelection: string;
8
9
  setAllSelection: string;
9
10
  insertRow: string;
@@ -2,13 +2,14 @@ const e = {
2
2
  ai: {
3
3
  grid: {
4
4
  description: "表格组件相关工具集合,包含滚动到指定行、表格全选等功能",
5
- scrollToRow: "滚动到指定行,要先获取表格数据,然后根据表格数据中的数组下标索引确定滚动行",
5
+ scrollToRow: '滚动到指定行,需要传递需要滚动的行的数据,要求数据中包含"_RID"字段',
6
6
  getTableData: "获取表格数据",
7
- setSelection: "选中或者选择表格一条数据,需要先获取表格数据,然后根据表格数据中的数组下标索引选中或者选择数据,要求:选中之前先滚动到选中行",
7
+ getColumns: '获取表格列配置,"property" 字段代表表格数据的字段属性,"title" 代表表格列的标题',
8
+ setSelection: '选中或者选择表格一条数据,需要传递需要选中的数据,要求:选中之前先滚动到选中行,要求数据中包含"_RID"字段',
8
9
  setAllSelection: "用来设置表格全选状态,true:全选,false:取消全选",
9
10
  insertRow: "插入或者新增一行数据,需要先获取表格数据,根据表格数据的格式新增对应的数据",
10
- updateRow: '更新修改表格中指定行数据,需要先获取表格数据,根据表格数据中的数组下标索引更新对应的数据,要求:将更新数据的数组下标以"tiny_mcp_index"字段传入',
11
- removeRow: "删除表格中指定行,需要先获取表格数据,根据表格数据中的数组下标索引删除对应的数据"
11
+ updateRow: '更新修改表格中指定行数据,需要传递需要更新的数据,要求数据中包含"_RID"字段',
12
+ removeRow: '删除表格中指定行,需要传递需要删除的数据,要求数据中包含"_RID"字段'
12
13
  },
13
14
  baseSelect: {
14
15
  description: "下拉组件相关工具集合,包含获取下拉数据、选中下拉数据,清除选中值等功能",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentiny/tiny-vue-mcp",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "ISC",
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.number().optional().describe(t('ai.grid.scrollToRow')),
18
+ paramsSchema: z.record(z.any()).optional().describe(t('ai.grid.scrollToRow')),
19
19
  cb: (instance, value) => {
20
- const tableData = instance.getTableData().tableData
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.number().optional().describe(t('ai.grid.setSelection')),
49
+ paramsSchema: z.record(z.any()).optional().describe(t('ai.grid.setSelection')),
38
50
  cb: (instance, value) => {
39
- const tableData = instance.getTableData().tableData
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 && typeof value.tiny_mcp_index === 'number') {
65
- const tableData = instance.getTableData().tableData
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.number().optional().describe(t('ai.grid.removeRow')),
86
+ paramsSchema: z.record(z.any()).optional().describe(t('ai.grid.removeRow')),
77
87
  cb: (instance, value) => {
78
- const tableData = instance.getTableData().tableData
79
- const targetRow = tableData[value]
80
- if (targetRow) {
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 the specified row, table full selection, etc.',
5
+ 'Grid component related tool set, including scrolling to specified row, table full selection and other functions',
6
6
  scrollToRow:
7
- 'Scroll to the specified row,need to get the table data first,then scroll to the row according to the index of the data in the table data',
8
- getTableData: 'Get the table data',
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 the specified row,need to get the table data first,then select the data according to the index of the data in the table data,requirement:scroll to the selected row before selecting',
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 the table data first,then add the corresponding data according to the format of the table data',
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 the specified row data in the table,need to get the table data first,then update the corresponding data according to the index of the data in the table data,requirement:the index of the data in the table data is passed in as the "tiny_mcp_index" field',
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 the specified row in the table,need to get the table data first,then remove the corresponding data according to the index of the data in the table data'
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
- 'Base select component related tool set, including opening the drop-down panel,set selected value or clear selected value and get selected options',
23
- openMenu: 'Open the drop-down panel',
24
- selectByLabel: 'update select value by label',
25
- clearValue: 'clear select value,remove value',
26
- getOptions: 'get all options of the select component'
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: 'trigger button click,click self'
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
- '更新修改表格中指定行数据,需要先获取表格数据,根据表格数据中的数组下标索引更新对应的数据,要求:将更新数据的数组下标以"tiny_mcp_index"字段传入',
13
- removeRow: '删除表格中指定行,需要先获取表格数据,根据表格数据中的数组下标索引删除对应的数据'
12
+ updateRow: '更新修改表格中指定行数据,需要传递需要更新的数据,要求数据中包含"_RID"字段',
13
+ removeRow: '删除表格中指定行,需要传递需要删除的数据,要求数据中包含"_RID"字段'
14
14
  },
15
15
  baseSelect: {
16
16
  description: '下拉组件相关工具集合,包含获取下拉数据、选中下拉数据,清除选中值等功能',