Skip to content

capire/xflights

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

@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: One to maintain the master data from UIs or remote systems, and one to consume it from remote applications, as shown below:

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:

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

License

Copyright (c) 2022 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.

About

Master data service for flights, airlines, airports

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages