Capabilities
The Capabilities API allows apps on the platform to declare the functionality they provide to other apps. This is done by enabling capabilities.
A capability must always return an Operation, which is a unit of work that can be executed by the platform. There are two types of operations: LogicOperation
, which executes some code, and ViewOperation
, which requires a graphical user interface to be presented to the user.
By enabling capabilities and returning operations, apps can communicate with each other on the platform, allowing them to work together to create more powerful integrations and workflows. The platform can chain multiple operations from different apps, allowing for more complex and integrated workflows.
WARNING
Please note that the Capabilities API is currently in beta, which means it may be subject to change and may not yet be suitable for production use other than the capabilities pre defined by the framework, such as 'launch'.
enableCapability()
Enables a capability on your app. Has to return an Operation.
// app.ts
import { enableCapability, createOperation } from '@telia-ace/alliance-framework';
export default function () {
enableCapability('theCapability', (args) => {
return createOperation((ctx) => {
// logic
ctx.complete({ msg: 'hello world' });
});
});
}
runCapability()
Runs a capability on a specific app.
Returns a ResolvableCapabilityTicket
containing an id
and a result
.
The result can be awaited
.
// app.ts
import { runCapability } from '@telia-ace/alliance-framework';
export default function () {
const ticket = runCapability('anotherApp', 'theCapability', {
// args
});
ticket.result.then((result) => {
console.log(result.msg); // hello world
});
}
Pre defined capabilities
launch
The predefined capability launch
enables the platform to start apps in their default mode.