Description
Enhancement Request
Use Case:
Suppose there is an existing ecosystem of applications that communicate with each other via DesktopAgent
. The context for the fdc3.instrument
type includes the id.ISIN
property. One day, a third-party application is to be integrated into the ecosystem and communicate with the existing applications via DesktopAgent
.
The problem is that this application doesn’t support id.ISIN
but instead supports id.FIGI
.
Refactoring all existing applications to add id.FIGI
to every context broadcast is expensive, so it would be helpful if the contexts could be converted automatically according to defined rules.
Workflow Description
Context Translation Middleware: Middleware within DesktopAgent that automatically converts contexts based on defined rules (e.g., context type) during broadcasting.
- This conversion can be synchronous (in-place) or asynchronous (e.g., by requesting a service to transform the context).
- There can be multiple middleware.
Error Handling: If there are any cases where the translation is not feasible, DesktopAgent
should handle this so developers can log the situation and alert the administrators. This ensures visibility for unsupported context translations and reduces potential issues during runtime.
Workflow Examples
const contextTransform = async (context) => {
if (context.type === 'fdc3.instrument') {
if (context.id.ISIN && !context.id.FIGI) {
const FIGI = await convertISINtoFIGI(context.id.ISIN) // a fetch request to some service
if (!FIGI) {
throw new Error(`Cannot convert ISIN ${context.id.ISIN} to FIGI for fdc3.instrument`)
}
return {
...context,
id: {
...context.id,
FIGI,
}
}
}
}
}
getAgent({
middleware: [
contextTransform
]
})