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

[CDSADAPTERS-2187]: Added integration dependency for cds import for events #94

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

Dipto-at-sap
Copy link

Copy link
Contributor

@swennemers swennemers left a 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

@RoshniNaveenaS RoshniNaveenaS marked this pull request as draft November 14, 2024 08:50
@Dipto-at-sap Dipto-at-sap marked this pull request as ready for review November 19, 2024 09:04
@Dipto-at-sap Dipto-at-sap requested a review from Fannon November 25, 2024 08:26
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) {
Copy link
Contributor

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?

Copy link
Author

@Dipto-at-sap Dipto-at-sap Nov 28, 2024

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?

Consider the following case:
custom.ord.json
Screenshot 2024-11-28 at 1 55 23 PM

package.json
Screenshot 2024-11-28 at 1 56 46 PM

This is what I'm getting:
Screenshot 2024-11-28 at 1 59 53 PM

Copy link
Contributor

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.

Copy link
Author

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 {
Copy link
Contributor

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)

Copy link
Author

@Dipto-at-sap Dipto-at-sap Dec 3, 2024

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.

lib/templates.js Outdated Show resolved Hide resolved
lib/templates.js Outdated Show resolved Hide resolved
@zongqichen zongqichen linked an issue Nov 25, 2024 that may be closed by this pull request
lib/ord.js Outdated Show resolved Hide resolved
lib/ord.js Outdated Show resolved Hide resolved
Comment on lines +19 to +25
"cds": {
"requires": {
"sap.s4.beh.businesspartner.v1.BusinessPartner": {
"kind": "odata",
"model": "srv/external/CE_BUSINESSPARTNEREVENTS.asyncapi"
}
}
Copy link
Contributor

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?

Copy link
Contributor

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...

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.

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...

Copy link
Contributor

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

Copy link
Author

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.

Copy link
Contributor

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?

Copy link
Author

@Dipto-at-sap Dipto-at-sap Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the requirement:
Screenshot 2024-12-03 at 2 41 17 PM

And for that issue, let me know if we're missing out on anything.

lib/ord.js Outdated Show resolved Hide resolved
lib/ord.js Outdated Show resolved Hide resolved
lib/templates.js Outdated Show resolved Hide resolved
lib/templates.js Outdated Show resolved Hide resolved
@RoshniNaveenaS
Copy link
Contributor

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

Yeah we have corrected this

lib/templates.js Show resolved Hide resolved
lib/templates.js Outdated Show resolved Hide resolved
@David-Kunz
Copy link

David-Kunz commented Nov 28, 2024

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 (using {...} from './external/myRemote.cds'), which is not always the case.

Note: cds.model would include it, shouldn't this be used, also for performance reasons? In mtx scenarios, it should be the customer's model.

Since csn doesn't include the remote definitions (incl. events), integrationDependencies is empty.

@@ -58,6 +58,7 @@ module.exports = {
return [
createPackage(name, "-api:v1"),
createPackage(name, "-event:v1"),
createPackage(name,"-integration-dependency:v1")
Copy link
Contributor

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

Copy link
Author

@Dipto-at-sap Dipto-at-sap Dec 3, 2024

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.

Copy link
Contributor

@swennemers swennemers left a 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.

@Dipto-at-sap
Copy link
Author

Dipto-at-sap commented Dec 3, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ORD and integration dependencies (consumed events)
7 participants