Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds DerivedTypeConstraint, ReadRestrictions and Referenceable annotations to complex and navigation properties #473

Merged
merged 3 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions transforms/csdl/preprocess_csdl.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,16 @@
</xsl:element>
</xsl:copy>
</xsl:template>

<xsl:template match="edm:Schema[@Namespace='microsoft.graph']/edm:ComplexType[@Name='onAuthenticationMethodLoadStartExternalUsersSelfServiceSignUp']/edm:NavigationProperty[@Name='identityProviders']">
<xsl:copy>
<xsl:copy-of select="@* | node()" />
<xsl:call-template name="ReferenceableRestrictionsTemplate">
<xsl:with-param name="referenceable">true</xsl:with-param>
</xsl:call-template>
</xsl:copy>
</xsl:template>

<xsl:template match="edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='user']/edm:NavigationProperty[@Name='createdObjects']|
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='servicePrincipal']/edm:NavigationProperty[@Name='createdObjects']">
<xsl:copy>
Expand Down Expand Up @@ -452,6 +462,36 @@
</Annotation>
</xsl:copy>
</xsl:template>
<xsl:template match="edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='identityContainer']/edm:NavigationProperty[@Name='authenticationEventsFlows']">
<xsl:copy>
<xsl:copy-of select="@* | node()" />
<Annotation Term="Org.OData.Validation.V1.DerivedTypeConstraint">
<Collection>
<String>microsoft.graph.externalUsersSelfServiceSignUpEventsFlow</String>
</Collection>
</Annotation>
</xsl:copy>
</xsl:template>
<xsl:template match="edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='externalUsersSelfServiceSignUpEventsFlow']/edm:Property[@Name='onAttributeCollection']">
<xsl:copy>
<xsl:copy-of select="@* | node()" />
<Annotation Term="Org.OData.Validation.V1.DerivedTypeConstraint">
<Collection>
<String>microsoft.graph.onAttributeCollectionExternalUsersSelfServiceSignUp</String>
</Collection>
</Annotation>
</xsl:copy>
</xsl:template>
<xsl:template match="edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='externalUsersSelfServiceSignUpEventsFlow']/edm:Property[@Name='onAuthenticationMethodLoadStart']">
<xsl:copy>
<xsl:copy-of select="@* | node()" />
<Annotation Term="Org.OData.Validation.V1.DerivedTypeConstraint">
<Collection>
<String>microsoft.graph.onAuthenticationMethodLoadStartExternalUsersSelfServiceSignUp</String>
</Collection>
</Annotation>
</xsl:copy>
</xsl:template>

<!-- Remove attribute -->
<xsl:template match="edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='onenotePage']/@HasStream|
Expand Down Expand Up @@ -1639,6 +1679,30 @@
</xsl:element>
</xsl:when>
</xsl:choose>

<!-- Add readability for complex property externalUsersSelfServiceSignUpEventsFlow/onAttributeCollection -->
<xsl:choose>
<xsl:when test="not(edm:Annotations[@Target='microsoft.graph.externalUsersSelfServiceSignUpEventsFlow/onAttributeCollection'])">
<xsl:element name="Annotations">
<xsl:attribute name="Target">microsoft.graph.externalUsersSelfServiceSignUpEventsFlow/onAttributeCollection</xsl:attribute>
<xsl:call-template name="ReadRestrictionsTemplate">
<xsl:with-param name="readable">true</xsl:with-param>
</xsl:call-template>
</xsl:element>
</xsl:when>
</xsl:choose>

<!-- Add readability for complex property externalUsersSelfServiceSignUpEventsFlow/onAuthenticationMethodLoadStart -->
<xsl:choose>
<xsl:when test="not(edm:Annotations[@Target='microsoft.graph.externalUsersSelfServiceSignUpEventsFlow/onAuthenticationMethodLoadStart'])">
<xsl:element name="Annotations">
<xsl:attribute name="Target">microsoft.graph.externalUsersSelfServiceSignUpEventsFlow/onAuthenticationMethodLoadStart</xsl:attribute>
<xsl:call-template name="ReadRestrictionsTemplate">
<xsl:with-param name="readable">true</xsl:with-param>
</xsl:call-template>
</xsl:element>
</xsl:when>
</xsl:choose>

</xsl:copy>
</xsl:template>
Expand Down Expand Up @@ -2005,6 +2069,76 @@
</xsl:choose>
</xsl:template>

<!-- If the parent "Annotation" tag already exists, modify it -->

<!-- Add readability for complex property externalUsersSelfServiceSignUpEventsFlow/onAttributeCollection -->
<xsl:template match="edm:Schema[@Namespace='microsoft.graph']/edm:Annotations[@Target='microsoft.graph.externalUsersSelfServiceSignUpEventsFlow/onAttributeCollection']/edm:Annotation[@Term='Org.OData.Capabilities.V1.ReadRestrictions']">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:element name="Record" namespace="{namespace-uri()}">
<xsl:copy-of select="edm:Record/edm:PropertyValue"/>
<xsl:call-template name="ReadableTemplate">
<xsl:with-param name="readable">true</xsl:with-param>
</xsl:call-template>
</xsl:element>
</xsl:copy>
</xsl:template>

<!-- Add readability for complex property externalUsersSelfServiceSignUpEventsFlow/onAuthenticationMethodLoadStart -->
<xsl:template match="edm:Schema[@Namespace='microsoft.graph']/edm:Annotations[@Target='microsoft.graph.externalUsersSelfServiceSignUpEventsFlow/onAuthenticationMethodLoadStart']/edm:Annotation[@Term='Org.OData.Capabilities.V1.ReadRestrictions']">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:element name="Record" namespace="{namespace-uri()}">
<xsl:copy-of select="edm:Record/edm:PropertyValue"/>
<xsl:call-template name="ReadableTemplate">
<xsl:with-param name="readable">true</xsl:with-param>
</xsl:call-template>
</xsl:element>
</xsl:copy>
</xsl:template>

<!-- If the grand-parent "Annotations" tag already exists, modify it -->

<!-- Add readability for complex property externalUsersSelfServiceSignUpEventsFlow/onAttributeCollection -->
<xsl:template match="edm:Schema[@Namespace='microsoft.graph']/edm:Annotations[@Target='microsoft.graph.externalUsersSelfServiceSignUpEventsFlow/onAttributeCollection']">
<xsl:choose>
<!--ReadRestrictions not present-->
<xsl:when test="not(edm:Annotation[@Term='Org.OData.Capabilities.V1.ReadRestrictions'])">
<xsl:copy>
<xsl:copy-of select="@*|node()"/>
<xsl:call-template name="ReadableTemplate">
<xsl:with-param name="readable">true</xsl:with-param>
</xsl:call-template>
</xsl:copy>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<!-- Add readability for complex property externalUsersSelfServiceSignUpEventsFlow/onAuthenticationMethodLoadStart -->
<xsl:template match="edm:Schema[@Namespace='microsoft.graph']/edm:Annotations[@Target='microsoft.graph.externalUsersSelfServiceSignUpEventsFlow/onAuthenticationMethodLoadStart']">
<xsl:choose>
<!--ReadRestrictions not present-->
<xsl:when test="not(edm:Annotation[@Term='Org.OData.Capabilities.V1.ReadRestrictions'])">
<xsl:copy>
<xsl:copy-of select="@*|node()"/>
<xsl:call-template name="ReadableTemplate">
<xsl:with-param name="readable">true</xsl:with-param>
</xsl:call-template>
</xsl:copy>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<!-- Remove directoryObject Capability Annotations -->
<xsl:template match="edm:Schema[starts-with(@Namespace, 'microsoft.graph')]/edm:Annotations[@Target='microsoft.graph.directoryObject']/*[starts-with(@Term, 'Org.OData.Capabilities')]"/>

