-
Notifications
You must be signed in to change notification settings - Fork 4
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
[CDSADAPTERS-2187]: Added integration dependency for cds import for events #94
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not the right approach to build the integration dependencies, you have to read the package json/cds config for this, the information is not the same as the events
lib/ord.js
Outdated
@@ -30,8 +32,13 @@ const initializeAppConfig = (csn) => { | |||
const modelKeys = Object.keys(csn.definitions); | |||
const apiEndpoints = new Set(); | |||
const events = []; | |||
let externalServiceKeys = []; | |||
if (packageJson.cds && packageJson.cds.requires) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will happen, when the information is provided through the cdsrc.json and not via package json?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@swennemers if you have configurations in both package.json and cdsrc.json then it is considering both the configurations and both the objects are there in the integrationDependencies array
So, which one should be omitted or given more priority?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Dipto-at-sap , the comment was related to the issue @David-Kunz highlighted, you can have cds.requires in package.json and cdsrc.json the custom.ord.json is another aspect.
With regards to the custom.ord.json, it must be consistent with the behavior described in https://github.com/cap-js/ord/blob/main/docs/ord.md. @zongqichen can support you in case of questions on that. Please reach out directly to him or @aramovic79 in his absence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is related to David's comment. So, we'll discuss it in the call.
}) | ||
.map(event => ({ eventType: serviceDefinition.model.definitions[event]["@topic"] })); | ||
|
||
return { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please follow the example of event and API templates to handle ordExtensions and don't explicitly access properties of ordExtensions and test that aspects can be overwritten as well (missing test)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case of createIntegrationDependencyTemplate, in the ordExtensions, there is no attribute related to the event, so how will we get the eventType for all the consumed external events? In API or event templates, we had no requirement for events, so we can't refer to those examples.
"cds": { | ||
"requires": { | ||
"sap.s4.beh.businesspartner.v1.BusinessPartner": { | ||
"kind": "odata", | ||
"model": "srv/external/CE_BUSINESSPARTNEREVENTS.asyncapi" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we have a similar structure/content in the ORD/xmpl
folder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@David-Kunz , is this a correct cds.requires statement? Kind odata sounds like API required, but model is an async API, so events...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that is weird. I've only seen *.cds
or *.json
files here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I don't know if *.asyncapi
is also supported...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be a .json
file. You could make it .asyncapi.json
if you want to state it. But it definately is a JSON file, encoded in application/json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's indeed a json file, the name is given like that to state it's an asyncapi file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This statement doesn't match: https://pages.github.tools.sap/cap/docs/guides/messaging/s4#configure-cap
Therefore I have my strong doubts the code is sitting on the right funcationality. @David-Kunz , can you help @Dipto-at-sap on how event consumption must be configured for a CAP app?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we have corrected this |
I did a small example with srv/external/myRemote.cds service myRemote {
event Foo { key ID: UUID };
} package.json contains {
"cds": {
"requires": {
"myRemote": {
"kind": "odata",
"model": "srv/external/myRemote.cds",
"credentials": {
"url": "http://www.foo.com"
}
}
}
} in custom code during bootstrapping: const ext = await cds.connect.to('myRemote') The problem is that the remote service definitions are not part of app.get("/open-resource-discovery/v1/documents/1", async (req, res) => {
/* ... */
const csn = await cds.load(cds.env.folders.srv); // <-- doesn't include myRemote I think you assume that the external model is loaded within the own model ( Note: Since |
@@ -58,6 +58,7 @@ module.exports = { | |||
return [ | |||
createPackage(name, "-api:v1"), | |||
createPackage(name, "-event:v1"), | |||
createPackage(name,"-integration-dependency:v1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please us the constants defined above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@swennemers let me know which constant you're referring to. Here, I'm creating another package for integration dependency and defined the constant in the lib/constants.js, just similar to what was there for event and api.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see my comments addressed.
@swennemers for David's comment, currently we're assuming that the services will be given in package.json only and we'll set up a call for further discussion to address that. For now trying to get the other comments here resolved. |
JIRA: https://jira.tools.sap/browse/CDSADAPTERS-2187
Github issue: #81