-
Notifications
You must be signed in to change notification settings - Fork 12
fix: Backreferences #182
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
Merged
Merged
fix: Backreferences #182
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d150b1e
Backreferences
daogrady 0c8a11f
Introduce helpers
daogrady 445ba09
Simplify structure
daogrady 400c6ed
Changelog
daogrady e65f8af
Import
daogrady 702f79a
Linebreak
daogrady 3e7808b
Add missing types back
daogrady 567bca8
More helpers
daogrady 775263d
Merge branch 'main' into fix/backreferences
daogrady b103eac
Merge branch 'main' into fix/backreferences
daogrady 4c47ac2
Reintroduce guard
daogrady fdcb8d8
Merge main
daogrady 22b7679
Merge branch 'main' into fix/backreferences
daogrady File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /** | ||
| * @typedef {object} CSDLProperty | ||
| * @property {string} [$Kind] | ||
| * @property {string} [$Type] | ||
| * @property {string} [$Partner] | ||
| * @property {boolean} [$ContainsTarget] | ||
| * @property {boolean} [$Collection] | ||
| * @property {string} [$OnDelete] | ||
| */ | ||
|
|
||
| /** | ||
| * @typedef {object} PropertyPredicates | ||
| * @property {(property: CSDLProperty) => boolean} isNavBackReference - True when the nav property is the back-reference side of a composition (child -> parent) | ||
| * @property {(property: CSDLProperty) => boolean} isNavWritable - True when the nav property may be written by the client (create/update) | ||
| * @property {(property: CSDLProperty) => boolean} isScalarReadOnly - True when the scalar property is read-only or computed (must be removed from required) | ||
| * @property {(property: CSDLProperty) => boolean} isScalarWritable - True when the scalar property may be written by the client (create/update) | ||
| * @property {(property: CSDLProperty) => boolean} isMandatoryField - True when the property is annotated as a mandatory field control | ||
| * @property {(element: CSDLProperty) => boolean} isDeltaSupported - True when the element has change tracking with delta support enabled | ||
| */ | ||
|
|
||
| /** | ||
| * Returns property predicate functions bound to the given CSDL metadata instance. | ||
| * @param {InstanceType<typeof import('./csdl').CSDLMeta>} meta | ||
| * @returns {PropertyPredicates} | ||
| */ | ||
| module.exports = (meta) => ({ | ||
| isNavBackReference: (property) => | ||
| !!property.$Partner | ||
| && !!property.$Type | ||
| && !!meta.modelElement(property.$Type)?.[property.$Partner]?.$ContainsTarget, | ||
|
|
||
| isNavWritable: (property) => | ||
| property[meta.voc.Core.Permissions] !== "Read" | ||
| && !property[meta.voc.Core.Computed] | ||
| && (property.$ContainsTarget || property.$OnDelete === 'Cascade'), | ||
|
|
||
| isScalarReadOnly: (property) => | ||
| property[meta.voc.Core.Permissions] === "Read" | ||
| || property[meta.voc.Core.Computed] | ||
| || property[meta.voc.Core.ComputedDefaultValue], | ||
|
|
||
| isScalarWritable: (property) => | ||
| property[meta.voc.Core.Permissions] !== "Read" | ||
| && !property[meta.voc.Core.Computed], | ||
|
|
||
| isMandatoryField: (property) => | ||
| property['@Common.FieldControl'] === 'Mandatory', | ||
|
|
||
| isDeltaSupported: (element) => | ||
| !!element[meta.voc.Capabilities.ChangeTracking]?.Supported, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| { | ||
| "$Version": "4.01", | ||
| "$Reference": { | ||
| "https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Core.V1.json": { | ||
| "$Include": [ | ||
| { | ||
| "$Namespace": "Org.OData.Core.V1", | ||
| "$Alias": "Core", | ||
| "@Core.DefaultNamespace": true | ||
| } | ||
| ] | ||
| }, | ||
| "https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Capabilities.V1.json": { | ||
| "$Include": [ | ||
| { | ||
| "$Namespace": "Org.OData.Capabilities.V1", | ||
| "$Alias": "Capabilities" | ||
| } | ||
| ] | ||
| } | ||
| }, | ||
| "$EntityContainer": "UsageService.Container", | ||
| "UsageService": { | ||
| "$Alias": "self", | ||
| "UsageRecords": { | ||
| "$Kind": "EntityType", | ||
| "$Key": ["ID"], | ||
| "ID": { "$Type": "Edm.Guid" }, | ||
| "description": { "$Nullable": true }, | ||
| "customReferences": { | ||
| "$Kind": "NavigationProperty", | ||
| "$Collection": true, | ||
| "$Type": "self.UsageRecordCustomReferences", | ||
| "$ContainsTarget": true, | ||
| "$Partner": "usageRecord" | ||
| } | ||
| }, | ||
| "UsageRecordCustomReferences": { | ||
| "$Kind": "EntityType", | ||
| "$Key": ["ID"], | ||
| "ID": { "$Type": "Edm.Guid" }, | ||
| "type": { "$Nullable": true }, | ||
| "value": { "$Nullable": true }, | ||
| "usageRecord": { | ||
| "$Kind": "NavigationProperty", | ||
| "$Type": "self.UsageRecords", | ||
| "$Nullable": false, | ||
| "$Partner": "customReferences" | ||
| } | ||
| }, | ||
| "Container": { | ||
| "$Kind": "EntityContainer", | ||
| "@Core.Description": "Usage Record Service", | ||
| "UsageRecords": { | ||
| "$Collection": true, | ||
| "$Type": "self.UsageRecords" | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.