Expand Down
18 changes: 18 additions & 0 deletions transforms/csdl/preprocess_csdl_test_input.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,24 @@
<Property Name="squareLogo" Type="Edm.Stream" />
<Property Name="squareLogoDark" Type="Edm.Stream" />
</EntityType>
<EntityType Name="externalUsersSelfServiceSignUpEventsFlow" BaseType="graph.authenticationEventsFlow">
<Property Name="onAttributeCollection" Type="graph.onAttributeCollectionHandler" />
<Property Name="onAuthenticationMethodLoadStart" Type="graph.onAuthenticationMethodLoadStartHandler" />
</EntityType>
<ComplexType Name="onAuthenticationMethodLoadStartExternalUsersSelfServiceSignUp" BaseType="graph.onAuthenticationMethodLoadStartHandler">
<NavigationProperty Name="identityProviders" Type="Collection(graph.identityProviderBase)" />
</ComplexType>
<EntityType Name="identityContainer">
<NavigationProperty Name="authenticationEventsFlows" Type="Collection(graph.authenticationEventsFlow)" ContainsTarget="true" />
</EntityType>
<Annotations Target="microsoft.graph.externalUsersSelfServiceSignUpEventsFlow/onAttributeCollection">
<Annotation Term="Org.OData.Capabilities.V1.ReadRestrictions">
<Record>
<PropertyValue Property="Description" String="List onAttributeCollection" />
<PropertyValue Property="LongDescription" String="Get the The configuration for what to invoke when attributes are ready to be collected from the user." />
</Record>
</Annotation>
</Annotations>
<Annotations Target="microsoft.graph.user/joinedGroups">
<Annotation Term="Org.OData.Capabilities.V1.ChangeTracking">
<Record>
Expand Down
52 changes: 51 additions & 1 deletion transforms/csdl/preprocess_csdl_test_output.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/xsl' href='preprocess_csdl.xsl'?>
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
<edmx:DataServices>
Expand Down Expand Up @@ -497,6 +497,49 @@
</Annotation>
</Property>
</EntityType>
<EntityType Name="externalUsersSelfServiceSignUpEventsFlow" BaseType="graph.authenticationEventsFlow">
<Property Name="onAttributeCollection" Type="graph.onAttributeCollectionHandler">
<Annotation Term="Org.OData.Validation.V1.DerivedTypeConstraint" xmlns:edm="http://docs.oasis-open.org/odata/ns/edm">
<Collection>
<String>microsoft.graph.onAttributeCollectionExternalUsersSelfServiceSignUp</String>
</Collection>
</Annotation>
</Property>
<Property Name="onAuthenticationMethodLoadStart" Type="graph.onAuthenticationMethodLoadStartHandler">
<Annotation Term="Org.OData.Validation.V1.DerivedTypeConstraint" xmlns:edm="http://docs.oasis-open.org/odata/ns/edm">
<Collection>
<String>microsoft.graph.onAuthenticationMethodLoadStartExternalUsersSelfServiceSignUp</String>
</Collection>
</Annotation>
</Property>
</EntityType>
<ComplexType Name="onAuthenticationMethodLoadStartExternalUsersSelfServiceSignUp" BaseType="graph.onAuthenticationMethodLoadStartHandler">
<NavigationProperty Name="identityProviders" Type="Collection(graph.identityProviderBase)">
<Annotation Term="Org.OData.Capabilities.V1.NavigationRestrictions">
<Record>
<PropertyValue Property="Referenceable" Bool="true" />
</Record>
</Annotation>
</NavigationProperty>
</ComplexType>
<EntityType Name="identityContainer">
<NavigationProperty Name="authenticationEventsFlows" Type="Collection(graph.authenticationEventsFlow)" ContainsTarget="true">
<Annotation Term="Org.OData.Validation.V1.DerivedTypeConstraint" xmlns:edm="http://docs.oasis-open.org/odata/ns/edm">
<Collection>
<String>microsoft.graph.externalUsersSelfServiceSignUpEventsFlow</String>
</Collection>
</Annotation>
</NavigationProperty>
</EntityType>
<Annotations Target="microsoft.graph.externalUsersSelfServiceSignUpEventsFlow/onAttributeCollection">
<Annotation Term="Org.OData.Capabilities.V1.ReadRestrictions">
<Record>
<PropertyValue Property="Description" String="List onAttributeCollection" />
<PropertyValue Property="LongDescription" String="Get the The configuration for what to invoke when attributes are ready to be collected from the user." />
<PropertyValue Property="Readable" Bool="true" />
</Record>
</Annotation>
</Annotations>
<Annotations Target="microsoft.graph.user/joinedGroups">
<Annotation Term="Org.OData.Capabilities.V1.ChangeTracking">
<Record>
Expand Down Expand Up @@ -1307,6 +1350,13 @@
</Record>
</Annotation>
</Annotations>
<Annotations Target="microsoft.graph.externalUsersSelfServiceSignUpEventsFlow/onAuthenticationMethodLoadStart">
<Annotation Term="Org.OData.Capabilities.V1.ReadRestrictions">
<Record>
<PropertyValue Property="Readable" Bool="true" />
</Record>
</Annotation>
</Annotations>
</Schema>
<Schema Namespace="microsoft.graph.callRecords" xmlns="http://docs.oasis-open.org/odata/ns/edm">
<EnumType Name="callType">
Expand Down
Loading