Skip to content

Auto-generate IntegrationDependencies for consumed Data Products #343

@zongqichen

Description

@zongqichen

Background

When CAP applications consume external Data Products via cds import, the ORD plugin should be able to automatically generate integrationDependencies in the ORD document.

Implementation

  • Detect external Data Products by checking @cds.external, @data.product, and @cds.dp.ordId annotations
  • Parse @cds.dp.ordId to extract namespace, resourceType, and version
  • Group resources by namespace to create one IntegrationDependency per external Data Product

Open Questions

  • Event handling: Currently no DP example with events. Proposal: DP provider should annotate event services with @cds.dp.ordId (e.g., sap.sai:eventResource:SupplierEvents:v1), and we parse resourceType from ordId to place it in the correct aspect.
  • Customization: How to allow users to customize IntegrationDependency fields (e.g., mandatory)? Proposal: Create a new annotation key (e.g., @ORD.IntegrationDependency) that users can apply to the external DP service.
  • localId: How to derive localId from namespace? Current approach: sap.saisapsai
  • ordId format: Proposal: Use DP namespace as resourceName, e.g., <appNamespace>:integrationDependency:<dpNamespace>:v1customer.sample:integrationDependency:sap.sai:v1
  • Aspects handling: Per ORD spec, aspects support (1) alternative APIs, (2) event subscriptions, (3) callback APIs. Proposal:
    • Simple case: Group by resourceType - APIs in one aspect, Events in another
    • Complex case (callback/alternatives): Require manual configuration via annotations or custom.ord.json
    • DP provider can prepare aspect metadata, consumer can override via annotations

Example

1. DP Provider (sap-sai-supplier-v1/services.cds):

@cds.dp.ordId : 'sap.sai:apiResource:Supplier:v1'
@cds.external : true
@data.product : true
service sap.sai.Supplier.v1 {
  entity Supplier { key ID : String; name : String; }
}

@cds.dp.ordId : 'sap.sai:eventResource:SupplierEvents:v1'
@cds.external : true
@data.product : true
service sap.sai.SupplierEvents.v1 {
  event SupplierChanged { ID : String; }
}

2. Consumer (srv/services.cds):

using { sap.sai.Supplier.v1 as Supplier } from 'sap-sai-supplier-v1';
using { sap.sai.SupplierEvents.v1 as SupplierEvents } from 'sap-sai-supplier-v1';

service SupplierService {
  entity Suppliers as projection on Supplier.Supplier;
}

// Callback API for sap.sai to push data back
service SupplierCallbackService {
  action receiveSupplierUpdate(data: String);
}

annotate Supplier with @ORD.IntegrationDependency: {
  mandatory: false,
  aspects: [{
    title: 'Supplier Callback',
    apiResources: [{ ordId: 'customer.sample:apiResource:SupplierCallbackService:v1' }]
  }]
};

3. Generated ORD:

{
  "integrationDependencies": [{
    "ordId": "customer.sample:integrationDependency:sap.sai:v1",
    "title": "Integration with sap.sai",
    "mandatory": false,
    "aspects": [
      {
        "title": "sap.sai APIs",
        "apiResources": [{ "ordId": "sap.sai:apiResource:Supplier:v1", "minVersion": "1.0.0" }]
      },
      {
        "title": "sap.sai Events",
        "eventResources": [{ "ordId": "sap.sai:eventResource:SupplierEvents:v1", "minVersion": "1.0.0" }]
      },
      {
        "title": "Supplier Callback",
        "apiResources": [{ "ordId": "customer.sample:apiResource:SupplierCallbackService:v1" }]
      }
    ]
  }]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions