-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: extend custom ORD content (#63)
* add ovrride logic * add todo list * udpate unittest * extract into new file * add unittest * extend conflict function * Update lib/extendOrdWithCustom.js Co-authored-by: Sebastian Wennemers <sebastian.wennemers@sap.com> * Update lib/extendOrdWithCustom.js Co-authored-by: Sebastian Wennemers <sebastian.wennemers@sap.com> * use lodash to merge two objects * update snapshot * fix small issues * add one more test * update ord.custom.json * clean up logic to be clear * clean up unittest * clean up unittest * change patch logic * fix mutation bug * use override instead of merge * clean up * clean up dead code and add cds.log replacing console.log * give proper logger id * refactor and fix --------- Co-authored-by: Simon Heimler <heimlersimon@gmail.com> Co-authored-by: Sebastian Wennemers <sebastian.wennemers@sap.com>
- Loading branch information
1 parent
1f70236
commit a159fee
Showing
16 changed files
with
581 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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 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 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,66 @@ | ||
{ | ||
"namespace": "should not update since has conflict with cdsrc.json", | ||
"openResourceDiscovery": "should not update since not defined in cdsrc.json", | ||
"packages": [ | ||
{ | ||
"description": "Description for capire bookshop ord sample version 2", | ||
"ordId": "sap.test.cdsrc.sample:package:capirebookshopordsample-api:v2", | ||
"partOfProducts": [ | ||
"customer:product:capire.bookshop.ord.sample:" | ||
], | ||
"shortDescription": "Short description for capire bookshop ord sample version 2", | ||
"title": "capire bookshop ord sample", | ||
"vendor": "customer:vendor:Customer:", | ||
"version": "2.0.0" | ||
}, | ||
{ | ||
"ordId": "sap.test.cdsrc.sample:package:capirebookshopordsample-event:v1", | ||
"shortDescription": null, | ||
"version": "1.0.1" | ||
} | ||
], | ||
"apiResources": [ | ||
{ | ||
"partOfGroups": null, | ||
"ordId": "sap.test.cdsrc.sample:apiResource:AdminService:v1", | ||
"entityTypeMappings": [ | ||
{ | ||
"entityTypeTargets": [ | ||
{ | ||
"ordId": "sap.odm:entityType:BusinessPartner:v1" | ||
} | ||
] | ||
} | ||
], | ||
"extensible": { | ||
"supported": "yes" | ||
} | ||
} | ||
], | ||
"dataProducts": [ | ||
{ | ||
"ordId": "sap.sm:dataProduct:Supplier:v1", | ||
"localId": "Supplier", | ||
"title": "Supplier", | ||
"shortDescription": "Ariba Supplier data product", | ||
"description": "The Supplier data product offers access to all customers.", | ||
"partOfPackage": "sap.sm:package:smDataProducts:v1", | ||
"visibility": "public", | ||
"releaseStatus": "active", | ||
"version": "1.1.11", | ||
"lastUpdate": "2024-06-20T14:04:01+01:00", | ||
"type": "primary", | ||
"category": "business-object", | ||
"outputPorts": [ | ||
{ | ||
"ordId": "sap.sm:apiResource:SupplierService:v1" | ||
} | ||
], | ||
"responsible": "sap:ach:CIC-DP-CO", | ||
"entityTypes": [ | ||
"sap.odm:entityType:BusinessPartner:v1", | ||
"sap.sm:entityType:BusinessPartner:v1" | ||
] | ||
} | ||
] | ||
} |
This file contains 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
107 changes: 107 additions & 0 deletions
107
__tests__/unittest/__snapshots__/extendOrdWithCustom.test.js.snap
This file contains 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,107 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`extendOrdWithCustom extendCustomORDContentIfExists should add new ord resources that are not supported by cap framework 1`] = ` | ||
{ | ||
"dataProducts": [ | ||
{ | ||
"category": "business-object", | ||
"description": "The Supplier data product offers access to all customers.", | ||
"entityTypes": [ | ||
"sap.odm:entityType:BusinessPartner:v1", | ||
"sap.sm:entityType:BusinessPartner:v1", | ||
], | ||
"lastUpdate": "2024-06-20T14:04:01+01:00", | ||
"localId": "Supplier", | ||
"ordId": "sap.sm:dataProduct:Supplier:v1", | ||
"outputPorts": [ | ||
{ | ||
"ordId": "sap.sm:apiResource:SupplierService:v1", | ||
}, | ||
], | ||
"partOfPackage": "sap.sm:package:smDataProducts:v1", | ||
"releaseStatus": "active", | ||
"responsible": "sap:ach:CIC-DP-CO", | ||
"shortDescription": "Ariba Supplier data product", | ||
"title": "Supplier", | ||
"type": "primary", | ||
"version": "1.1.11", | ||
"visibility": "public", | ||
}, | ||
], | ||
} | ||
`; | ||
|
||
exports[`extendOrdWithCustom extendCustomORDContentIfExists should enhance the list of generated ord resources 1`] = ` | ||
{ | ||
"packages": [ | ||
{ | ||
"localId": "smDataProductsV1", | ||
"ordId": "sap.sm:package:smDataProducts:v1", | ||
}, | ||
{ | ||
"localId": "smDataProductsV2", | ||
"ordId": "sap.sm:package:smDataProducts:v2", | ||
}, | ||
], | ||
} | ||
`; | ||
|
||
exports[`extendOrdWithCustom extendCustomORDContentIfExists should ignore and log warn if found ord top-level primitive property in customOrdFile 1`] = ` | ||
{ | ||
"packages": [ | ||
{ | ||
"localId": "smDataProducts", | ||
"ordId": "sap.sm:package:smDataProducts:v1", | ||
}, | ||
], | ||
} | ||
`; | ||
|
||
exports[`extendOrdWithCustom extendCustomORDContentIfExists should should patch the existing generated ord resources 1`] = ` | ||
{ | ||
"apiResources": [ | ||
{ | ||
"entityTypeMappings": [ | ||
{ | ||
"entityTypeTargets": [ | ||
{ | ||
"ordId": "sap.odm:entityType:BusinessPartner:v1", | ||
}, | ||
], | ||
}, | ||
], | ||
"entryPoints": [ | ||
"/odata/v4/admin", | ||
], | ||
"ordId": "sap.sm:apiResource:SupplierService:v1", | ||
"partOfGroups": [ | ||
"sap.cds:service:sap.test.cdsrc.sample:AdminService", | ||
], | ||
"partOfPackage": "sap.sm:package:smDataProducts:v1", | ||
}, | ||
{ | ||
"entityTypeMappings": [ | ||
{ | ||
"entityTypeTargets": [], | ||
}, | ||
], | ||
"ordId": "sap.sm:apiResource:orginalService:v2", | ||
"partOfGroups": [ | ||
"sap.cds:service:sap.test.cdsrc.sample:originalService", | ||
], | ||
"partOfPackage": "sap.sm:package:smDataProducts:v2", | ||
}, | ||
], | ||
"packages": [ | ||
{ | ||
"localId": "overrideSmDataProductsV1", | ||
"ordId": "sap.sm:package:smDataProducts:v1", | ||
"version": "1.1.1", | ||
}, | ||
{ | ||
"localId": "smDataProductsV2", | ||
"ordId": "sap.sm:package:smDataProducts:v2", | ||
}, | ||
], | ||
} | ||
`; |
Oops, something went wrong.