Skip to main content

module

Function module 

Source
pub fn module() -> ModuleDescriptor
Expand description

The canonical declaration of the entity module: the two capabilities that answer for an object and for the catalogue of kinds, with every projection each is exposed through.

This is the only place either capability is written down. The MCP tool, the HTTP route, the command-line path, the generated OpenAPI and the Cockpit’s page are all read from here, which is why adding a surface to entity.show is an edit to this function and never to a transport registry or a documentation table (ADR 0004).

use majordomus_cli::capability::builtin::entity;

let m = entity::module();
assert_eq!(m.id.as_str(), "entity");

// both capabilities are namespaced by the module id, with no second spelling of it
let ids: Vec<String> = m
    .capabilities
    .iter()
    .map(|c| c.capability.id.to_string())
    .collect();
assert!(ids.iter().any(|id| id == "entity.show"));
assert!(ids.iter().any(|id| id == "entity.kinds"));

// and each declares where it is answered, rather than being registered elsewhere
let show = m
    .capabilities
    .iter()
    .find(|c| c.capability.id.to_string() == "entity.show")
    .expect("entity.show is declared here");
assert_eq!(
    show.capability.exposure.http.as_ref().map(|h| h.path.as_str()),
    Some("/api/v1/entity")
);