Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/axios-1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
stewsk authored Nov 6, 2023
2 parents df27d08 + 1ff14d3 commit 3abcff1
Show file tree
Hide file tree
Showing 8 changed files with 380 additions and 152 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
# Welcome to cap/samples

Find here a collection of samples for the [SAP Cloud Application Programming Model](https://cap.cloud.sap) organized in a simplistic [monorepo setup](samples.md#all-in-one-monorepo). → See [**Overview** of contained samples](samples.md)
Find here a collection of samples for the [SAP Cloud Application Programming Model](https://cap.cloud.sap) organized in a simplistic [monorepo setup](samples.md#all-in-one-monorepo).

[See **Overview** of contained samples](samples.md):

![](etc/samples.drawio.svg)

![](https://github.com/SAP-samples/cloud-cap-samples/workflows/CI/badge.svg)
[![REUSE status](https://api.reuse.software/badge/github.com/SAP-samples/cloud-cap-samples)](https://api.reuse.software/info/github.com/SAP-samples/cloud-cap-samples)



### Preliminaries

1. Ensure you have the latest LTS version of Node.js installed (see [Getting Started](https://cap.cloud.sap/docs/get-started/))
Expand Down
22 changes: 11 additions & 11 deletions bookshop/db/schema.cds
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ using { Currency, managed, sap } from '@sap/cds/common';
namespace sap.capire.bookshop;

entity Books : managed {
key ID : Integer;
title : localized String(111) @mandatory ;
descr : localized String(1111);
author : Association to Authors @mandatory;
genre : Association to Genres;
stock : Integer;
price : Decimal;
key ID : Integer;
title : localized String(111) @mandatory;
descr : localized String(1111);
author : Association to Authors @mandatory;
genre : Association to Genres;
stock : Integer;
price : Decimal;
currency : Currency;
image : LargeBinary @Core.MediaType : 'image/png';
image : LargeBinary @Core.MediaType: 'image/png';
}

entity Authors : managed {
key ID : Integer;
name : String(111) @mandatory;
key ID : Integer;
name : String(111) @mandatory;
dateOfBirth : Date;
dateOfDeath : Date;
placeOfBirth : String;
placeOfDeath : String;
books : Association to many Books on books.author = $self;
books : Association to many Books on books.author = $self;
}

/** Hierarchically organized Code List for Genres */
Expand Down
4 changes: 2 additions & 2 deletions bookshop/srv/admin-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ module.exports = class AdminService extends cds.ApplicationService { init(){

/** Generate primary keys for target entity in request */
async function genid (req) {
const {ID} = await cds.tx(req).run (SELECT.one.from(req.target).columns('max(ID) as ID'))
req.data.ID = ID - ID % 100 + 100 + 1
const {id} = await SELECT.one.from(req.target).columns('max(ID) as id')
req.data.ID = id - id % 100 + 100 + 1
}
23 changes: 6 additions & 17 deletions bookstore/srv/mashup.cds
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,28 @@
// respective reuse packages and services
//

using { sap.capire.bookshop.Books } from '@capire/bookshop';

//
// Extend Books with access to Reviews and average ratings
//
using { sap.capire.bookshop.Books } from '@capire/bookshop';
using { ReviewsService.Reviews } from '@capire/reviews';
extend Books with {
reviews : Composition of many Reviews on reviews.subject = $self.ID;

@Common.Label : '{i18n>Rating}'
rating : Decimal;

@Common.Label : '{i18n>NumberOfReviews}'
numberOfReviews : Integer;
rating : type of Reviews:rating; // average rating
numberOfReviews : Integer @title : '{i18n>NumberOfReviews}';
}


//
// Extend Orders with Books as Products
//
using { sap.capire.orders.Orders } from '@capire/orders';
extend Orders with {
extend Items with {
book : Association to Books on product.ID = book.ID
}
extend Orders:Items with {
book : Association to Books on product.ID = book.ID
}


// Add orders fiori app (in case of embedded orders service)
// Ensure models from all imported packages are loaded
using from '@capire/orders/app/fiori';

// Add data browser
using from '@capire/data-viewer';

// Incorporate pre-build extensions from...
using from '@capire/common';
141 changes: 82 additions & 59 deletions etc/dark.drawio.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
116 changes: 58 additions & 58 deletions etc/incidents.drawio.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
216 changes: 212 additions & 4 deletions etc/samples.drawio.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions samples.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
The following list gives an overview of the samples provided in subdirectories.
Each sub directory essentially is an individual npm package arranged in an [all-in-one monorepo](#all-in-one-monorepo) umbrella setup.

![](etc/samples.drawio.svg)


## [@capire/hello-world](hello)

Expand Down

0 comments on commit 3abcff1

Please sign in to comment.