@progress/kendo-react-webmcp 15.0.1-develop.3 → 15.0.1-develop.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.
- package/WebMcpProvider.js +1 -1
- package/WebMcpProvider.mjs +84 -80
- package/adapters/button.d.ts +1 -1
- package/adapters/button.js +1 -1
- package/adapters/button.mjs +12 -17
- package/adapters/{dashboard.d.ts → checkbox.d.ts} +5 -6
- package/adapters/checkbox.js +8 -0
- package/adapters/checkbox.mjs +60 -0
- package/adapters/dropdowntree.js +1 -1
- package/adapters/dropdowntree.mjs +78 -51
- package/adapters/editor.d.ts +0 -1
- package/adapters/editor.js +1 -1
- package/adapters/editor.mjs +38 -46
- package/adapters/form.d.ts +1 -0
- package/adapters/form.js +3 -3
- package/adapters/form.mjs +75 -49
- package/adapters/gantt.d.ts +2 -0
- package/adapters/gantt.js +1 -1
- package/adapters/gantt.mjs +188 -140
- package/adapters/grid.d.ts +0 -1
- package/adapters/grid.js +1 -1
- package/adapters/grid.mjs +52 -60
- package/adapters/multicolumncombobox.d.ts +20 -0
- package/adapters/multicolumncombobox.js +8 -0
- package/adapters/multicolumncombobox.mjs +75 -0
- package/adapters/multiselect.d.ts +2 -0
- package/adapters/multiselect.js +1 -1
- package/adapters/multiselect.mjs +46 -30
- package/adapters/notification.js +1 -1
- package/adapters/notification.mjs +14 -14
- package/adapters/pivotgrid.js +1 -1
- package/adapters/pivotgrid.mjs +39 -47
- package/adapters/scheduler.js +1 -1
- package/adapters/scheduler.mjs +137 -92
- package/adapters/spreadsheet.js +1 -1
- package/adapters/spreadsheet.mjs +3 -3
- package/adapters/switch.js +1 -1
- package/adapters/switch.mjs +29 -19
- package/adapters/treeview.js +2 -2
- package/adapters/treeview.mjs +79 -113
- package/adapters/window.d.ts +0 -2
- package/adapters/window.js +1 -1
- package/adapters/window.mjs +29 -63
- package/commands/form.d.ts +4 -1
- package/commands/form.js +1 -1
- package/commands/form.mjs +11 -7
- package/commands/gantt.js +1 -1
- package/commands/gantt.mjs +14 -10
- package/commands/grid.d.ts +0 -4
- package/commands/grid.js +1 -1
- package/commands/grid.mjs +18 -24
- package/commands/index.d.ts +0 -1
- package/commands/pivotgrid.d.ts +0 -4
- package/commands/pivotgrid.js +1 -1
- package/commands/pivotgrid.mjs +6 -12
- package/commands/scheduler.d.ts +10 -0
- package/commands/scheduler.js +1 -1
- package/commands/scheduler.mjs +16 -4
- package/commands/window.d.ts +0 -8
- package/commands/window.js +1 -1
- package/commands/window.mjs +8 -18
- package/dist/cdn/js/kendo-react-webmcp.js +1 -1
- package/index.d.mts +2 -1
- package/index.d.ts +2 -1
- package/index.js +1 -1
- package/index.mjs +248 -249
- package/package.json +3 -3
- package/schemas/gantt.d.ts +4 -0
- package/schemas/gantt.js +1 -1
- package/schemas/gantt.mjs +93 -8
- package/schemas/scheduler.d.ts +2 -0
- package/schemas/scheduler.js +1 -1
- package/schemas/scheduler.mjs +21 -5
- package/adapters/dashboard.js +0 -8
- package/adapters/dashboard.mjs +0 -41
- package/commands/dashboard.d.ts +0 -19
- package/commands/dashboard.js +0 -8
- package/commands/dashboard.mjs +0 -21
package/adapters/editor.d.ts
CHANGED
package/adapters/editor.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../commands/editor.js"),c=require("@progress/kendo-react-editor"),
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../commands/editor.js"),c=require("@progress/kendo-react-editor"),H={componentSuffix:"editor",createTools(t,p,r,v){const d=[],y=e=>`${r.groupName}_${e}`,x=p.current,m=!!(t!=null&&t.view),u=!!x.onChange,l=[{name:"get_content",description:`Get the current HTML content of the ${r.dataName} editor.`,commandType:i.EditorCommands.GetValue,enabled:!1},{name:"set_content",description:`Replace the entire content of the ${r.dataName} editor with the provided HTML.`,commandType:i.EditorCommands.SetValue,enabled:m||u},{name:"insert_html",description:`Insert HTML content at the cursor position in the ${r.dataName} editor.`,commandType:i.EditorCommands.SetValue,enabled:m||u},{name:"clear_content",description:`Clear all content from the ${r.dataName} editor.`,commandType:i.EditorCommands.GetValue,enabled:m||u}],s=p.current.webMcp,f=typeof s=="object"&&s!==null&&typeof s.tools=="function"?s.tools:void 0,w=f?f(l):l,a={content:[{type:"text",text:"Editor ref or view not available."}],isError:!0};function E(){return t!=null&&t.view?{content:[{type:"text",text:c.EditorUtils.getHtml(t.view.state)||"(empty)"}]}:a}function T(e){if(!(t!=null&&t.view))return a;const o=e.value;return o==null?{content:[{type:"text",text:"Missing required argument: value"}],isError:!0}:(c.EditorUtils.setHtml(t.view,o),{content:[{type:"text",text:"Content replaced."}]})}function C(e){if(!(t!=null&&t.view))return a;const o=e.value;if(!o)return{content:[{type:"text",text:"Missing required argument: value"}],isError:!0};const n=c.EditorUtils.createDocument(t.view.state.schema,o);return n&&c.EditorUtils.insertNode(t.view,n),{content:[{type:"text",text:"HTML inserted at cursor position."}]}}function b(){return t!=null&&t.view?(c.EditorUtils.setHtml(t.view,""),{content:[{type:"text",text:"Content cleared."}]}):a}const g=(e,o,n)=>{switch(o){case"get_content":return E();case"set_content":return T(n);case"insert_html":return C(n);case"clear_content":return b();default:return{content:[{type:"text",text:`Unknown command: ${o}`}],isError:!0}}};for(const e of w){if(!e.enabled)continue;const o=i.getEditorToolSchema(e.commandType),n=e.commandType,M=e.name;try{d.push(v.registerTool({name:y(e.name),description:e.description,inputSchema:o,execute:_=>Promise.resolve(g(n,M,_||{}))}))}catch{}}return d}};exports.editorAdapter=H;
|
package/adapters/editor.mjs
CHANGED
|
@@ -5,105 +5,97 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import { EditorCommands as
|
|
9
|
-
import { EditorUtils as
|
|
10
|
-
const
|
|
8
|
+
import { EditorCommands as m, getEditorToolSchema as M } from "../commands/editor.mjs";
|
|
9
|
+
import { EditorUtils as c } from "@progress/kendo-react-editor";
|
|
10
|
+
const S = {
|
|
11
11
|
componentSuffix: "editor",
|
|
12
|
-
createTools(t, p,
|
|
13
|
-
const
|
|
12
|
+
createTools(t, p, r, v) {
|
|
13
|
+
const l = [], x = (e) => `${r.groupName}_${e}`, y = p.current, u = !!(t != null && t.view), a = !!y.onChange, f = [
|
|
14
14
|
{
|
|
15
15
|
name: "get_content",
|
|
16
|
-
description: `Get the current HTML content of the ${
|
|
17
|
-
commandType:
|
|
18
|
-
enabled: !
|
|
16
|
+
description: `Get the current HTML content of the ${r.dataName} editor.`,
|
|
17
|
+
commandType: m.GetValue,
|
|
18
|
+
enabled: !1
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
name: "set_content",
|
|
22
|
-
description: `Replace the entire content of the ${
|
|
23
|
-
commandType:
|
|
22
|
+
description: `Replace the entire content of the ${r.dataName} editor with the provided HTML.`,
|
|
23
|
+
commandType: m.SetValue,
|
|
24
24
|
enabled: u || a
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
name: "insert_html",
|
|
28
|
-
description: `Insert HTML content at the cursor position in the ${
|
|
29
|
-
commandType:
|
|
28
|
+
description: `Insert HTML content at the cursor position in the ${r.dataName} editor.`,
|
|
29
|
+
commandType: m.SetValue,
|
|
30
30
|
enabled: u || a
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
33
|
name: "clear_content",
|
|
34
|
-
description: `Clear all content from the ${
|
|
35
|
-
commandType:
|
|
34
|
+
description: `Clear all content from the ${r.dataName} editor.`,
|
|
35
|
+
commandType: m.GetValue,
|
|
36
36
|
enabled: u || a
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: "export_pdf",
|
|
40
|
-
description: `Export the ${n.dataName} editor content to PDF.`,
|
|
41
|
-
commandType: c.GetValue,
|
|
42
|
-
enabled: !!(t != null && t.exportToPdf)
|
|
43
37
|
}
|
|
44
|
-
],
|
|
38
|
+
], i = p.current.webMcp, d = typeof i == "object" && i !== null && typeof i.tools == "function" ? i.tools : void 0, w = d ? d(f) : f, s = {
|
|
45
39
|
content: [{ type: "text", text: "Editor ref or view not available." }],
|
|
46
40
|
isError: !0
|
|
47
41
|
};
|
|
48
|
-
function
|
|
49
|
-
return t != null && t.view ? { content: [{ type: "text", text:
|
|
42
|
+
function T() {
|
|
43
|
+
return t != null && t.view ? { content: [{ type: "text", text: c.getHtml(t.view.state) || "(empty)" }] } : s;
|
|
50
44
|
}
|
|
51
45
|
function C(e) {
|
|
52
46
|
if (!(t != null && t.view))
|
|
53
|
-
return
|
|
47
|
+
return s;
|
|
54
48
|
const o = e.value;
|
|
55
|
-
return o == null ? { content: [{ type: "text", text: "Missing required argument: value" }], isError: !0 } : (
|
|
49
|
+
return o == null ? { content: [{ type: "text", text: "Missing required argument: value" }], isError: !0 } : (c.setHtml(t.view, o), { content: [{ type: "text", text: "Content replaced." }] });
|
|
56
50
|
}
|
|
57
51
|
function b(e) {
|
|
58
52
|
if (!(t != null && t.view))
|
|
59
|
-
return
|
|
53
|
+
return s;
|
|
60
54
|
const o = e.value;
|
|
61
55
|
if (!o)
|
|
62
56
|
return { content: [{ type: "text", text: "Missing required argument: value" }], isError: !0 };
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return
|
|
57
|
+
const n = c.createDocument(
|
|
58
|
+
t.view.state.schema,
|
|
59
|
+
o
|
|
60
|
+
);
|
|
61
|
+
return n && c.insertNode(t.view, n), { content: [{ type: "text", text: "HTML inserted at cursor position." }] };
|
|
68
62
|
}
|
|
69
63
|
function g() {
|
|
70
|
-
return t
|
|
64
|
+
return t != null && t.view ? (c.setHtml(t.view, ""), { content: [{ type: "text", text: "Content cleared." }] }) : s;
|
|
71
65
|
}
|
|
72
|
-
const
|
|
66
|
+
const E = (e, o, n) => {
|
|
73
67
|
switch (o) {
|
|
74
68
|
case "get_content":
|
|
75
|
-
return
|
|
69
|
+
return T();
|
|
76
70
|
case "set_content":
|
|
77
|
-
return C(
|
|
71
|
+
return C(n);
|
|
78
72
|
case "insert_html":
|
|
79
|
-
return b(
|
|
73
|
+
return b(n);
|
|
80
74
|
case "clear_content":
|
|
81
|
-
return E();
|
|
82
|
-
case "export_pdf":
|
|
83
75
|
return g();
|
|
84
76
|
default:
|
|
85
77
|
return { content: [{ type: "text", text: `Unknown command: ${o}` }], isError: !0 };
|
|
86
78
|
}
|
|
87
79
|
};
|
|
88
|
-
for (const e of
|
|
80
|
+
for (const e of w) {
|
|
89
81
|
if (!e.enabled)
|
|
90
82
|
continue;
|
|
91
|
-
const o =
|
|
83
|
+
const o = M(e.commandType), n = e.commandType, _ = e.name;
|
|
92
84
|
try {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
name:
|
|
85
|
+
l.push(
|
|
86
|
+
v.registerTool({
|
|
87
|
+
name: x(e.name),
|
|
96
88
|
description: e.description,
|
|
97
89
|
inputSchema: o,
|
|
98
|
-
execute: (
|
|
90
|
+
execute: (H) => Promise.resolve(E(n, _, H || {}))
|
|
99
91
|
})
|
|
100
92
|
);
|
|
101
93
|
} catch {
|
|
102
94
|
}
|
|
103
95
|
}
|
|
104
|
-
return
|
|
96
|
+
return l;
|
|
105
97
|
}
|
|
106
98
|
};
|
|
107
99
|
export {
|
|
108
|
-
|
|
100
|
+
S as editorAdapter
|
|
109
101
|
};
|
package/adapters/form.d.ts
CHANGED
package/adapters/form.js
CHANGED
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
9
|
-
`+
|
|
10
|
-
`)}]}}function C(t){if(!t)return{content:[{type:"text",text:"Form ref not available."}],isError:!0};const n={preventDefault:()=>{},stopPropagation:()=>{}};return t.onSubmit(n),{content:[{type:"text",text:"Form submitted."}]}}function $(t){return t?(t.onReset(),{content:[{type:"text",text:"Form reset to initial values."}]}):{content:[{type:"text",text:"Form ref not available."}],isError:!0}}const
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../commands/form.js");function v(t,n){var u;if(!n)return{content:[{type:"text",text:"Form ref not available."}],isError:!0};const o=t.values,r=o&&typeof o=="object"&&!Array.isArray(o)?o:Object.fromEntries(Object.entries(t).filter(([e])=>e!=="values"&&e!=="target"&&e!=="syntheticEvent"));if(!r||typeof r!="object"||Object.keys(r).length===0)return{content:[{type:"text",text:"Missing required argument: values (object)"}],isError:!0};const s=new Set(n.fields||[]),f=s.size>0,a=[];for(const[e,l]of Object.entries(r)){if(f&&!s.has(e)){a.push(e);continue}n.onChange(e,{value:l}),(u=n.onBlur)==null||u.call(n,e,!0)}const m=Object.keys(r).filter(e=>!a.includes(e));return m.length===0?{content:[{type:"text",text:"No matching form fields were filled."}],isError:!0}:a.length>0?{content:[{type:"text",text:`Filled ${m.length} field(s): ${m.join(", ")}. Skipped unknown field(s): ${a.join(", ")}.`}]}:{content:[{type:"text",text:`Filled ${m.length} field(s): ${m.join(", ")}.`}]}}function j(t){if(!t)return{content:[{type:"text",text:"Form ref not available."}],isError:!0};(t.fields||[]).forEach(r=>{var s;return(s=t.onBlur)==null?void 0:s.call(t,r)});const n=t.errors||{},o=Object.entries(n).filter(([,r])=>!!r);return o.length===0?{content:[{type:"text",text:"Form is valid."}]}:{content:[{type:"text",text:`Validation errors:
|
|
9
|
+
`+o.map(([r,s])=>` ${r}: ${s}`).join(`
|
|
10
|
+
`)}]}}function C(t){if(!t)return{content:[{type:"text",text:"Form ref not available."}],isError:!0};const n={preventDefault:()=>{},stopPropagation:()=>{}};return t.onSubmit(n),{content:[{type:"text",text:"Form submitted."}]}}function $(t){return t?(t.onReset(),{content:[{type:"text",text:"Form reset to initial values."}]}):{content:[{type:"text",text:"Form ref not available."}],isError:!0}}const g={componentSuffix:"form",createTools(t,n,o,r){const s=[],f=i=>`${o.groupName}_${i}`,a=(t==null?void 0:t.fields)||[],m=a.length>0?` Available fields: ${a.join(", ")}.`:"",u=[{name:"fill",description:`Fill the ${o.dataName} form fields with the provided values.${m}`,commandType:c.FormCommands.Fill,enabled:!0},{name:"validate",description:`Validate the ${o.dataName} form and return any errors.`,commandType:c.FormCommands.Validate,enabled:!0},{name:"submit",description:`Submit the ${o.dataName} form.`,commandType:c.FormCommands.Submit,enabled:!0},{name:"reset",description:`Reset the ${o.dataName} form to its initial values.`,commandType:c.FormCommands.Reset,enabled:!0}],e=n.current.webMcp,l=typeof e=="object"&&e!==null&&typeof e.tools=="function"?e.tools:void 0,y=l?l(u):u,b=async(i,d)=>{switch(i){case c.FormCommands.Fill:return v(d,t);case c.FormCommands.Validate:return j(t);case c.FormCommands.Submit:return C(t);case c.FormCommands.Reset:return $(t);default:return{content:[{type:"text",text:`Unknown command: ${i}`}],isError:!0}}};for(const i of y){if(!i.enabled)continue;const d=i.inputSchema||c.getFormToolSchema(i.commandType,a),F=i.commandType,x=i.execute;try{s.push(r.registerTool({name:f(i.name),description:i.description,inputSchema:d,execute:x?async p=>await x(p||{}):async p=>b(F,p||{})}))}catch{}}return s}};exports.formAdapter=g;
|
package/adapters/form.mjs
CHANGED
|
@@ -5,111 +5,137 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import { FormCommands as
|
|
9
|
-
function
|
|
10
|
-
|
|
8
|
+
import { FormCommands as a, getFormToolSchema as F } from "../commands/form.mjs";
|
|
9
|
+
function $(t, r) {
|
|
10
|
+
var m;
|
|
11
|
+
if (!r)
|
|
11
12
|
return { content: [{ type: "text", text: "Form ref not available." }], isError: !0 };
|
|
12
|
-
const
|
|
13
|
-
|
|
13
|
+
const o = t.values, n = o && typeof o == "object" && !Array.isArray(o) ? o : Object.fromEntries(
|
|
14
|
+
Object.entries(t).filter(
|
|
15
|
+
([e]) => e !== "values" && e !== "target" && e !== "syntheticEvent"
|
|
16
|
+
)
|
|
17
|
+
);
|
|
18
|
+
if (!n || typeof n != "object" || Object.keys(n).length === 0)
|
|
14
19
|
return { content: [{ type: "text", text: "Missing required argument: values (object)" }], isError: !0 };
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
const s = new Set(r.fields || []), f = s.size > 0, c = [];
|
|
21
|
+
for (const [e, l] of Object.entries(n)) {
|
|
22
|
+
if (f && !s.has(e)) {
|
|
23
|
+
c.push(e);
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
r.onChange(e, { value: l }), (m = r.onBlur) == null || m.call(r, e, !0);
|
|
27
|
+
}
|
|
28
|
+
const u = Object.keys(n).filter((e) => !c.includes(e));
|
|
29
|
+
return u.length === 0 ? {
|
|
30
|
+
content: [{ type: "text", text: "No matching form fields were filled." }],
|
|
31
|
+
isError: !0
|
|
32
|
+
} : c.length > 0 ? {
|
|
18
33
|
content: [
|
|
19
|
-
{
|
|
34
|
+
{
|
|
35
|
+
type: "text",
|
|
36
|
+
text: `Filled ${u.length} field(s): ${u.join(
|
|
37
|
+
", "
|
|
38
|
+
)}. Skipped unknown field(s): ${c.join(", ")}.`
|
|
39
|
+
}
|
|
20
40
|
]
|
|
41
|
+
} : {
|
|
42
|
+
content: [{ type: "text", text: `Filled ${u.length} field(s): ${u.join(", ")}.` }]
|
|
21
43
|
};
|
|
22
44
|
}
|
|
23
|
-
function
|
|
45
|
+
function j(t) {
|
|
24
46
|
if (!t)
|
|
25
47
|
return { content: [{ type: "text", text: "Form ref not available." }], isError: !0 };
|
|
26
|
-
|
|
27
|
-
|
|
48
|
+
(t.fields || []).forEach((n) => {
|
|
49
|
+
var s;
|
|
50
|
+
return (s = t.onBlur) == null ? void 0 : s.call(t, n);
|
|
51
|
+
});
|
|
52
|
+
const r = t.errors || {}, o = Object.entries(r).filter(([, n]) => !!n);
|
|
53
|
+
return o.length === 0 ? { content: [{ type: "text", text: "Form is valid." }] } : {
|
|
28
54
|
content: [
|
|
29
55
|
{
|
|
30
56
|
type: "text",
|
|
31
57
|
text: `Validation errors:
|
|
32
|
-
` +
|
|
58
|
+
` + o.map(([n, s]) => ` ${n}: ${s}`).join(`
|
|
33
59
|
`)
|
|
34
60
|
}
|
|
35
61
|
]
|
|
36
62
|
};
|
|
37
63
|
}
|
|
38
|
-
function
|
|
64
|
+
function g(t) {
|
|
39
65
|
if (!t)
|
|
40
66
|
return { content: [{ type: "text", text: "Form ref not available." }], isError: !0 };
|
|
41
|
-
const
|
|
67
|
+
const r = {
|
|
42
68
|
preventDefault: () => {
|
|
43
69
|
},
|
|
44
70
|
stopPropagation: () => {
|
|
45
71
|
}
|
|
46
72
|
};
|
|
47
|
-
return t.onSubmit(
|
|
73
|
+
return t.onSubmit(r), { content: [{ type: "text", text: "Form submitted." }] };
|
|
48
74
|
}
|
|
49
|
-
function
|
|
75
|
+
function E(t) {
|
|
50
76
|
return t ? (t.onReset(), { content: [{ type: "text", text: "Form reset to initial values." }] }) : { content: [{ type: "text", text: "Form ref not available." }], isError: !0 };
|
|
51
77
|
}
|
|
52
|
-
const
|
|
78
|
+
const S = {
|
|
53
79
|
componentSuffix: "form",
|
|
54
|
-
createTools(t,
|
|
55
|
-
const
|
|
80
|
+
createTools(t, r, o, n) {
|
|
81
|
+
const s = [], f = (i) => `${o.groupName}_${i}`, c = (t == null ? void 0 : t.fields) || [], u = c.length > 0 ? ` Available fields: ${c.join(", ")}.` : "", m = [
|
|
56
82
|
{
|
|
57
83
|
name: "fill",
|
|
58
|
-
description: `Fill the ${
|
|
59
|
-
commandType:
|
|
84
|
+
description: `Fill the ${o.dataName} form fields with the provided values.${u}`,
|
|
85
|
+
commandType: a.Fill,
|
|
60
86
|
enabled: !0
|
|
61
87
|
},
|
|
62
88
|
{
|
|
63
89
|
name: "validate",
|
|
64
|
-
description: `Validate the ${
|
|
65
|
-
commandType:
|
|
90
|
+
description: `Validate the ${o.dataName} form and return any errors.`,
|
|
91
|
+
commandType: a.Validate,
|
|
66
92
|
enabled: !0
|
|
67
93
|
},
|
|
68
94
|
{
|
|
69
95
|
name: "submit",
|
|
70
|
-
description: `Submit the ${
|
|
71
|
-
commandType:
|
|
96
|
+
description: `Submit the ${o.dataName} form.`,
|
|
97
|
+
commandType: a.Submit,
|
|
72
98
|
enabled: !0
|
|
73
99
|
},
|
|
74
100
|
{
|
|
75
101
|
name: "reset",
|
|
76
|
-
description: `Reset the ${
|
|
77
|
-
commandType:
|
|
102
|
+
description: `Reset the ${o.dataName} form to its initial values.`,
|
|
103
|
+
commandType: a.Reset,
|
|
78
104
|
enabled: !0
|
|
79
105
|
}
|
|
80
|
-
],
|
|
81
|
-
switch (
|
|
82
|
-
case
|
|
83
|
-
return
|
|
84
|
-
case
|
|
85
|
-
return $(t);
|
|
86
|
-
case r.Submit:
|
|
106
|
+
], e = r.current.webMcp, l = typeof e == "object" && e !== null && typeof e.tools == "function" ? e.tools : void 0, y = l ? l(m) : m, b = async (i, p) => {
|
|
107
|
+
switch (i) {
|
|
108
|
+
case a.Fill:
|
|
109
|
+
return $(p, t);
|
|
110
|
+
case a.Validate:
|
|
87
111
|
return j(t);
|
|
88
|
-
case
|
|
89
|
-
return
|
|
112
|
+
case a.Submit:
|
|
113
|
+
return g(t);
|
|
114
|
+
case a.Reset:
|
|
115
|
+
return E(t);
|
|
90
116
|
default:
|
|
91
|
-
return { content: [{ type: "text", text: `Unknown command: ${
|
|
117
|
+
return { content: [{ type: "text", text: `Unknown command: ${i}` }], isError: !0 };
|
|
92
118
|
}
|
|
93
119
|
};
|
|
94
|
-
for (const
|
|
95
|
-
if (!
|
|
120
|
+
for (const i of y) {
|
|
121
|
+
if (!i.enabled)
|
|
96
122
|
continue;
|
|
97
|
-
const
|
|
123
|
+
const p = i.inputSchema || F(i.commandType, c), v = i.commandType, x = i.execute;
|
|
98
124
|
try {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
name: f(
|
|
102
|
-
description:
|
|
103
|
-
inputSchema:
|
|
104
|
-
execute: async (
|
|
125
|
+
s.push(
|
|
126
|
+
n.registerTool({
|
|
127
|
+
name: f(i.name),
|
|
128
|
+
description: i.description,
|
|
129
|
+
inputSchema: p,
|
|
130
|
+
execute: x ? async (d) => await x(d || {}) : async (d) => b(v, d || {})
|
|
105
131
|
})
|
|
106
132
|
);
|
|
107
133
|
} catch {
|
|
108
134
|
}
|
|
109
135
|
}
|
|
110
|
-
return
|
|
136
|
+
return s;
|
|
111
137
|
}
|
|
112
138
|
};
|
|
113
139
|
export {
|
|
114
|
-
|
|
140
|
+
S as formAdapter
|
|
115
141
|
};
|
package/adapters/gantt.d.ts
CHANGED
|
@@ -46,12 +46,14 @@ interface GanttAdapterProps {
|
|
|
46
46
|
[key: string]: unknown;
|
|
47
47
|
}>;
|
|
48
48
|
sortable?: boolean | Record<string, unknown>;
|
|
49
|
+
selectable?: boolean | Record<string, unknown>;
|
|
49
50
|
onSortChange?: (event: Record<string, unknown>) => void;
|
|
50
51
|
onFilterChange?: (event: Record<string, unknown>) => void;
|
|
51
52
|
onExpandChange?: (event: Record<string, unknown>) => void;
|
|
52
53
|
onViewChange?: (event: Record<string, unknown>) => void;
|
|
53
54
|
onTaskChange?: (event: Record<string, unknown>) => void;
|
|
54
55
|
onDataStateChange?: (event: Record<string, unknown>) => void;
|
|
56
|
+
onSelectionChange?: (event: Record<string, unknown>) => void;
|
|
55
57
|
columnsState?: GanttColumnState[];
|
|
56
58
|
onColumnsStateChange?: (event: Record<string, unknown>) => void;
|
|
57
59
|
onColumnResize?: (event: Record<string, unknown>) => void;
|
package/adapters/gantt.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("react"),i=require("../commands/gantt.js"),S=require("./utils.js");function j(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const a=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,a.get?a:{enumerable:!0,get:()=>t[e]})}}return n.default=t,Object.freeze(n)}const v=j(O);function b(t){return{id:(t==null?void 0:t.id)||"id",title:(t==null?void 0:t.title)||"title",start:(t==null?void 0:t.start)||"start",end:(t==null?void 0:t.end)||"end",percentComplete:(t==null?void 0:t.percentComplete)||"percentComplete",isExpanded:(t==null?void 0:t.isExpanded)||"isExpanded",children:(t==null?void 0:t.children)||"children"}}function G(t,n){const e=[],a=o=>{for(const c of o){e.push(c);const r=c[n.children];Array.isArray(r)&&r.length>0&&a(r)}};return a(t),e}function H(t){const n=[];if(Array.isArray(t.columns))for(const e of t.columns)e.field&&n.push({field:e.field,id:e.id||e.field});return n.length===0&&t.children&&v.Children.forEach(t.children,e=>{if(v.isValidElement(e)&&e.props.field){const a=e.props;n.push({field:a.field,id:a.id||a.field})}}),n}function V(t,n,e){if(!t.field)return{content:[{type:"text",text:"Missing required argument: field"}],isError:!0};const a=t.field,o=t.dir||"asc",c=[{field:a,dir:o}];return n.current.onSortChange&&n.current.onSortChange({sort:c,field:a,target:e}),{content:[{type:"text",text:`Sorted by ${a} ${o}.`}]}}function W(t,n,e){if(!t.field||!t.operator)return{content:[{type:"text",text:"Missing required arguments: field, operator"}],isError:!0};const a=t.field,o=t.operator,c=t.value;return n.current.onFilterChange&&n.current.onFilterChange({filter:{logic:"and",filters:[{field:a,operator:o,value:c}]},target:e}),{content:[{type:"text",text:`Filter applied: ${a} ${o} "${S.toText(c)}".`}]}}function D(t,n,e){const a=typeof t=="string"?t.toLowerCase():t,o=typeof e=="string"?e.toLowerCase():e;switch(n){case"eq":return a===o;case"neq":return a!==o;case"contains":return typeof a=="string"&&typeof o=="string"&&a.includes(o);case"startswith":return typeof a=="string"&&typeof o=="string"&&a.startsWith(o);case"endswith":return typeof a=="string"&&typeof o=="string"&&a.endsWith(o);default:return a===o}}function N(t,n,e,a){const o=e.current,c=b(o.taskModelFields),r=G(o.taskData||[],c);let s;return n.field&&n.operator?s=r.find(u=>{const l=u[n.field];return D(l,n.operator,n.value)}):n.id!==void 0&&(s=r.find(u=>String(u[c.id])===String(n.id))),s?(o.onExpandChange&&o.onExpandChange({dataItem:s,value:t,level:[],target:a}),{content:[{type:"text",text:`${t?"Expanded":"Collapsed"} task "${S.toText(s[c.title])}".`}]}):{content:[{type:"text",text:"No matching task found."}],isError:!0}}function A(t,n,e){const a=n.current,o=b(a.taskModelFields),r=G(a.taskData||[],o).filter(m=>{const u=m[o.children];return Array.isArray(u)&&u.length>0});if(a.onExpandChange)for(const m of r)a.onExpandChange({dataItem:m,value:t,level:[],target:e});return{content:[{type:"text",text:`${t?"Expanded":"Collapsed"} ${r.length} parent task(s).`}]}}function P(t,n,e,a){switch(t){case i.GanttCommands.Expand:return N(!0,n,e,a);case i.GanttCommands.Collapse:return N(!1,n,e,a);case i.GanttCommands.ExpandAll:return A(!0,e,a);case i.GanttCommands.CollapseAll:return A(!1,e,a);default:return{content:[{type:"text",text:`Unknown expand/collapse command: ${t}`}],isError:!0}}}function g(t,n){return t.id===n||t.field===n}function _(t,n,e){return t.map(a=>g(a,n)?e(a):a)}function U(t,n,e,a,o,c,r){var m;const s=Number(n.position);if(Number.isNaN(s))return{content:[{type:"text",text:"Missing required argument: position"}],isError:!0};if(r){const u=o.findIndex(C=>g(C,t)),l=c[u];if(l){const C=[...c];C.splice(u,1),C.splice(s,0,l),(m=e.onColumnsStateChange)==null||m.call(e,{columnsState:C.map((x,w)=>({...x,orderIndex:w})),target:a})}}else if(e.onColumnReorder){const u=o.findIndex(l=>g(l,t));e.onColumnReorder({oldIndex:u,newIndex:s,target:a})}else return{content:[{type:"text",text:"Column reorder not supported."}],isError:!0};return{content:[{type:"text",text:`Column ${t} moved to position ${s}.`}]}}function L(t,n,e,a,o,c,r){var m;const s=Number.parseInt(n.size,10);if(Number.isNaN(s))return{content:[{type:"text",text:"Missing required argument: size"}],isError:!0};if(r)(m=e.onColumnsStateChange)==null||m.call(e,{columnsState:_(c,t,u=>({...u,width:s})),target:a});else if(e.onColumnResize){const u=o.findIndex(x=>g(x,t)),l=(e.columns||[])[u],C=l&&l.width||0;e.onColumnResize({index:u,newWidth:s,oldWidth:C,end:!0,target:a})}else return{content:[{type:"text",text:"Column resize not supported."}],isError:!0};return{content:[{type:"text",text:`Column ${t} resized to ${s}px.`}]}}function z(t,n,e,a,o,c){var s;return c?((s=e.onColumnsStateChange)==null||s.call(e,{columnsState:_(o,t,m=>({...m,hidden:n})),target:a}),{content:[{type:"text",text:`Column ${t} is now ${n?"hidden":"visible"}.`}]}):{content:[{type:"text",text:"Column state changes not supported."}],isError:!0}}function B(t,n,e,a,o){const c=n.id;if(!c)return{content:[{type:"text",text:"Missing required argument: id"}],isError:!0};const r=e.current,s=!!r.onColumnsStateChange&&!!a,m=s?r.columnsState||(a==null?void 0:a.columns)||[]:[];switch(t){case i.GanttCommands.ColumnReorder:return U(c,n,r,a,o,m,s);case i.GanttCommands.ColumnResize:return L(c,n,r,a,o,m,s);case i.GanttCommands.ColumnShow:return z(c,!1,r,a,m,s);case i.GanttCommands.ColumnHide:return z(c,!0,r,a,m,s);default:return null}}function J(t,n,e){const a=t.view;return a?(n.current.onViewChange&&n.current.onViewChange({value:a,target:e}),{content:[{type:"text",text:`Switched to ${a} view.`}]}):{content:[{type:"text",text:"Missing required argument: view"}],isError:!0}}function K(t,n,e,a){var s;const o=e.current,c=o.onTaskChange||o.onDataStateChange;if(!c)return null;const r=b(o.taskModelFields);switch(t){case i.GanttCommands.CreateTask:{const m=n.title;if(!m)return{content:[{type:"text",text:"Missing required argument: title"}],isError:!0};const u={[r.id]:Date.now(),[r.title]:m,[r.start]:n.start?new Date(n.start):void 0,[r.end]:n.end?new Date(n.end):void 0,[r.percentComplete]:(s=n.percentComplete)!=null?s:0};return c({created:[u],updated:[],deleted:[]}),{content:[{type:"text",text:`Added task "${m}".`}]}}case i.GanttCommands.DeleteTask:{const m=G(o.taskData||[],r);let u;return n.field&&n.operator?u=m.find(l=>{const C=l[n.field];return D(C,n.operator,n.value)}):n.id!==void 0&&(u=m.find(l=>String(l[r.id])===String(n.id))),u?(c({created:[],updated:[],deleted:[u]}),{content:[{type:"text",text:`Deleted task "${S.toText(u[r.title])}".`}]}):{content:[{type:"text",text:"No matching task found."}],isError:!0}}default:return null}}const Q={componentSuffix:"gantt",createTools(t,n,e,a){const o=[],c=d=>`${e.groupName}_${d}`,r=n.current,s=H(r),m=!!r.sortable,u=!!r.onFilterChange,l=!!r.onExpandChange,C=!!r.onViewChange,x=!!r.onTaskChange||!!r.onDataStateChange,w=!!r.reorderable,I=!!r.resizable,E=!!r.onColumnsStateChange,$=[{name:"sort",description:`Sort the ${e.dataName} gantt by a column`,commandType:i.GanttCommands.Sort,enabled:m},{name:"clear_sort",description:`Remove all sorting from the ${e.dataName} gantt`,commandType:i.GanttCommands.ClearSort,enabled:m},{name:"filter",description:`Filter the ${e.dataName} gantt on a column`,commandType:i.GanttCommands.Filter,enabled:u},{name:"clear_filters",description:`Remove all filters from the ${e.dataName} gantt`,commandType:i.GanttCommands.ClearFilter,enabled:u},{name:"expand",description:`Expand a task in the ${e.dataName} gantt`,commandType:i.GanttCommands.Expand,enabled:l},{name:"collapse",description:`Collapse a task in the ${e.dataName} gantt`,commandType:i.GanttCommands.Collapse,enabled:l},{name:"expand_all",description:`Expand all parent tasks in the ${e.dataName} gantt`,commandType:i.GanttCommands.ExpandAll,enabled:l},{name:"collapse_all",description:`Collapse all parent tasks in the ${e.dataName} gantt`,commandType:i.GanttCommands.CollapseAll,enabled:l},{name:"change_view",description:`Switch the ${e.dataName} gantt chart view`,commandType:i.GanttCommands.ChangeView,enabled:C},{name:"create_task",description:`Add a new task to the ${e.dataName} gantt`,commandType:i.GanttCommands.CreateTask,enabled:x},{name:"delete_task",description:`Delete a task from the ${e.dataName} gantt`,commandType:i.GanttCommands.DeleteTask,enabled:x},{name:"reorder_column",description:`Reorder a column in the ${e.dataName} gantt`,commandType:i.GanttCommands.ColumnReorder,enabled:w},{name:"resize_column",description:`Resize a column in the ${e.dataName} gantt`,commandType:i.GanttCommands.ColumnResize,enabled:I},{name:"show_column",description:`Show a hidden column in the ${e.dataName} gantt`,commandType:i.GanttCommands.ColumnShow,enabled:E},{name:"hide_column",description:`Hide a column in the ${e.dataName} gantt`,commandType:i.GanttCommands.ColumnHide,enabled:E}],y=n.current.webMcp,T=typeof y=="object"&&y!==null&&typeof y.tools=="function"?y.tools:void 0,k={tname:c,columns:s,data:r.taskData},q=T?T($,k):$,R=async(d,p)=>{const h=n.current;switch(d){case i.GanttCommands.Sort:return V(p,n,t);case i.GanttCommands.ClearSort:return h.onSortChange&&h.onSortChange({sort:[],field:"",target:t}),{content:[{type:"text",text:"Sorting cleared."}]};case i.GanttCommands.Filter:return W(p,n,t);case i.GanttCommands.ClearFilter:return h.onFilterChange&&h.onFilterChange({filter:{logic:"and",filters:[]},target:t}),{content:[{type:"text",text:"All filters cleared."}]};case i.GanttCommands.Expand:case i.GanttCommands.Collapse:case i.GanttCommands.ExpandAll:case i.GanttCommands.CollapseAll:return P(d,p,n,t);case i.GanttCommands.ChangeView:return J(p,n,t);case i.GanttCommands.CreateTask:case i.GanttCommands.DeleteTask:{const f=K(d,p,n);return f||{content:[{type:"text",text:"Task operations not supported."}],isError:!0}}case i.GanttCommands.ColumnReorder:case i.GanttCommands.ColumnResize:case i.GanttCommands.ColumnShow:case i.GanttCommands.ColumnHide:{const f=B(d,p,n,t,s);return f||{content:[{type:"text",text:`Unknown column command: ${d}`}],isError:!0}}default:return{content:[{type:"text",text:`Unknown command: ${d}`}],isError:!0}}};for(const d of q){if(!d.enabled)continue;const p=i.getGanttToolSchema(d.commandType,s),h=d.commandType;try{o.push(a.registerTool({name:c(d.name),description:d.description,inputSchema:p,execute:async f=>R(h,f||{})}))}catch{}}return o}};exports.ganttAdapter=Q;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("react"),i=require("../commands/gantt.js"),g=require("./utils.js");function L(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const z=L(W),k="GanttUpdateTask",I="GanttSelect";function T(e){return{id:(e==null?void 0:e.id)||"id",title:(e==null?void 0:e.title)||"title",start:(e==null?void 0:e.start)||"start",end:(e==null?void 0:e.end)||"end",percentComplete:(e==null?void 0:e.percentComplete)||"percentComplete",isExpanded:(e==null?void 0:e.isExpanded)||"isExpanded",children:(e==null?void 0:e.children)||"children"}}function b(e,t){const n=[],a=r=>{for(const c of r){n.push(c);const o=c[t.children];Array.isArray(o)&&o.length>0&&a(o)}};return a(e),n}function B(e){const t=[];if(Array.isArray(e.columns))for(const n of e.columns)n.field&&t.push({field:n.field,id:n.id||n.field});return t.length===0&&e.children&&z.Children.forEach(e.children,n=>{if(z.isValidElement(n)&&n.props.field){const a=n.props;t.push({field:a.field,id:a.id||a.field})}}),t}function K(e,t,n){if(!e.field)return{content:[{type:"text",text:"Missing required argument: field"}],isError:!0};const a=e.field,r=e.dir||"asc",c=[{field:a,dir:r}];return t.current.onSortChange&&t.current.onSortChange({sort:c,field:a,target:n}),{content:[{type:"text",text:`Sorted by ${a} ${r}.`}]}}function J(e,t,n){if(!e.field||!e.operator)return{content:[{type:"text",text:"Missing required arguments: field, operator"}],isError:!0};const a=e.field,r=e.operator,c=e.value;return t.current.onFilterChange&&t.current.onFilterChange({filter:{logic:"and",filters:[{field:a,operator:r,value:c}]},target:n}),{content:[{type:"text",text:`Filter applied: ${a} ${r} "${g.toText(c)}".`}]}}function G(e,t,n){const a=typeof e=="string"?e.toLowerCase():e,r=typeof n=="string"?n.toLowerCase():n;switch(t){case"eq":return a===r;case"neq":return a!==r;case"contains":return typeof a=="string"&&typeof r=="string"&&a.includes(r);case"startswith":return typeof a=="string"&&typeof r=="string"&&a.startsWith(r);case"endswith":return typeof a=="string"&&typeof r=="string"&&a.endsWith(r);default:return a===r}}function q(e,t,n,a){const r=n.current,c=T(r.taskModelFields),o=b(r.taskData||[],c);let s;return t.field&&t.operator?s=o.find(d=>{const u=d[t.field];return G(u,t.operator,t.value)}):t.id!==void 0&&(s=o.find(d=>String(d[c.id])===String(t.id))),s?(r.onExpandChange&&r.onExpandChange({dataItem:s,value:e,level:[],target:a}),{content:[{type:"text",text:`${e?"Expanded":"Collapsed"} task "${g.toText(s[c.title])}".`}]}):{content:[{type:"text",text:"No matching task found."}],isError:!0}}function R(e,t,n){const a=t.current,r=T(a.taskModelFields),o=b(a.taskData||[],r).filter(l=>{const d=l[r.children];return Array.isArray(d)&&d.length>0});if(a.onExpandChange)for(const l of o)a.onExpandChange({dataItem:l,value:e,level:[],target:n});return{content:[{type:"text",text:`${e?"Expanded":"Collapsed"} ${o.length} parent task(s).`}]}}function Q(e,t,n,a){switch(e){case i.GanttCommands.Expand:return q(!0,t,n,a);case i.GanttCommands.Collapse:return q(!1,t,n,a);case i.GanttCommands.ExpandAll:return R(!0,n,a);case i.GanttCommands.CollapseAll:return R(!1,n,a);default:return{content:[{type:"text",text:`Unknown expand/collapse command: ${e}`}],isError:!0}}}function E(e,t){return e.id===t||e.field===t}function U(e,t,n){return e.map(a=>E(a,t)?n(a):a)}function X(e,t,n,a,r,c,o){var l;const s=Number(t.position);if(Number.isNaN(s))return{content:[{type:"text",text:"Missing required argument: position"}],isError:!0};if(o){const d=r.findIndex(p=>E(p,e)),u=c[d];if(u){const p=[...c];p.splice(d,1),p.splice(s,0,u),(l=n.onColumnsStateChange)==null||l.call(n,{columnsState:p.map((x,$)=>({...x,orderIndex:$})),target:a})}}else if(n.onColumnReorder){const d=r.findIndex(u=>E(u,e));n.onColumnReorder({oldIndex:d,newIndex:s,target:a})}else return{content:[{type:"text",text:"Column reorder not supported."}],isError:!0};return{content:[{type:"text",text:`Column ${e} moved to position ${s}.`}]}}function Y(e,t,n,a,r,c,o){var l;const s=Number.parseInt(t.size,10);if(Number.isNaN(s))return{content:[{type:"text",text:"Missing required argument: size"}],isError:!0};if(o)(l=n.onColumnsStateChange)==null||l.call(n,{columnsState:U(c,e,d=>({...d,width:s})),target:a});else if(n.onColumnResize){const d=r.findIndex(x=>E(x,e)),u=(n.columns||[])[d],p=u&&u.width||0;n.onColumnResize({index:d,newWidth:s,oldWidth:p,end:!0,target:a})}else return{content:[{type:"text",text:"Column resize not supported."}],isError:!0};return{content:[{type:"text",text:`Column ${e} resized to ${s}px.`}]}}function O(e,t,n,a,r,c){var s;return c?((s=n.onColumnsStateChange)==null||s.call(n,{columnsState:U(r,e,l=>({...l,hidden:t})),target:a}),{content:[{type:"text",text:`Column ${e} is now ${t?"hidden":"visible"}.`}]}):{content:[{type:"text",text:"Column state changes not supported."}],isError:!0}}function Z(e,t,n,a,r){const c=t.id;if(!c)return{content:[{type:"text",text:"Missing required argument: id"}],isError:!0};const o=n.current,s=!!o.onColumnsStateChange&&!!a,l=s?o.columnsState||(a==null?void 0:a.columns)||[]:[];switch(e){case i.GanttCommands.ColumnReorder:return X(c,t,o,a,r,l,s);case i.GanttCommands.ColumnResize:return Y(c,t,o,a,r,l,s);case i.GanttCommands.ColumnShow:return O(c,!1,o,a,l,s);case i.GanttCommands.ColumnHide:return O(c,!0,o,a,l,s);default:return null}}function F(e,t,n){const a=e.view;return a?(t.current.onViewChange&&t.current.onViewChange({value:a,target:n}),{content:[{type:"text",text:`Switched to ${a} view.`}]}):{content:[{type:"text",text:"Missing required argument: view"}],isError:!0}}function M(e,t,n,a){var s;const r=n.current,c=r.onTaskChange||r.onDataStateChange;if(!c)return null;const o=T(r.taskModelFields);switch(e){case i.GanttCommands.CreateTask:{const l=t.title;if(!l)return{content:[{type:"text",text:"Missing required argument: title"}],isError:!0};const d={[o.id]:Date.now(),[o.title]:l,[o.start]:t.start?new Date(t.start):void 0,[o.end]:t.end?new Date(t.end):void 0,[o.percentComplete]:(s=t.percentComplete)!=null?s:0};return c({created:[d],updated:[],deleted:[]}),{content:[{type:"text",text:`Added task "${l}".`}]}}case i.GanttCommands.DeleteTask:{const l=b(r.taskData||[],o);let d;return t.field&&t.operator?d=l.find(u=>{const p=u[t.field];return G(p,t.operator,t.value)}):t.id!==void 0&&(d=l.find(u=>String(u[o.id])===String(t.id))),d?(c({created:[],updated:[],deleted:[d]}),{content:[{type:"text",text:`Deleted task "${g.toText(d[o.title])}".`}]}):{content:[{type:"text",text:"No matching task found."}],isError:!0}}case k:{const l=b(r.taskData||[],o);let d;if(t.field&&t.operator?d=l.find(p=>{const x=p[t.field];return G(x,t.operator,t.value)}):t.id!==void 0&&(d=l.find(p=>String(p[o.id])===String(t.id))),!d)return{content:[{type:"text",text:"No matching task found."}],isError:!0};const u={...d};return t.title!==void 0&&(u[o.title]=t.title),t.start!==void 0&&(u[o.start]=new Date(t.start)),t.end!==void 0&&(u[o.end]=new Date(t.end)),t.percentComplete!==void 0&&(u[o.percentComplete]=t.percentComplete),c({created:[],updated:[u],deleted:[]}),{content:[{type:"text",text:`Updated task "${g.toText(u[o.title])}".`}]}}default:return null}}const tt={componentSuffix:"gantt",createTools(e,t,n,a){const r=[],c=m=>`${n.groupName}_${m}`,o=t.current,s=B(o),l=!!o.sortable,d=!!o.onFilterChange,u=!!o.onExpandChange,p=!!o.onViewChange,x=!!o.onTaskChange||!!o.onDataStateChange,$=!!o.reorderable||!!o.onColumnReorder,j=!!o.resizable||!!o.onColumnResize,D=!!o.onColumnsStateChange,A=[{name:"sort",description:`Sort the ${n.dataName} gantt by a column`,commandType:i.GanttCommands.Sort,enabled:l},{name:"clear_sort",description:`Remove all sorting from the ${n.dataName} gantt`,commandType:i.GanttCommands.ClearSort,enabled:l},{name:"filter",description:`Filter the ${n.dataName} gantt on a column`,commandType:i.GanttCommands.Filter,enabled:d},{name:"clear_filters",description:`Remove all filters from the ${n.dataName} gantt`,commandType:i.GanttCommands.ClearFilter,enabled:d},{name:"expand",description:`Expand a task in the ${n.dataName} gantt`,commandType:i.GanttCommands.Expand,enabled:u},{name:"collapse",description:`Collapse a task in the ${n.dataName} gantt`,commandType:i.GanttCommands.Collapse,enabled:u},{name:"expand_all",description:`Expand all parent tasks in the ${n.dataName} gantt`,commandType:i.GanttCommands.ExpandAll,enabled:u},{name:"collapse_all",description:`Collapse all parent tasks in the ${n.dataName} gantt`,commandType:i.GanttCommands.CollapseAll,enabled:u},{name:"set_view",description:`Switch the ${n.dataName} gantt chart view`,commandType:i.GanttCommands.ChangeView,enabled:p},{name:"add_task",description:`Add a new task to the ${n.dataName} gantt`,commandType:i.GanttCommands.CreateTask,enabled:x},{name:"update_task",description:`Update an existing task in the ${n.dataName} gantt`,commandType:k,enabled:x},{name:"delete_task",description:`Delete a task from the ${n.dataName} gantt`,commandType:i.GanttCommands.DeleteTask,enabled:x},{name:"select",description:`Select a task in the ${n.dataName} gantt`,commandType:I,enabled:!!o.selectable||!!o.onSelectionChange||x},{name:"reorder_column",description:`Reorder a column in the ${n.dataName} gantt`,commandType:i.GanttCommands.ColumnReorder,enabled:$},{name:"resize_column",description:`Resize a column in the ${n.dataName} gantt`,commandType:i.GanttCommands.ColumnResize,enabled:j},{name:"show_column",description:`Show a hidden column in the ${n.dataName} gantt`,commandType:i.GanttCommands.ColumnShow,enabled:D},{name:"hide_column",description:`Hide a column in the ${n.dataName} gantt`,commandType:i.GanttCommands.ColumnHide,enabled:D}],w=t.current.webMcp,_=typeof w=="object"&&w!==null&&typeof w.tools=="function"?w.tools:void 0,H={tname:c,columns:s,data:o.taskData},P=_?_(A,H):A,V=async(m,C)=>{const y=t.current;switch(m){case i.GanttCommands.Sort:return K(C,t,e);case i.GanttCommands.ClearSort:return y.onSortChange&&y.onSortChange({sort:[],field:"",target:e}),{content:[{type:"text",text:"Sorting cleared."}]};case i.GanttCommands.Filter:return J(C,t,e);case i.GanttCommands.ClearFilter:return y.onFilterChange&&y.onFilterChange({filter:{logic:"and",filters:[]},target:e}),{content:[{type:"text",text:"All filters cleared."}]};case i.GanttCommands.Expand:case i.GanttCommands.Collapse:case i.GanttCommands.ExpandAll:case i.GanttCommands.CollapseAll:return Q(m,C,t,e);case i.GanttCommands.ChangeView:return F(C,t,e);case i.GanttCommands.CreateTask:case i.GanttCommands.DeleteTask:case k:{const f=M(m,C,t);return f||{content:[{type:"text",text:"Task operations not supported."}],isError:!0}}case I:{const f=t.current,h=T(f.taskModelFields),v=b(f.taskData||[],h);let S;if(C.field&&C.operator?S=v.find(N=>G(N[C.field],C.operator,C.value)):C.id!==void 0&&(S=v.find(N=>String(N[h.id])===String(C.id))),!S)return{content:[{type:"text",text:"No matching task found."}],isError:!0};if(f.onSelectionChange)f.onSelectionChange({dataItem:S,dataItems:v,target:e});else if(f.onDataStateChange)f.onDataStateChange({selected:[S],target:e});else return{content:[{type:"text",text:"Selection not supported. Add onSelectionChange or selectable prop."}],isError:!0};return{content:[{type:"text",text:`Selected task "${g.toText(S[h.title])}".`}]}}case i.GanttCommands.ColumnReorder:case i.GanttCommands.ColumnResize:case i.GanttCommands.ColumnShow:case i.GanttCommands.ColumnHide:{const f=Z(m,C,t,e,s);return f||{content:[{type:"text",text:`Unknown column command: ${m}`}],isError:!0}}default:return{content:[{type:"text",text:`Unknown command: ${m}`}],isError:!0}}};for(const m of P){if(!m.enabled)continue;const C=m.inputSchema||i.getGanttToolSchema(m.commandType,s),y=m.commandType,f=m.execute;try{r.push(a.registerTool({name:c(m.name),description:m.description,inputSchema:C,execute:f?async h=>await f(h||{}):async h=>V(y,h||{})}))}catch{}}return r}};exports.ganttAdapter=tt;
|