Open Roaders opened 4 months ago
@Roaders There exist AppRequestMessage, AgentResponseMessage and AgentEvent message schemas and types. See:
The types are structurally compatible with all messages derived from them so you can use them to write generalized TypeScript code in your implementation. However, as we generate the TypeScript code from the schemas, the type definitions of specific message types don't formally extend these types - but as TypeScript uses structural compatibility rather than than more traditional declarative typing that should not matter (other than it feeling a little odd to those of us that grew up with OO languages).
Given the number of messages, we should try to avoid creating a manual maintenance situation wherever possible (lest we incur the wrath of future generations of FDC3 maintainers). However, I believe it could/should be possible to come up with a way to generate some of your above suggestions by post processing the BrowserTypes file.
Type detection does seem like something the Convert class could be doing...
Enhancement Request
Use Case:
I am a developer implementing a Desktop Agent Proxy that will use the proposed messaging protocol to communicate with a Desktop Agent. The types defined in BrowserTypes are very helpful but there are things that can be done to make things easier.
FDC3Message
(name is just an example. I am not good at naming things! feel free to suggest a different name)FDC3Message
union type should be composed of 2 other union typesRequestMessage
andResponseMessage
RequestMessageBase
and aResponseMessageBase
. All response messages should have asource: AppIdentifier
and request / response uuid in the meta object for example (I am not sure how practical this is but some commanality between messages would be great)This isn't necessarily the desired implementation - we could probably use some of the logic from the
Convert
class to do a better check that it is in fact a valid message. The important bit is the type predicate return type.We have already implemeted a lot of type predicates and union types but I am not sure how useful it would be to contribute these as I understand that the
BrowserTypes
are generated by magic so that magic should probably also generate the predicates and union types.