Azure / opendigitaltwins-dtdl

Digital Twins Definition Language
Creative Commons Attribution 4.0 International
473 stars 161 forks source link

[DTDLv3] Provide native extensions for invariants on primitive data types #156

Open thern743 opened 1 year ago

thern743 commented 1 year ago

IoT Central has built-in schema extensions for primitive types. These allow for metadata for invariants such as default values, minimum values, maximum values, etc.

How does Microsoft propose we adopt this into the wider ecosystem? Implementing these ourselves seems counter-productive and trying to use the new Annotations seems unnecessarily verbose.

Can we propose a native extension that include these out of the box in V3?

jrdouceur commented 1 year ago

DTDL v3 does not include an updated IoT Central partner-extension context. DTDL v2 is expected to be the last version of DTDL that has any associated partner extensions; moving forward, DTDL will offer feature extensions instead. The two specific features you mentioned above are default values and value constraints (e.g., min/max). We have already defined an extension for default values, but it is not quite ready to be shipped since it is not yet supported by any IoT services. We have not yet defined an extension for value constraints, but we have discussed extracting (and likely renaming) the value-constraint types from IoT Central into a new feature extension. If this is something you would find valuable, this will help us in our prioritization.

thern743 commented 1 year ago

Yes, I think that's exactly what I would expect. I was confused because the DTDL v3 documentation specifically mentions partner extension and calls out IoT Central specifically - and I don't see anything outside of the IoT Central extensions that related to constraints. Are the feature extensions and the value constraints planned to being DTDLv3? Is there an ETA?

jrdouceur commented 1 year ago

Where are you seeing a reference to partner extensions or IoT Central in the DTDL v3 docs? The main v3 doc does not mention either of these, and the extensions doc shows the Central partner extension associated with DTDL v2 and the feature extensions associated with DTDL v3.

thern743 commented 1 year ago

Ahh, I see. It wasn't clear to me that the "partner extensions" from IoT Central were only available in V2 (I see it in the table). The language at the top made it seem like "partner" extensions were a feature of DTDLv3:

DTDL language extensions -- PREVIEW...There are two categories of language extensions: Partner extensions add types, properties, and elements that are relevant to a specific cloud service. Feature extensions add non-core features to the DTDL language in a selectable manner.

jrdouceur commented 1 year ago

This was not intended to be a DTDLv3-specific document. It is a general DTDL doc describing the concept of language extensions. There is no indication in the doc title or header of DTDL v3. However, you might have been confused by the placement of this doc under the "v3" folder. There was some disagreement about the appropriate location of some of the doc files, and perhaps this one landed in a sub-optimal location that led to an incorrect inference.

thern743 commented 1 year ago

Thanks @jrdouceur, makes sense. While we're on the topic, do you foresee special extensions for the concepts of Cloud Properties as implemented in IoT Central? Or do we see this as a specific type of annotation?

jrdouceur commented 1 year ago

This is not something I've been involved in discussing, so I don't know whether there are any plans either way. My knee-jerk opinion is that the impact of co-typing a Property with Cloud is comparable to that of co-typing with Streaming, so this would argue for a distinct adjunct type rather than an annotation. But I do not know of any plans regarding this as a feature in any form outside of IoT Central.