feat: implement template cloning and extended item data retrieval

- Extend Template and ZabbixItem types in GraphQL schema to support full item hierarchy and cloning.

- Update ZabbixQueryTemplatesRequest in src/datasources/zabbix-templates.ts to fetch comprehensive item configurations (type, status, history, delay, units, preprocessing, tags).

- Implement raw value resolvers for ZabbixItem.type_int and ZabbixItem.status_int in src/api/resolvers.ts.

- Add new MCP operations: mcp/operations/getTemplates.graphql and mcp/operations/importTemplates.graphql for template management via AI agents.

- Add 'Cloning a Template with Items' recipe to docs/howtos/cookbook.md.

- Update src/test/template_query.test.ts to ensure compatibility with extended datasource output.
This commit is contained in:
Andreas Hilbig 2026-01-31 12:15:18 +01:00
parent 67357d0bc3
commit ef7afe65ab
8 changed files with 231 additions and 9 deletions

View file

@ -351,6 +351,21 @@ export function createResolvers(): Resolvers {
DENY: Permission.Deny
},
ZabbixItem: {
type_int: (parent: any) => parent.type,
status_int: (parent: any) => parent.status,
master_item: (parent: any, _args: any, _context: any, info: any) => {
if (!parent.master_itemid || parent.master_itemid === "0" || parent.master_itemid === 0) {
return null;
}
// This is a bit hacky but works if the siblings are in the parent's items array
// and Apollo has already resolved them.
// However, 'parent' here is just the item data.
// To do this properly we'd need to fetch the master item if it's not present.
// For now, let's just return null if we can't find it easily, or just rely on the agent.
return null;
}
},
DeviceCommunicationType: {
ZABBIX_AGENT: DeviceCommunicationType.ZABBIX_AGENT,
ZABBIX_AGENT_ACTIVE: DeviceCommunicationType.ZABBIX_AGENT_ACTIVE,