Skip to content

Commit

Permalink
Split serviceGroupId into separate telem and cmd props
Browse files Browse the repository at this point in the history
  • Loading branch information
jrdouceur committed Oct 31, 2024
1 parent c6c06d0 commit ca0cf9f
Show file tree
Hide file tree
Showing 10 changed files with 235 additions and 22 deletions.
3 changes: 2 additions & 1 deletion dotnet/src/DTDLParser/generated/ContextCollection.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,15 @@ private static ContextHistory GetAffiliate2ContextHistory()

VersionedContext context2_0 = new VersionedContext("dtmi:dtdl:extension:mqtt;2", 2, 0, 0, null, mergeDefinitions: false);
context2_0.AddTermDefinition("Cacheable", new Dtmi("dtmi:dtdl:extension:mqtt:v2:Cacheable"), isMergeableType: false);
context2_0.AddTermDefinition("cmdServiceGroupId", new Dtmi("dtmi:dtdl:extension:mqtt:v2:Mqtt:cmdServiceGroupId"), isMergeableType: false);
context2_0.AddTermDefinition("commandTopic", new Dtmi("dtmi:dtdl:extension:mqtt:v2:Mqtt:commandTopic"), isMergeableType: false);
context2_0.AddTermDefinition("Idempotent", new Dtmi("dtmi:dtdl:extension:mqtt:v2:Idempotent"), isMergeableType: false);
context2_0.AddTermDefinition("index", new Dtmi("dtmi:dtdl:extension:mqtt:v2:Indexed:index"), isMergeableType: false);
context2_0.AddTermDefinition("Indexed", new Dtmi("dtmi:dtdl:extension:mqtt:v2:Indexed"), isMergeableType: false);
context2_0.AddTermDefinition("Mqtt", new Dtmi("dtmi:dtdl:extension:mqtt:v2:Mqtt"), isMergeableType: false);
context2_0.AddTermDefinition("payloadFormat", new Dtmi("dtmi:dtdl:extension:mqtt:v2:Mqtt:payloadFormat"), isMergeableType: false);
context2_0.AddTermDefinition("serviceGroupId", new Dtmi("dtmi:dtdl:extension:mqtt:v2:Mqtt:serviceGroupId"), isMergeableType: false);
context2_0.AddTermDefinition("telemetryTopic", new Dtmi("dtmi:dtdl:extension:mqtt:v2:Mqtt:telemetryTopic"), isMergeableType: false);
context2_0.AddTermDefinition("telemServiceGroupId", new Dtmi("dtmi:dtdl:extension:mqtt:v2:Mqtt:telemServiceGroupId"), isMergeableType: false);
context2_0.AddTermDefinition("Transparent", new Dtmi("dtmi:dtdl:extension:mqtt:v2:Transparent"), isMergeableType: false);
context2_0.AddTermDefinition("ttl", new Dtmi("dtmi:dtdl:extension:mqtt:v2:Cacheable:ttl"), isMergeableType: false);
versionedContexts.Add(context2_0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,11 @@ static SupplementalTypeCollection()
indexedInfoCV2.AllowedCotypeVersions = new HashSet<int>() { 3, 4 };

DTSupplementalTypeInfo mqttInfoCV2 = new DTSupplementalTypeInfo(DTExtensionKind.AdjunctType, dtdlExtensionMqttContextIdV2, mqttTypeIdCV2, isAbstract: false, isMergeable: false, adjunctTypeTypeIdEV4);
mqttInfoCV2.AddProperty("dtmi:dtdl:extension:mqtt:v2:Mqtt:cmdServiceGroupId", new Uri("http://www.w3.org/2001/XMLSchema#string"), 1, null, null, null, null, regex: new Regex(@"^[!$-*,-.0-z|~]+$"), hasUniqueValue: false, isPlural: false, isOptional: true, defaultLanguage: null, dtmiSeg: null, dictionaryKey: null, idRequired: false, typeRequired: true, childOf: null, instanceProperty: null, requiredValues: null, requiredValuesString: null, requiredLiteral: null);
mqttInfoCV2.AddProperty("dtmi:dtdl:extension:mqtt:v2:Mqtt:commandTopic", new Uri("http://www.w3.org/2001/XMLSchema#string"), 1, null, null, null, null, regex: new Regex(@"^(?:(?:[!%-*,-.0-z|~][!$-*,-.0-z|~]*)|(?:{(?:[A-Za-z]+:)?[A-Za-z]+}))(?:\/(?:(?:[!$-*,-.0-z|~]+)|(?:{(?:[A-Za-z]+:)?[A-Za-z]+})))*$"), hasUniqueValue: false, isPlural: false, isOptional: true, defaultLanguage: null, dtmiSeg: null, dictionaryKey: null, idRequired: false, typeRequired: true, childOf: null, instanceProperty: null, requiredValues: null, requiredValuesString: null, requiredLiteral: null);
mqttInfoCV2.AddProperty("dtmi:dtdl:extension:mqtt:v2:Mqtt:payloadFormat", new Uri("http://www.w3.org/2001/XMLSchema#string"), 1, 1, null, null, null, regex: null, hasUniqueValue: false, isPlural: false, isOptional: false, defaultLanguage: null, dtmiSeg: null, dictionaryKey: null, idRequired: false, typeRequired: true, childOf: null, instanceProperty: null, requiredValues: null, requiredValuesString: null, requiredLiteral: null);
mqttInfoCV2.AddProperty("dtmi:dtdl:extension:mqtt:v2:Mqtt:serviceGroupId", new Uri("http://www.w3.org/2001/XMLSchema#string"), 1, null, null, null, null, regex: new Regex(@"^[!$-*,-.0-z|~]+$"), hasUniqueValue: false, isPlural: false, isOptional: true, defaultLanguage: null, dtmiSeg: null, dictionaryKey: null, idRequired: false, typeRequired: true, childOf: null, instanceProperty: null, requiredValues: null, requiredValuesString: null, requiredLiteral: null);
mqttInfoCV2.AddProperty("dtmi:dtdl:extension:mqtt:v2:Mqtt:telemetryTopic", new Uri("http://www.w3.org/2001/XMLSchema#string"), 1, null, null, null, null, regex: new Regex(@"^(?:(?:[!%-*,-.0-z|~][!$-*,-.0-z|~]*)|(?:{(?:[A-Za-z]+:)?[A-Za-z]+}))(?:\/(?:(?:[!$-*,-.0-z|~]+)|(?:{(?:[A-Za-z]+:)?[A-Za-z]+})))*$"), hasUniqueValue: false, isPlural: false, isOptional: true, defaultLanguage: null, dtmiSeg: null, dictionaryKey: null, idRequired: false, typeRequired: true, childOf: null, instanceProperty: null, requiredValues: null, requiredValuesString: null, requiredLiteral: null);
mqttInfoCV2.AddProperty("dtmi:dtdl:extension:mqtt:v2:Mqtt:telemServiceGroupId", new Uri("http://www.w3.org/2001/XMLSchema#string"), 1, null, null, null, null, regex: new Regex(@"^[!$-*,-.0-z|~]+$"), hasUniqueValue: false, isPlural: false, isOptional: true, defaultLanguage: null, dtmiSeg: null, dictionaryKey: null, idRequired: false, typeRequired: true, childOf: null, instanceProperty: null, requiredValues: null, requiredValuesString: null, requiredLiteral: null);
mqttInfoCV2.AllowedCotypeKinds = new HashSet<DTEntityKind>() { DTEntityKind.Interface };
mqttInfoCV2.AllowedCotypeVersions = new HashSet<int>() { 3, 4 };

Expand Down
9 changes: 6 additions & 3 deletions dotnet/tests/ParserUnitTest/generated/ParserUnitTest.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1035,25 +1035,28 @@ public void TestParser_H(string testName)
[DataRow("InterfaceValuePropertyV2")]
[DataRow("InterfaceValuePropertyV3")]
[DataRow("InterfaceValuePropertyV4")]
[DataRow("InterfaceWithAdjunctTypeMqttEmptyCmdServiceGroupIdV4")]
[DataRow("InterfaceWithAdjunctTypeMqttEmptyCommandTopicV3")]
[DataRow("InterfaceWithAdjunctTypeMqttEmptyCommandTopicV4")]
[DataRow("InterfaceWithAdjunctTypeMqttEmptyServiceGroupIdV4")]
[DataRow("InterfaceWithAdjunctTypeMqttEmptyTelemetryTopicV3")]
[DataRow("InterfaceWithAdjunctTypeMqttEmptyTelemetryTopicV4")]
[DataRow("InterfaceWithAdjunctTypeMqttEmptyTelemServiceGroupIdV4")]
[DataRow("InterfaceWithAdjunctTypeMqttInvalidCmdServiceGroupIdV4")]
[DataRow("InterfaceWithAdjunctTypeMqttInvalidCommandTopicV3")]
[DataRow("InterfaceWithAdjunctTypeMqttInvalidCommandTopicV4")]
[DataRow("InterfaceWithAdjunctTypeMqttInvalidServiceGroupIdV4")]
[DataRow("InterfaceWithAdjunctTypeMqttInvalidTelemetryTopicV3")]
[DataRow("InterfaceWithAdjunctTypeMqttInvalidTelemetryTopicV4")]
[DataRow("InterfaceWithAdjunctTypeMqttInvalidTelemServiceGroupIdV4")]
[DataRow("InterfaceWithAdjunctTypeMqttNumericPayloadFormatV3")]
[DataRow("InterfaceWithAdjunctTypeMqttNumericPayloadFormatV4")]
[DataRow("InterfaceWithAdjunctTypeMqttV3")]
[DataRow("InterfaceWithAdjunctTypeMqttV4")]
[DataRow("InterfaceWithAdjunctTypeMqttWithCmdServiceGroupIdV4")]
[DataRow("InterfaceWithAdjunctTypeMqttWithOnlyPayloadFormatV3")]
[DataRow("InterfaceWithAdjunctTypeMqttWithOnlyPayloadFormatV4")]
[DataRow("InterfaceWithAdjunctTypeMqttWithoutPayloadFormatV3")]
[DataRow("InterfaceWithAdjunctTypeMqttWithoutPayloadFormatV4")]
[DataRow("InterfaceWithAdjunctTypeMqttWithServiceGroupIdV4")]
[DataRow("InterfaceWithAdjunctTypeMqttWithTelemServiceGroupIdV4")]
[DataRow("InterfaceWithNameV2")]
[DataRow("InterfaceWithNameV3")]
[DataRow("InterfaceWithNameV4")]
Expand Down
42 changes: 31 additions & 11 deletions dtdl/dtdl_digest.json
Original file line number Diff line number Diff line change
Expand Up @@ -651,14 +651,15 @@
},
"dtmi:dtdl:extension:mqtt;2": {
"Cacheable": "dtmi:dtdl:extension:mqtt:v2:Cacheable",
"cmdServiceGroupId": "dtmi:dtdl:extension:mqtt:v2:Mqtt:cmdServiceGroupId",
"commandTopic": "dtmi:dtdl:extension:mqtt:v2:Mqtt:commandTopic",
"Idempotent": "dtmi:dtdl:extension:mqtt:v2:Idempotent",
"index": "dtmi:dtdl:extension:mqtt:v2:Indexed:index",
"Indexed": "dtmi:dtdl:extension:mqtt:v2:Indexed",
"Mqtt": "dtmi:dtdl:extension:mqtt:v2:Mqtt",
"payloadFormat": "dtmi:dtdl:extension:mqtt:v2:Mqtt:payloadFormat",
"serviceGroupId": "dtmi:dtdl:extension:mqtt:v2:Mqtt:serviceGroupId",
"telemetryTopic": "dtmi:dtdl:extension:mqtt:v2:Mqtt:telemetryTopic",
"telemServiceGroupId": "dtmi:dtdl:extension:mqtt:v2:Mqtt:telemServiceGroupId",
"Transparent": "dtmi:dtdl:extension:mqtt:v2:Transparent",
"ttl": "dtmi:dtdl:extension:mqtt:v2:Cacheable:ttl"
},
Expand Down Expand Up @@ -35157,6 +35158,25 @@
"mergeable": false,
"parent": "dtmi:dtdl:class:AdjunctType;4",
"properties": {
"dtmi:dtdl:extension:mqtt:v2:Mqtt:cmdServiceGroupId": {
"deprecated": false,
"description": {
"en-us": "The service group ID for subscribing to Command topics when shared subscriptions are wanted."
},
"idRequired": false,
"maxCount": 1,
"optional": true,
"pattern": "^[!$-*,-.0-z|~]+$",
"patternDesc": {
"en-us": "non-empty string of printable ASCII characters not including space, \", +, #, {, }, or /"
},
"plural": false,
"propertyName": "cmdServiceGroupId",
"type": "http://www.w3.org/2001/XMLSchema#string",
"typeName": "string",
"typeRequired": true,
"uniqueValue": false
},
"dtmi:dtdl:extension:mqtt:v2:Mqtt:commandTopic": {
"deprecated": false,
"description": {
Expand Down Expand Up @@ -35192,39 +35212,39 @@
"typeRequired": true,
"uniqueValue": false
},
"dtmi:dtdl:extension:mqtt:v2:Mqtt:serviceGroupId": {
"dtmi:dtdl:extension:mqtt:v2:Mqtt:telemetryTopic": {
"deprecated": false,
"description": {
"en-us": "The service group ID for subscribing to Command topics when shared subscriptions are wanted."
"en-us": "MQTT topic pattern on which a Telemetry or a collection of Telemetries is published."
},
"idRequired": false,
"maxCount": 1,
"optional": true,
"pattern": "^[!$-*,-.0-z|~]+$",
"pattern": "^(?:(?:[!%-*,-.0-z|~][!$-*,-.0-z|~]*)|(?:{(?:[A-Za-z]+:)?[A-Za-z]+}))(?:\\/(?:(?:[!$-*,-.0-z|~]+)|(?:{(?:[A-Za-z]+:)?[A-Za-z]+})))*$",
"patternDesc": {
"en-us": "non-empty string of printable ASCII characters not including space, \", +, #, {, }, or /"
"en-us": "slash-separated sequence of character-restricted labels and/or brace-enclosed tokens"
},
"plural": false,
"propertyName": "serviceGroupId",
"propertyName": "telemetryTopic",
"type": "http://www.w3.org/2001/XMLSchema#string",
"typeName": "string",
"typeRequired": true,
"uniqueValue": false
},
"dtmi:dtdl:extension:mqtt:v2:Mqtt:telemetryTopic": {
"dtmi:dtdl:extension:mqtt:v2:Mqtt:telemServiceGroupId": {
"deprecated": false,
"description": {
"en-us": "MQTT topic pattern on which a Telemetry or a collection of Telemetries is published."
"en-us": "The service group ID for subscribing to Telemetry topics when shared subscriptions are wanted."
},
"idRequired": false,
"maxCount": 1,
"optional": true,
"pattern": "^(?:(?:[!%-*,-.0-z|~][!$-*,-.0-z|~]*)|(?:{(?:[A-Za-z]+:)?[A-Za-z]+}))(?:\\/(?:(?:[!$-*,-.0-z|~]+)|(?:{(?:[A-Za-z]+:)?[A-Za-z]+})))*$",
"pattern": "^[!$-*,-.0-z|~]+$",
"patternDesc": {
"en-us": "slash-separated sequence of character-restricted labels and/or brace-enclosed tokens"
"en-us": "non-empty string of printable ASCII characters not including space, \", +, #, {, }, or /"
},
"plural": false,
"propertyName": "telemetryTopic",
"propertyName": "telemServiceGroupId",
"type": "http://www.w3.org/2001/XMLSchema#string",
"typeName": "string",
"typeRequired": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"payloadFormat": "Json/ecma/404",
"telemetryTopic": "sample/{modelId}/{senderId}/telemetry",
"commandTopic": "sample/{modelId}/command/{commandName}",
"serviceGroupId": "",
"cmdServiceGroupId": "",
"contents": [
{
"@type": "Telemetry",
Expand Down Expand Up @@ -51,7 +51,7 @@
{
"ValidationID": "dtmi:dtdl:parsingError:stringInvalid",
"PrimaryID": "dtmi:jsonTest:TelemetryAndCommand;1",
"Property": "dtmi:dtdl:extension:mqtt:v2:Mqtt:serviceGroupId",
"Property": "dtmi:dtdl:extension:mqtt:v2:Mqtt:cmdServiceGroupId",
"Value": "",
"PrimaryIndex": 0,
"PrimaryStart": 14
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"requiredContexts": [
"dtmi:dtdl:extension:mqtt;2"
],
"valid": false,
"quirks": [],
"options": [],
"input": [
{
"@context": [
"dtmi:dtdl:context;4",
"dtmi:dtdl:extension:mqtt;2"
],
"@id": "dtmi:jsonTest:TelemetryAndCommand;1",
"@type": [
"Interface",
"Mqtt"
],
"payloadFormat": "Json/ecma/404",
"telemetryTopic": "sample/{modelId}/{senderId}/telemetry",
"commandTopic": "sample/{modelId}/command/{commandName}",
"telemServiceGroupId": "",
"contents": [
{
"@type": "Telemetry",
"name": "distance",
"schema": "double"
},
{
"@type": "Telemetry",
"name": "color",
"schema": "string"
},
{
"@type": "Command",
"name": "doit",
"request": {
"name": "poke",
"schema": "string"
},
"response": {
"name": "peek",
"schema": "integer"
}
}
]
}
],
"expect": {
"parsingErrors": [
{
"ValidationID": "dtmi:dtdl:parsingError:stringInvalid",
"PrimaryID": "dtmi:jsonTest:TelemetryAndCommand;1",
"Property": "dtmi:dtdl:extension:mqtt:v2:Mqtt:telemServiceGroupId",
"Value": "",
"PrimaryIndex": 0,
"PrimaryStart": 14
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"payloadFormat": "Json/ecma/404",
"telemetryTopic": "sample/{modelId}/{senderId}/telemetry",
"commandTopic": "sample/{modelId}/command/{commandName}",
"serviceGroupId": "hello/there",
"cmdServiceGroupId": "hello/there",
"contents": [
{
"@type": "Telemetry",
Expand Down Expand Up @@ -51,7 +51,7 @@
{
"ValidationID": "dtmi:dtdl:parsingError:stringInvalid",
"PrimaryID": "dtmi:jsonTest:TelemetryAndCommand;1",
"Property": "dtmi:dtdl:extension:mqtt:v2:Mqtt:serviceGroupId",
"Property": "dtmi:dtdl:extension:mqtt:v2:Mqtt:cmdServiceGroupId",
"Value": "hello/there",
"PrimaryIndex": 0,
"PrimaryStart": 14
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"requiredContexts": [
"dtmi:dtdl:extension:mqtt;2"
],
"valid": false,
"quirks": [],
"options": [],
"input": [
{
"@context": [
"dtmi:dtdl:context;4",
"dtmi:dtdl:extension:mqtt;2"
],
"@id": "dtmi:jsonTest:TelemetryAndCommand;1",
"@type": [
"Interface",
"Mqtt"
],
"payloadFormat": "Json/ecma/404",
"telemetryTopic": "sample/{modelId}/{senderId}/telemetry",
"commandTopic": "sample/{modelId}/command/{commandName}",
"telemServiceGroupId": "hello/there",
"contents": [
{
"@type": "Telemetry",
"name": "distance",
"schema": "double"
},
{
"@type": "Telemetry",
"name": "color",
"schema": "string"
},
{
"@type": "Command",
"name": "doit",
"request": {
"name": "poke",
"schema": "string"
},
"response": {
"name": "peek",
"schema": "integer"
}
}
]
}
],
"expect": {
"parsingErrors": [
{
"ValidationID": "dtmi:dtdl:parsingError:stringInvalid",
"PrimaryID": "dtmi:jsonTest:TelemetryAndCommand;1",
"Property": "dtmi:dtdl:extension:mqtt:v2:Mqtt:telemServiceGroupId",
"Value": "hello/there",
"PrimaryIndex": 0,
"PrimaryStart": 14
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"payloadFormat": "Json/ecma/404",
"telemetryTopic": "sample/{modelId}/{senderId}/telemetry",
"commandTopic": "sample/{modelId}/command/{commandName}",
"serviceGroupId": "hello",
"cmdServiceGroupId": "hello",
"contents": [
{
"@type": "Telemetry",
Expand Down Expand Up @@ -58,7 +58,7 @@
"dtmi:dtdl:extension:mqtt:v2:Mqtt:payloadFormat": "Json/ecma/404",
"dtmi:dtdl:extension:mqtt:v2:Mqtt:telemetryTopic": "sample/{modelId}/{senderId}/telemetry",
"dtmi:dtdl:extension:mqtt:v2:Mqtt:commandTopic": "sample/{modelId}/command/{commandName}",
"dtmi:dtdl:extension:mqtt:v2:Mqtt:serviceGroupId": "hello"
"dtmi:dtdl:extension:mqtt:v2:Mqtt:cmdServiceGroupId": "hello"
}
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"requiredContexts": [
"dtmi:dtdl:extension:mqtt;2"
],
"valid": true,
"quirks": [],
"options": [],
"input": [
{
"@context": [
"dtmi:dtdl:context;4",
"dtmi:dtdl:extension:mqtt;2"
],
"@id": "dtmi:jsonTest:TelemetryAndCommand;1",
"@type": [
"Interface",
"Mqtt"
],
"payloadFormat": "Json/ecma/404",
"telemetryTopic": "sample/{modelId}/{senderId}/telemetry",
"commandTopic": "sample/{modelId}/command/{commandName}",
"telemServiceGroupId": "hello",
"contents": [
{
"@type": "Telemetry",
"name": "distance",
"schema": "double"
},
{
"@type": "Telemetry",
"name": "color",
"schema": "string"
},
{
"@type": "Command",
"name": "doit",
"request": {
"name": "poke",
"schema": "string"
},
"response": {
"name": "peek",
"schema": "integer"
}
}
]
}
],
"expect": {
"elements": [
{
"id": "dtmi:jsonTest:TelemetryAndCommand;1",
"type": "Interface",
"supplementalTypes": [
"dtmi:dtdl:extension:mqtt:v2:Mqtt"
],
"supplementalProperties": {
"dtmi:dtdl:extension:mqtt:v2:Mqtt:payloadFormat": "Json/ecma/404",
"dtmi:dtdl:extension:mqtt:v2:Mqtt:telemetryTopic": "sample/{modelId}/{senderId}/telemetry",
"dtmi:dtdl:extension:mqtt:v2:Mqtt:commandTopic": "sample/{modelId}/command/{commandName}",
"dtmi:dtdl:extension:mqtt:v2:Mqtt:telemServiceGroupId": "hello"
}
}
]
}
}

0 comments on commit ca0cf9f

Please sign in to comment.