SampleSampletypeA worked example you read or clone. Evidence: it demonstrates, it never provides.See every one →What this type is →by SAPby SAPoriginPublished by SAP itself. A visible facet, never an input to a reading — a dormant official plugin reads exactly like a dormant independent one.See every one →Reference

xflights

A reuse package serving master-data entities (Airlines, Airports and Flights) as a service that other CAP applications compose into their own data model.

Two service interfaces split maintenance from consumption: an admin service to maintain the data from a UI or a remote system, and a data service that denormalises Flights together with its FlightConnections for consuming apps. cds export turns the data service into a standalone client package, @capire/xflights-data, published to GitHub Packages so other applications, such as xtravels, import and mix its entities into their own schema instead of redefining them. An npm workspace setup lets the same package be linked locally during development, ahead of any publish.

Facts

Last pushLicenceApache-2.0

Where it sits

Lives in
Demonstrates
Data modellingCAPData modellingcapabilityDefining the shape of data before anything serves it: entities and their types, how they relate, and the projections and views that services and applications consume.Service integrationCAPService integrationcapabilityUsing a service that runs somewhere else as if it were one of your own: its API imported into the model, a proxy that turns a local query into the remote protocol, and a mock that stands in for it on a laptop. Distinct from [destinations](capability:destinations), which is how the address and the credentials are found, and from [replication](capability:replication), which is holding the data locally.

Who is behind it

Capire Docs & SamplesCapire Docs & SamplesOrganisationMaintains this
In the atlas: maintains 20, wrote 1
@capire
maintainerJohannes VogtPersonContributes to this
In the atlas: maintains 1, contributes to 28, wrote 10
@Akatuoro
Bob den OsPersonContributes to this
In the atlas: contributes to 13
@BobdenOs
Christian GeorgiPersonContributes to this
In the atlas: maintains 1, contributes to 53
@chgeo
Daniel HutzelPersonContributes to this
In the atlas: contributes to 32, wrote 3
@danjoa
DJ AdamsPersonContributes to this
Developer Advocate
In the atlas: contributes to 20, wrote 22
@qmacro
Nick JosipovicPersonContributes to this
In the atlas: contributes to 4, wrote 1
@nkaputnik
René JeglinskyPersonContributes to this
In the atlas: contributes to 20
@renejeglinsky
sjvansPersonContributes to this
In the atlas: contributes to 45
@sjvans
Steffen WeinstockPersonContributes to this
In the atlas: contributes to 14
@stewsk
Steffen WaldmannPersonContributes to this
In the atlas: contributes to 25
@swaldmann
10 contributors

What it declares

Every artifact

Type
Sample
Origin
By SAP
Use as
A reference

As a sample

Form
A reference application

Connections2

Learn more1

Readings
  1. CAP-level Data FederationSAP Developers, YouTube — SAP Developers playlists

README

quoted from capire/xflights under Apache-2.0, read
capire/xflights/readme.mdOn GitHub

@capire/xflights

This is a reuse package to manage and serve master data like Airlines, Airports, and Flights. It publishes a pre-built client package, that is used in the xtravels application.

Table of Contents

Domain Model

The domain model is defined in db/schema.cds. It centers around normalized FlightConnections, which connect two Airports operated by an Airline, while entity Flights represents scheduled flights on specific dates with a specific aircraft and price.

Service Interfaces

Two service interfaces are defined in srv/admin-service.cds, and srv/data-service.cds, to serve different use cases as shown below:

  • an admin service to maintain the master data from UIs or remote systems
  • a data service to consume it from remote applications

[!tip]

Serving denormalized views The data service exposes a denormalized view of `Flights` and associated `FlightConnections` data, essentially declared like that:
entity Flights as projection on my.Flights {
  *,          // all elements from Flights
  flight.*,   // all elements from FlightConnections
}

With that consumers aren't bothered with normalized data but can just consume flat data, looking like that:

Exporting APIs

Given the respective service definition, we create a pre-built client package for the data API, which can be used from consuming apps in a plug-and-play fashion.

We use cds export to create the API package, based on the Data Service definition:

cds export srv/data-service.cds

This generates a separate CAP reuse package within subfolder apis/data-service that contains only the effective service API definitions, accompanied by automatically derived test data and i18n bundles.

Initially, cds export also adds a package.json, which we can modify as appropriate, and did so by changing the package name to @capire/xflights-data:

{
- "name": "@capire/xflights-data-service",
+ "name": "@capire/xflights-data",
  ...
}

Publishing APIs

We can finally share this package with consuming applications using standard ways, like npm publish:

cd apis/data-service
npm publish

[!tip]

Using GitHub Packages

Within the capire org, we're publishing to GitHub Packages, which requires you to npm login once like that:

npm login --scope=@capire --registry=https://npm.pkg.github.com

As password you're using a Personal Access Token (classic) with read:packages scope (for retrieving and installing a package). Read more about that in Authenticating to GitHub Packages.

Consuming APIs

Use the published client package in your consuming application by installing it via npm:

