Components & applications
Components group provided resources and services and declare which model elements they use. Applications compose components.
Complete example
package com.example.customer
import org.joinedworkz.facilities.common.base
import org.joinedworkz.facilities.common.base.api
platform Base
type Customer {
id**: Id
}
service CustomerService {
find(id*: Id): Customer
}
resource /customers as Customer[] by id {
query()
read()
}
component CustomerComponent uses CustomerService {
provide /customers
}
component ReportingComponent uses CustomerComponent {
}
application CustomerApp {
consists of {
CustomerComponent
}
use {
ReportingComponent
}
}Component dependencies
Dependencies are written in the component header with uses; there is no depends keyword:
component CustomerComponent uses CustomerService, Customer {
}A component can use types, services, and other components.
Component-scoped OpenAPI
With the Base platform in release 1.3.80, every component with provided resources produces an additional component-scoped OpenAPI YAML and matching HTML viewer. The document aggregates all resource paths in that component's provide declarations, including resources imported from different CMN models.
The same cartridge also creates a model-scoped document from the non-abstract resources declared directly in each CMN model. Applications do not create a third, application-wide aggregate.
Application composition
consists of { ... }lists components that belong to the application.use { ... }oruses { ... }lists referenced components outside that composition.supports { ... }can list scenarios supported by the application.
The component lists are blocks; use CustomerComponent is not valid application syntax.
