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
Open
1 change: 1 addition & 0 deletions __tests__/__snapshots__/noOrdInCdsrc.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ exports[`Tests for ORD document when .cdsrc.json has no \`ord\` property Success
"title": "This is test Cinema Service title",
},
],
"integrationDependencies": [],
"openResourceDiscovery": "1.9",
"packages": [
{
Expand Down
37 changes: 37 additions & 0 deletions __tests__/__snapshots__/ordCdsrc.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,32 @@ exports[`Tests for default ORD document when .cdsrc.json is present Successfully
"title": "This is test Cinema Service title",
},
],
"integrationDependencies": [
{
"aspects": [
{
"eventResources": [
{
"ordId": "sap.test.cdsrc.sample:eventResource:sap.s4.beh.businesspartner.v1.BusinessPartner:v1",
"subset": [
{
"eventType": "sap.s4.beh.businesspartner.v1.BusinessPartner.Created.v1",
},
],
},
],
},
],
"lastUpdate": "2024-11-04T14:33:25+01:00",
"mandatory": true,
"ordId": "sap.test.cdsrc.sample:integrationDependency:sap.s4.beh.businesspartner.v1.BusinessPartner:v1",
"partOfPackage": "sap.test.cdsrc.sample:package:capirebookshopordsample-api:v1",
"releaseStatus": "active",
"title": "Integration Dependency sample title",
"version": "1.0.0",
"visibility": "public",
},
],
"openResourceDiscovery": "1.10",
"packages": [
{
Expand All @@ -169,6 +195,17 @@ exports[`Tests for default ORD document when .cdsrc.json is present Successfully
"vendor": "customer:vendor:Customer:",
"version": "1.0.1",
},
{
"description": "Description for capire bookshop ord sample",
"ordId": "sap.test.cdsrc.sample:package:capirebookshopordsample-integration-dependency:v1",
"partOfProducts": [
"customer:product:capire.bookshop.ord.sample:",
],
"shortDescription": "Short description for capire bookshop ord sample",
"title": "capire bookshop ord sample",
"vendor": "customer:vendor:Customer:",
"version": "1.0.0",
},
{
"description": "Description for capire bookshop ord sample version 2",
"ordId": "sap.test.cdsrc.sample:package:capirebookshopordsample-api:v2",
Expand Down
26 changes: 26 additions & 0 deletions __tests__/__snapshots__/ordPackageJson.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,32 @@ exports[`Tests for default ORD document when .cdsrc.json is not present Successf
"title": "This is test Cinema Service title",
},
],
"integrationDependencies": [
{
"aspects": [
{
"eventResources": [
{
"ordId": "customer.capirebookshopordsample:eventResource:sap.s4.beh.businesspartner.v1.BusinessPartner:v1",
"subset": [
{
"eventType": "sap.s4.beh.businesspartner.v1.BusinessPartner.Created.v1",
},
],
},
],
},
],
"lastUpdate": "2024-11-04T14:33:25+01:00",
"mandatory": true,
"ordId": "customer.capirebookshopordsample:integrationDependency:sap.s4.beh.businesspartner.v1.BusinessPartner:v1",
"partOfPackage": "customer.capirebookshopordsample:package:capirebookshopordsample:v1",
"releaseStatus": "active",
"title": "Integration Dependency sample title",
"version": "1.0.0",
"visibility": "public",
},
],
"openResourceDiscovery": "1.9",
"packages": [
{
Expand Down
26 changes: 26 additions & 0 deletions __tests__/bookshop/ord/custom.ord.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,31 @@
"sap.sm:entityType:BusinessPartner:v1"
]
}
],
"integrationDependencies": [
{
"ordId": "sap.test.cdsrc.sample:integrationDependency:sap.s4.beh.businesspartner.v1.BusinessPartner:v1",
"title": "Integration Dependency sample title",
"mandatory": true,
"partOfPackage": "sap.test.cdsrc.sample:package:capirebookshopordsample-api:v1",
"lastUpdate": "2024-11-04T14:33:25+01:00",
"releaseStatus": "active",
"version": "1.0.0",
"visibility": "public",
"aspects": [
{
"eventResources": [
{
"ordId": "sap.test.cdsrc.sample:eventResource:sap.s4.beh.businesspartner.v1.BusinessPartner:v1",
"subset": [
{
"eventType": "sap.s4.beh.businesspartner.v1.BusinessPartner.Created.v1"
}
]
}
]
}
]
}
]
}
8 changes: 8 additions & 0 deletions __tests__/bookshop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,13 @@
},
"scripts": {
"start": "cds-serve"
},
"cds": {
"requires": {
"sap.s4.beh.businesspartner.v1.BusinessPartner": {
"kind": "odata",
"model": "srv/external/CE_BUSINESSPARTNEREVENTS.asyncapi"
}
}
Comment on lines +19 to +25
Copy link
Member

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.

}
}
3 changes: 3 additions & 0 deletions __tests__/bookshop/srv/admin-service.cds
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using {sap.capire.bookshop as my} from '../db/schema';
using {sap.s4.beh.businesspartner.v1.BusinessPartner.Created.v1 as Created } from './external/CE_BUSINESSPARTNEREVENTS.asyncapi';

