Appearance
Plugin policy version 2
What is schemaVersion?
The schemaVersion key has been added to the policy JSON file to facilitate the adoption of any future file changes. The current version is marked as version 1, which is the default version and does not need to be mentioned in the file. If any changes to the file are necessary, they will be released as version 2 of the policy.json file. In this case, it will be necessary to specify the schemaVersion key in the file. However, the adoption of this change will not be enforced and can be taken up when needed.
Currently, no changes are needed in the policy.json file to include the schemaVersion key.
PlatformHub v.2.3.0 include version 2 of the policy file. This version is optimized compared to version 1, as no new additions have been made.
Under the receive and publish block, the messageName is considered redundant and is therefore converted to an array of string.
Example of a policy file for policy schemaVersion 2 for publish and receive
json
{
"name": "SomeNamePlugin",
"schemaVersion": 2,
"publish": {
"eventStreams": ["TheMessageToSend", "ShowFragmentB", "ShowFragmentCommand"]
},
"receive": {
"commands": ["TheMessageToSend", "ShowFragmentB", "ShowFragmentCommand"],
"navigationQueries": [
"TheMessageToSend",
"ShowFragmentB",
"ShowFragmentCommand"
],
"queries": ["TheMessageToSend", "ShowFragmentB", "ShowFragmentCommand"]
}
}We have made changes to the "send", "subscribeOnStartup" and "subscribeOnDemand" block in the policy file. Specifically, we have modified the "command","queries" "navigationQueries" field to optimize the format of the "messageName" field.
In the older format, the "messageName" field was a map, where each map contained a single key-value pair for the message name and plugin name. In the new format, the "messageName" field is an array of strings, where each string represents a single message name.
To achieve this, we have converted the "messageName" field to an array of strings. In the new format, each message name is represented as a single string within an array. This change allows for better optimization and reduces redundancy in the policy file.
Example of a policy file for policySchemaVersion 2 for send, subscribeOnStartup, subscribeOnDemand, publishToTopic, subscribeToTopic
json
{
"name": "SomeNamePlugin",
"schemaVersion": 2,
"subscribeOnStartup": {
"eventStreams": [
{
"pluginName": "MessagesSamplePlugin",
"messageNames": [
"timerTickedOnStartup",
"StopwatchTimer",
"ColorSelectionLimitReachedError"
]
}
]
},
"subscribeOnDemand": {
"eventStreams": [
{
"messageNames": [
"TheMessageToSend",
"StopwatchTimer",
"ColorSelectionLimitReachedError"
]
}
]
},
"send": {
"commands": [
{
"messageNames": [
"TheMessageToSend",
"ShowFragmentB",
"ShowFragmentCommand"
],
"pluginName": "TheNameOfThePluginOwningThisMessage"
}
],
"navigationQueries": [
{
"messageNames": [
"TheMessageToSend",
"ShowFragmentB",
"ShowFragmentCommand"
],
"pluginName": "TheNameOfThePluginOwningThisMessage"
}
],
"queries": [
{
"messageNames": [
"TheMessageToSend",
"ShowFragmentB",
"ShowFragmentCommand"
],
"pluginName": "TheNameOfThePluginOwningThisMessage"
}
]
},
"publishToTopic": {
"topicStreams": [
{
"topicName": "BalanceChanged",
"topicMessages": ["MeToMe", "MeToNotMe"]
}
]
},
"subscribeToTopic": {
"topicStreams": [
{
"topicName": "BalanceChanged",
"topicMessages": ["MeToMe", "MeToNotMe"]
}
]
}
}Note:
The publishToTopic and subscribeToTopic features on aOS are not supported in PlatformHub version 2.7.0 and earlier. To utilize features like publishToTopic and subscribeToTopic, you must use policy version 2.
To use version 2, it is mandatory to specify schemaVersion in the new policy json file.