npm add @capire/xflights-data

With that, we can use the imported models as usual, and as if they were local in mashups with our own entities like so:

using { sap.capire.flights.FlightsService as imported } from '@capire/xflights-data';
entity TravelBookings { //...
  flight : Association to imported.Flights;
}

▷ Learn more about consuming APIs and CAP-level data integration in the xtravels application.

Using Workspaces

Instead of exercising a workflow like that again and again:

  • ( develop → export → publish ) → npmjs.com → ( update → consume )

... we can use npm workspaces technique to work locally and speed up things as follows:

mkdir -p cap/works; cd cap/works
git clone https://github.com/capire/xflights
git clone https://github.com/capire/xtravels
echo '{"workspaces":["xflights","xtravels"]}' > package.json

Add a link to the local @capire/xflights-data API package, enclosed with the cloned xflights sources:

npm add ./xflights/apis/data-service

Check the installation using npm ls, which would yield output as below, showing that @capire/xtravel's dependency to @capire/xflights-data is nicely fulfilled by a local link to ./xflights/apis/data-service:

npm ls @capire/xflights-data
works@ ~/cap/works
├── @capire/xflights-data@0.1.11 -> ./xflights/apis/data-service
└─┬ @capire/xtravels@1.0.0 -> ./xtravels
  └── @capire/xflights-data@0.1.11 deduped -> ./xflights/apis/data-service

Start the xtravels application → and note the sources loaded from ./xflights/apis/data-service, and the information further below about the FlightsService service mocked automatically:

cds watch xtravels
[cds] - loaded model from 20 file(s):

  xtravels/srv/travel-service.cds
  xtravels/db/schema.cds
  xtravels/db/xflights.cds
  xflights/apis/data-service/index.cds
  xflights/apis/data-service/services.csn
  ...
[cds] - mocking sap.capire.flights.FlightsService {
  at: [ '/odata/v4/data', '/rest/data', '/hcql/data' ],
  decl: 'xflights/apis/data-service/services.csn:3',
}

Using Proxy Packages

The usage of npm workspaces technique as described above streamlined our workflows as follows:

  • Before: ( develop → export → publish ) → npmjs.com → ( update → consume )
  • After: ( develop → export ) → ( consume )

We can even more streamline that by eliminating the export step as follows...

Create a new subfolder xflights-api-shortcut in which we add two files as follows:

mkdir xflights-api-shortcut

Add a package.json file in there with that content:

{
  "name": "@capire/xflights-data",
  "dependencies": {
    "@capire/xflights": "*"
  }
}

And an index.cds file with that content:

using from '@capire/xflights/srv/data-service';
Using the shell's "here document" technique

You can also create those two files from the command line as follows:

cat > xflights-api-shortcut/package.json << EOF
{
  "name": "@capire/xflights-data",
  "dependencies": {
    "@capire/xflights": "*"
  }
}
EOF

Take the same approach for the index.cds file:

cat > xflights-api-shortcut/index.cds << EOF
using from '@capire/xflights/srv/data-service';
EOF
With that in place, change our API package dependency in the workspace root as follows:
npm add ./xflights-api-shortcut

Check the effect of that → note how @capire/xflights-data dependencies now link to ./xflights-api-shortcut:

npm ls @capire/xflights-data
works@ ~/cap/works
├── @capire/xflights-data@ -> ./xflights-api-shortcut
└─┬ @capire/xtravels@1.0.0 -> ./xtravels
  └── @capire/xflights-data@ deduped -> ./xflights-api-shortcut≤

Start the xtravels application → and note the sources loaded from ./xflights-api-shortcut, and the information further below about the FlightsService service now being served, not mocked anymore:

cds watch xtravels
[cds] - loaded model from 20 file(s):

  xtravels/srv/travel-service.cds
  xtravels/db/schema.cds
  xtravels/db/xflights.cds
  xflights-api-shortcut/index.cds
  xflights/srv/data-service.cds
  xflights/db/schema.cds
  ...
[cds] - serving sap.capire.flights.FlightsService {
  at: [ '/odata/v4/data', '/rest/data', '/hcql/data' ],
  decl: 'xflights/apis/data-service/services.csn:3',
}

Which means we've streamlined our workflows as follows:

  • Before: ( change → export → publish ) → npmjs.com → ( update → consume )
  • Step 1: ( change → export ) → ( consume )
  • Step 2: ( change ) → ( consume )

License

Copyright (c) 2026 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, version 2.0 except as noted otherwise in the LICENSE file.

Apache-2.0, read

Details

Sources3
Added by handdiscovered herechecked
github.com/capire/xflightstree, pushes, contributors, CIchecked
readme.mdquoted, and what the entry declareschecked

Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.

Compatibility and provenance
discovered viaAdded by hand
first seen in the atlas
ecosystem and domaincap, data-and-persistence
Contributors10
History in the atlas1
  1. First seen.
For your agent
Ref
artifact:capire-xflights
JSON
/artifacts/capire-xflights.json
MCP
Connecting an agent