service AdminService @(requires: 'authenticated-user') {
entity Books as projection on my.Books;
Expand All @@ -17,6 +18,8 @@ service AdminService @(requires: 'authenticated-user') {
ID : Integer;
title : String @title: 'Title';
}

event BPCreated : projection on Created;

function sum(x : Integer, y : Integer) returns Integer;
action add(x : Integer, to : Integer) returns Integer;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* checksum : 7c2129da2e89fec3fefa1cfb12090b2c */
@cds.external : 'true'
@AsyncAPI.Extensions : {
![sap-catalog-spec-version]: '1.0',
![sap-api-type]: 'EVENT'
}
@AsyncAPI.ShortText : 'Informs a remote system about created and changed business partners in an SAP S/4HANA Cloud tenant.'
@AsyncAPI.StateInfo : { state: 'ACTIVE' }
@AsyncAPI.Title : 'Business Partner Events'
@AsyncAPI.SchemaVersion : '1.0.0'
@AsyncAPI.Description : ```
A business partner is an organization (company, subsidiary), person or group of people or organizations in which your company has a business interest. The following events are available for business partner:\r
\r
* Business partner changed\r
* Business partner created
```
service sap.s4.beh.businesspartner.v1.BusinessPartner {};

@cds.external : 'true'
@topic : 'sap.s4.beh.businesspartner.v1.BusinessPartner.Changed.v1'
event sap.s4.beh.businesspartner.v1.BusinessPartner.Changed.v1 {
BusinessPartner : LargeString;
};

@cds.external : 'true'
@topic : 'sap.s4.beh.businesspartner.v1.BusinessPartner.Created.v1'
event sap.s4.beh.businesspartner.v1.BusinessPartner.Created.v1 {
BusinessPartner : LargeString;
Dipto-at-sap marked this conversation as resolved.
Show resolved Hide resolved
};

162 changes: 162 additions & 0 deletions __tests__/bookshop/srv/external/CE_BUSINESSPARTNEREVENTS.asyncapi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
{
"asyncapi": "2.0.0",
"x-sap-catalog-spec-version": "1.0",
"info": {
"title": "Business Partner Events",
"version": "1.0.0",
"description": "A business partner is an organization (company, subsidiary), person or group of people or organizations in which your company has a business interest. The following events are available for business partner:\r\n\r\n* Business partner changed\r\n* Business partner created"
},
"x-sap-api-type": "EVENT",
"x-sap-shortText": "Informs a remote system about created and changed business partners in an SAP S/4HANA Cloud tenant.",
"x-sap-stateInfo": {
"state": "ACTIVE"
},
"channels": {
"ce/sap/s4/beh/businesspartner/v1/BusinessPartner/Changed/v1": {
"subscribe": {
"message": {
"$ref": "#/components/messages/sap_s4_beh_businesspartner_v1_BusinessPartner_Changed_v1"
}
}
},
"ce/sap/s4/beh/businesspartner/v1/BusinessPartner/Created/v1": {
"subscribe": {
"message": {
"$ref": "#/components/messages/sap_s4_beh_businesspartner_v1_BusinessPartner_Created_v1"
}
}
}
},
"components": {
"messages": {
"sap_s4_beh_businesspartner_v1_BusinessPartner_Changed_v1": {
"name": "sap.s4.beh.businesspartner.v1.BusinessPartner.Changed.v1",
"summary": "BusinessPartner Changed",
"description": "This event is raised when Business Partner is changed.",
"headers": {
"properties": {
"type": {
"const": "sap.s4.beh.businesspartner.v1.BusinessPartner.Changed.v1"
},
"datacontenttype": {
"const": "application/json"
}
}
},
"payload": {
"$ref": "#/components/schemas/sap_s4_beh_businesspartner_v1_BusinessPartner_Changed_v1"
},
"traits": [
{
"$ref": "#/components/messageTraits/CloudEventContext"
}
]
},
"sap_s4_beh_businesspartner_v1_BusinessPartner_Created_v1": {
"name": "sap.s4.beh.businesspartner.v1.BusinessPartner.Created.v1",
"summary": "BusinessPartner Created",
"description": "This event is raised when Business Partner is created.",
"headers": {
"properties": {
"type": {
"const": "sap.s4.beh.businesspartner.v1.BusinessPartner.Created.v1"
},
"datacontenttype": {
"const": "application/json"
}
}
},
"payload": {
"$ref": "#/components/schemas/sap_s4_beh_businesspartner_v1_BusinessPartner_Created_v1"
},
"traits": [
{
"$ref": "#/components/messageTraits/CloudEventContext"
}
]
}
},
"schemas": {
"sap_s4_beh_businesspartner_v1_BusinessPartner_Changed_v1": {
"type": "object",
"properties": {
"BusinessPartner": {
"description": "# Definition\r\n\r\nKey identifying a **business partner** in the SAP system. The key is unique within a client.",
"type": "string",
"maxLength": 10
}
}
},
"sap_s4_beh_businesspartner_v1_BusinessPartner_Created_v1": {
"type": "object",
"properties": {
"BusinessPartner": {
"description": "# Definition\r\n\r\nKey identifying a **business partner** in the SAP system. The key is unique within a client.",
"type": "string",
"maxLength": 10
}
}
}
},
"messageTraits": {
"CloudEventContext": {
"headers": {
"type": "object",
"properties": {
"specversion": {
"description": "The version of the CloudEvents specification which the event uses. This enables the interpretation of the context.",
"type": "string",
"const": "1.0"
},
"type": {
"description": "Type of occurrence which has happened. Often this property is used for routing, observability, policy enforcement, etc.",
"type": "string",
"minLength": 1
},
"source": {
"description": "This describes the event producer.",
"type": "string",
"format": "uri-reference"
},
"subject": {
"description": "The subject of the event in the context of the event producer (identified by source).",
"type": "string",
"minLength": 1
},
"id": {
"description": "ID of the event.",
"type": "string",
"minLength": 1,
"examples": [
"6925d08e-bc19-4ad7-902e-bd29721cc69b"
]
},
"time": {
"description": "Timestamp of when the occurrence happened. Must adhere to RFC 3339.",
"type": "string",
"format": "date-time",
"examples": [
"2018-04-05T17:31:00Z"
]
},
"datacontenttype": {
"description": "Describe the data encoding format",
"type": "string",
"const": "application/json"
}
},
"required": [
"id",
"specversion",
"source",
"type"
]
}
}
}
},
"externalDocs": {
"description": "Business Documentation",
"url": "https://help.sap.com/http.svc/ahp2/SAP_S4HANA_CLOUD/2408.latest/EN/a7/5345282ddd4054a1e5ce7687e4b088/frameset.htm"
}
}
Loading