Skip to content

Commit

Permalink
fix: added top level property entityTypes (#95)
Browse files Browse the repository at this point in the history
* initial commit

* construct entityTypes and entityTypeMappings arrays

* Fix entityTypeTargets to be array of objects and not strings

* check existance of @ORDExtensions on entity level

* change schema and service in the xmpl folder so the sample ord document is valid

* handle entity type version

* tests clean-up

* minor change:rewrite the map statement

* introduct LEVEL constant

* rename sample entities in xmpl app

* change the version handling

* minor change

* remove incorrect validateNamespace function

* add test for missing package.json

* use constants with miningful names instead of oidIdParts[N]

---------

Co-authored-by: RoshniNaveenaS <[email protected]>
  • Loading branch information
aramovic79 and RoshniNaveenaS authored Dec 12, 2024
1 parent 341a514 commit 04441d1
Show file tree
Hide file tree
Showing 23 changed files with 1,139 additions and 693 deletions.
121 changes: 121 additions & 0 deletions __tests__/__mocks__/localAndNonODMReferencedEntitiesCsn.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
"$version": "2.0",
"definitions": {
"LocalService": {
"@ORD.Extensions.title": "This is Local Service title",
"kind": "service"
},
"LocalService.DummyEntityA": {
"@ODM.entityName": "SomeODMEntity",
"@ODM.oid": "id",
"@ODM.root": true,
"@title": "Dummy title of Entity with corresponding ODM entity title",
"elements": {
"id": {
"key": true,
"type": "cds.UUID"
},
"propertyA": {
"length": 10,
"type": "cds.String"
},
"propertyB": {
"length": 20,
"type": "cds.String"
}
},
"kind": "entity",
"projection": {
"from": {
"ref": [
"sap.cds.demo.EntityWithCorrespondingODMEntity"
]
}
}
},
"LocalService.DummyEntityB": {
"@EntityRelationship.entityType": "sap.sm:SomeAribaDummyEntity",
"@ObjectModel.compositionRoot": true,
"@title": "Dummy title of Ariba entity",
"elements": {
"id": {
"key": true,
"type": "cds.UUID"
},
"propertyC": {
"length": 10,
"type": "cds.String"
},
"propertyD": {
"length": 20,
"type": "cds.String"
}
},
"kind": "entity",
"projection": {
"from": {
"ref": [
"sap.cds.demo.SomeAribaEntity"
]
}
}
},
"LocalService.TitleChange2": {
"elements": {
"ID": {
"type": "cds.Integer"
},
"title": {
"@title": "Changed title",
"type": "cds.String"
}
},
"kind": "event"
},
"sap.cds.demo.EntityWithCorrespondingODMEntity": {
"@ODM.entityName": "SomeODMEntity",
"@ODM.oid": "id",
"@ODM.root": true,
"@title": "Dummy title of Entity with corresponding ODM entity title",
"elements": {
"id": {
"key": true,
"type": "cds.UUID"
},
"propertyA": {
"length": 10,
"type": "cds.String"
},
"propertyB": {
"length": 20,
"type": "cds.String"
}
},
"kind": "entity"
},
"sap.cds.demo.SomeAribaEntity": {
"@EntityRelationship.entityType": "sap.sm:SomeAribaDummyEntity",
"@ObjectModel.compositionRoot": true,
"@title": "Dummy title of Ariba entity",
"elements": {
"id": {
"key": true,
"type": "cds.UUID"
},
"propertyC": {
"length": 10,
"type": "cds.String"
},
"propertyD": {
"length": 20,
"type": "cds.String"
}
},
"kind": "entity"
}
},
"meta": {
"creator": "CDS Compiler v5.4.4",
"flavor": "inferred"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Tests for ORD document when .cdsrc.json has no \`ord\` property Successfully create ORD Documents with no \`ord\` in .cdsrc.json 1`] = `
exports[`Tests for ORD document generated out of mocked csn files Tests for ORD document when .cdsrc.json has no \`ord\` property Successfully create ORD Documents with no \`ord\` in .cdsrc.json 1`] = `
{
"$schema": "https://sap.github.io/open-resource-discovery/spec-v1/interfaces/Document.schema.json",
"apiResources": [
Expand Down Expand Up @@ -291,7 +291,7 @@ exports[`Tests for ORD document when .cdsrc.json has no \`ord\` property Success
"partOfProducts": [
"customer:product:capire.bookshop.ord.sample:",
],
"shortDescription": "Short description for capire bookshop ord sample",
"shortDescription": "Short description of capire bookshop ord sample",
"title": "capire bookshop ord sample",
"vendor": "customer:vendor:Customer:",
"version": "1.0.0",
Expand All @@ -301,7 +301,7 @@ exports[`Tests for ORD document when .cdsrc.json has no \`ord\` property Success
"products": [
{
"ordId": "customer:product:capire.bookshop.ord.sample:",
"shortDescription": "Description for capire bookshop ord sample",
"shortDescription": "Short description of capire bookshop ord sample",
"title": "capire bookshop ord sample",
"vendor": "customer:vendor:customer:",
},
Expand Down
Loading

0 comments on commit 04441d1

Please sign in to comment.