Compare commits

..

17 Commits

Author SHA1 Message Date
Johannes Vogt
a2c3e57e38 fixes 2025-03-24 10:12:40 +01:00
Johannes Vogt
d79fbde2de npm scripts and finalize 2025-03-21 17:24:07 +01:00
Johannes Vogt
a657be4adc misc 2025-03-21 17:22:25 +01:00
Johannes Vogt
d713b45596 misc - cap service module - with some interpretation 2025-03-21 17:13:37 +01:00
Johannes Vogt
e2901a9f60 misc - auth 2025-03-21 17:13:25 +01:00
Johannes Vogt
1646ab5e13 destination changes 2025-03-21 17:03:26 +01:00
Johannes Vogt
8332be13e1 cds add destination 2025-03-21 17:02:44 +01:00
Johannes Vogt
e22e1b0d12 messaging 2025-03-21 17:01:16 +01:00
Johannes Vogt
70d7e6ffea cds add enterprise-messaging 2025-03-21 16:54:37 +01:00
Johannes Vogt
89307140ad auth changes 2025-03-21 16:54:24 +01:00
Johannes Vogt
39335c8c9b cds add xsuaa --for production 2025-03-21 16:52:51 +01:00
Johannes Vogt
dca837e595 approuter changes 2025-03-21 16:52:23 +01:00
Johannes Vogt
7686931f56 cds add approuter 2025-03-21 16:41:07 +01:00
Johannes Vogt
e648b0072a database changes 2025-03-21 16:40:46 +01:00
Johannes Vogt
49ca54ca82 cds add hana --production 2025-03-21 16:33:12 +01:00
Johannes Vogt
24154725ba npm start script 2025-03-21 16:32:27 +01:00
Johannes Vogt
745698fe12 cds add mta 2025-03-21 16:30:17 +01:00
74 changed files with 2530 additions and 937 deletions

View File

@@ -1 +0,0 @@
../../../bookshop/app/vue

View File

@@ -1 +0,0 @@
../../../orders/app/orders

View File

@@ -1 +0,0 @@
../../../reviews/app/vue

3
.npmrc Normal file
View File

@@ -0,0 +1,3 @@
# Ensure we always use public packages, i.e. avoid using local registries from ~/.npmrc
@sap:registry=https://registry.npmjs.org/
registry=https://registry.npmjs.org/

117
.tours/db-native.tour Normal file
View File

@@ -0,0 +1,117 @@
{
"$schema": "https://aka.ms/codetour-schema",
"title": "Database Functions",
"steps": [
{
"title": "Introduction",
"description": "### Database Functions in CDS Models\n\nIn this tour, you'll learn how to add database-specific functions to CDS models in your application."
},
{
"file": "bookshop/db/schema.cds",
"description": "#### Basic Schema\n\nWe want to add two fields to the `Authors` entity, one for the author's age and one for the span of years that she or he lived.\n\nThese two fields can be computed out of the existing `dateOfBirth` and `dateOfDeath` fields.",
"selection": {
"start": {
"line": 19,
"character": 1
},
"end": {
"line": 21,
"character": 1
}
},
"title": "Base fields in Author"
},
{
"file": "bookshop/srv/admin-service.cds",
"description": "This is how the `Authors` entity gets exposed in an OData or REST service.\n\nIn the next step, you'll see how we extend this projection.",
"selection": {
"start": {
"line": 4,
"character": 1
},
"end": {
"line": 5,
"character": 1
}
},
"title": "Authors service"
},
{
"file": "fiori/db/sqlite/index.cds",
"description": "#### SQLite Implementation\n\nHere's the first implementation for SQLite. It computes the two fields `age` and `lifetime` through SQLite's [strftime](https://sqlite.org/lang_datefunc.html) function.\n\nThrough the [`extend projection`](https://cap.cloud.sap/docs/cds/cdl#extend-view) clause you can add additional fields to projection entities. These are deployed as database views, which is why we can integrate the database functions in the first place.\n",
"selection": {
"start": {
"line": 7,
"character": 1
},
"end": {
"line": 11,
"character": 1
}
},
"title": "SQLite implementation"
},
{
"file": "fiori/db/hana/index.cds",
"description": "#### SAP HANA Implementation\n\nThis is the second implementation for SAP HANA. It computes the same two fields `age` and `lifetime` through the [YEARS_BETWEEN](https://help.sap.com/viewer/7c78579ce9b14a669c1f3295b0d8ca16/Cloud/en-US/7c0d2c161ea34def86de3f5eadd6a0af.html) and [YEAR](https://help.sap.com/viewer/7c78579ce9b14a669c1f3295b0d8ca16/Cloud/en-US/20f5fac6751910148dabd3c6821f907d.html) functions of SAP HANA.\n\n#### File Layout and Code Structure\n\nNote the path of the `.cds` file we are in: it's in a subfolder of `db`, so that it's _not_ automatically picked up when we start the application. The same is true for the SQLite implementation: it's in a separate `db/sqlite/` folder as well. In the next step, you'll see how these files are loaded.\n\nAlso, we choose to implement all of that as an extension of the original bookshop here in the _fiori_ package. See the first [CAP Samples] code tour for more details on the different packages of this repository.",
"selection": {
"start": {
"line": 7,
"character": 1
},
"end": {
"line": 11,
"character": 1
}
},
"title": "SAP HANA implementation"
},
{
"file": "fiori/package.json",
"description": "#### Configuration\n\nThe `cds.requires` section in `package.json` is a place to configure which of the `db/sqlite` and `db/hana` folders are used for which database.\n\nWe use [Node.js profiles](https://cap.cloud.sap/docs/node.js/cds-env#profiles) to separate the configuration.\nIn the `development` profile, you can see that `db/sqlite` is set as the model, while the `db/hana` folder is configured in the `production` profile. `db-ext` is a pseudo datasource, its name doesn't matter.\n\nSee [`cds.resolve`](https://cap.cloud.sap/docs/node.js/cds-compile#cds-resolve) to learn more about how models are found.",
"selection": {
"start": {
"line": 41,
"character": 1
},
"end": {
"line": 48,
"character": 1
}
},
"title": "Configuration"
},
{
"file": "fiori/package.json",
"description": "#### Run with SQLite\n\nTo run with `development` and an in-memory SQLite database, you don't need to do anything special, because it's activated by default. Just run:\n\n>> cds watch fiori\n\nThen open [http://localhost:4004/admin/Authors](http://localhost:4004/admin/Authors) to see the two new fields.\n",
"line": 43,
"title": "Run with SQLite"
},
{
"file": "fiori/package.json",
"description": "#### Deploy the CDS Model to SAP HANA\n\nTo 'activate' SAP HANA through the `production` profile, you can use the global `--production` flag:\n\n>> cd fiori; cds deploy --to hana --production\n\n[Learn more about SAP HANA deployment](https://cap.cloud.sap/docs/guides/databases#get-hana)\n\n#### Run the Application\n\n>> cd fiori; cds watch --production\n\nThe service on [http://localhost:4004/admin/Authors](http://localhost:4004/admin/Authors) is the same as before, but this time the `Authors` entity is backed by a database view with an SAP HANA function.\n\n#### More\n\nIf you don't see data, you can add some in the next step.",
"line": 46,
"title": "Run with SAP HANA"
},
{
"file": "fiori/test/requests.http",
"description": "### Add More Data\n\nOptionally you can add some `Authors` data by clicking on the _Send Request_ link (provided by the [REST client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client) extension).",
"line": 72,
"selection": {
"start": {
"line": 67,
"character": 1
},
"end": {
"line": 73,
"character": 1
}
},
"title": "Add Data"
},
{
"title": "Wrap-up",
"description": "### Summary\n\nThat's it! You have seen: \n- How to integrate database-specific functions in a CDS model.\n- How to switch between the two implementations for SQLite and SAP HANA."
}
]
}

139
.tours/samples.tour Normal file
View File

@@ -0,0 +1,139 @@
{
"$schema": "https://aka.ms/codetour-schema",
"title": "CAP Samples",
"steps": [
{
"title": "Welcome",
"file": "README.md",
"description": "### Welcome to CAP Samples!\n\nThis tour leads you through a collection of samples for the [SAP Cloud Application Programming Model (CAP)](https://cap.cloud.sap).\nYou will learn which features of the programming model are demonstrated in which sample.\n\nLet's start!",
"line": 2,
"selection": {
"start": {
"line": 1,
"character": 1
},
"end": {
"line": 3,
"character": 108
}
}
},
{
"file": "hello/srv/world.cds",
"description": "### Hello World!\n\nThis is a simplistic [Hello World](https://cap.cloud.sap/docs/get-started/hello-world) service using [CDS](https://cap.cloud.sap/docs/cds/) and [cds.services](https://cap.cloud.sap/docs/node.js/api#services-api).",
"line": 2,
"selection": {
"start": {
"line": 1,
"character": 1
},
"end": {
"line": 4,
"character": 1
}
},
"title": "Hello World!"
},
{
"file": "bookshop/db/schema.cds",
"description": "### A Bookshop!\n\nIntroduces:\n- [Project Setup](https://cap.cloud.sap/docs/get-started/) and [Layouts](https://cap.cloud.sap/docs/get-started/projects)\n- [Domain Modeling](https://cap.cloud.sap/docs/guides/domain-models)\n- [Defining Services](https://cap.cloud.sap/docs/guides/providing-services)\n- [Generic Providers](https://cap.cloud.sap/docs/guides/generic-providers)\n- [Adding Custom Logic](https://cap.cloud.sap/docs/guides/service-impl)\n- [Using Databases](https://cap.cloud.sap/docs/guides/databases)\n",
"line": 1,
"selection": {
"start": {
"line": 1,
"character": 1
},
"end": {
"line": 32,
"character": 1
}
},
"title": "Bookshop"
},
{
"file": "common/index.cds",
"description": "### Extend and Reuse\n\nShowcases how to extend [@sap/cds/common](https://cap.cloud.sap/docs/cds/common) thereby covering:\n- Building [extension packages](https://cap.cloud.sap/docs/guides/domain-models#aspects-extensibility)\n- Providing [reuse packages](https://cap.cloud.sap/docs/get-started/projects#sharing-and-reusing-content)\n- [Verticalization](https://cap.cloud.sap/docs/cds/common#adapting-to-your-needs)\n- Using [Aspects](https://cap.cloud.sap/docs/cds/cdl#aspects)\n- Used in the [fiori app sample](#fiori)\n",
"line": 1,
"selection": {
"start": {
"line": 1,
"character": 1
},
"end": {
"line": 46,
"character": 1
}
},
"title": "Common"
},
{
"file": "orders/db/schema.cds",
"description": "### Orders - Compositions and Serving Documents\n\nA standalone orders management service, demonstrating:\n- Using [Compositions](https://cap.cloud.sap/docs/cds/cdl#compositions) in [Domain Models](https://cap.cloud.sap/docs/guides/domain-models), along with\n- [Serving deeply nested documents](https://cap.cloud.sap/docs/guides/generic-providers#serving-structured-data)\n",
"line": 1,
"selection": {
"start": {
"line": 1,
"character": 1
},
"end": {
"line": 27,
"character": 1
}
},
"title": "Orders"
},
{
"file": "reviews/db/schema.cds",
"description": "### Reviews - More Modularity\n\nShows how to implement a modular service to manage product reviews, including:\n- Consuming other services synchronously and asynchronously\n- Serving requests synchronously\n- Emitting events asynchronously\n- Grow as you go, with:\n- Mocking app services\n- Running service meshes\n- Late-cut Micro Services\n- As well as managed data, input validations, and authorization\n",
"line": 1,
"selection": {
"start": {
"line": 1,
"character": 1
},
"end": {
"line": 39,
"character": 1
}
},
"title": "Reviews"
},
{
"title": "Bookstore",
"description": "### Bookstore - Reuse and UI\n\n- A [composite app, reusing and combining](https://cap.cloud.sap/docs/guides/reuse-and-compose) these packages:\n - [@capire/bookshop](bookshop)\n - [@capire/reviews](reviews)\n - [@capire/orders](orders)\n - [@capire/common](common)\n- [The Vue.js app](bookshop/app/vue) imported from bookshop is served as well\n- [The Vue.js app](reviews/app/vue) imported from reviews is served as well\n- [The Fiori app](orders/app) imported from orders is served as well\n- [OpenAPI export + Swagger UI](https://cap.cloud.sap/docs/advanced/openapi)"
},
{
"file": "fiori/app/services.cds",
"description": "### Annotations for SAP Fiori Elements\n\nAdds an SAP Fiori elements application to bookstore, thereby introducing:\n- OData Annotations in `.cds` files\n- Support for Fiori Draft\n- Support for Value Helps\n- Serving SAP Fiori apps locally\n\nSee the [Serving Fiori UIs](https://cap.cloud.sap/docs/advanced/fiori) documentation for more information.",
"line": 1,
"selection": {
"start": {
"line": 1,
"character": 1
},
"end": {
"line": 13,
"character": 1
}
},
"title": "Fiori"
},
{
"file": "package.json",
"description": "### All-in-one Monorepo\n\nEach sample sub directory essentially is a standard npm package, some with standard npm dependencies to other samples. The root folder's [package.json](package.json) has local links to the sub folders, such that an `npm install` populates a local `node_modules` folder acts like a local npm registry to the individual sample packages.\n",
"selection": {
"start": {
"line": 8,
"character": 1
},
"end": {
"line": 16,
"character": 1
}
},
"title": "Packages"
}
],
"isPrimary": true,
"description": "Overview of CAP Samples for Node.js"
}

View File

@@ -9,6 +9,8 @@
"dbaeumer.vscode-eslint", "dbaeumer.vscode-eslint",
"mechatroner.rainbow-csv", "mechatroner.rainbow-csv",
"humao.rest-client", "humao.rest-client",
"sdras.night-owl",
"vsls-contrib.codetour"
], ],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace. // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": [ "unwantedRecommendations": [

10
.vscode/settings.json vendored
View File

@@ -1,8 +1,9 @@
{ {
"files.exclude": { "files.exclude": {
"**/node_modules": true, ".reuse/**": true,
"LICENSES": true, "**/.gitignore": true,
".reuse": true "**/.vscode": true,
"LICENSES/**": true
}, },
"debug.javascript.terminalOptions": { "debug.javascript.terminalOptions": {
"skipFiles": [ "skipFiles": [
@@ -12,6 +13,5 @@
"**/cds/lib/req/cds-context.js", "**/cds/lib/req/cds-context.js",
"**/odata-v4/okra/**" "**/odata-v4/okra/**"
] ]
}, }
"jest.jestCommandLine": "npx jest"
} }

69
README.md Normal file
View File

@@ -0,0 +1,69 @@
# 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):
![](etc/samples.drawio.svg)
![](https://github.com/SAP-samples/cloud-cap-samples/workflows/CI/badge.svg)
### Preliminaries
Ensure you have the latest LTS version of Node.js, [`@sap/cds-dk`](https://www.npmjs.com/package/@sap/cds-dk) installed globally, `git` and your IDE ready (see [Initial Setup](https://cap.cloud.sap/docs/get-started/#setup))
### Download
If you've [Git](https://git-scm.com/downloads) installed, clone this repo as shown below, otherwise [download as ZIP file](archive/main.zip).
```sh
git clone https://github.com/sap-samples/cloud-cap-samples samples
cd samples
```
### Setup
In the samples folder run:
```sh
npm ci
```
### Run
With that you're ready to run the samples, for example:
```sh
cds watch bookshop
```
After that open this link in your browser: [http://localhost:4004](http://localhost:4004)
When asked to log in, type `alice` as user and leave the password field blank, which is the [default user](https://cap.cloud.sap/docs/node.js/authentication#mocked).
### Testing
Run the provided tests with [_jest_](http://jestjs.io) or [_mocha_](http://mochajs.org), for example:
```sh
npx jest
```
> While mocha is a bit smaller and faster, jest runs tests in parallel and isolation, which allows to run all tests.
## Code Tours
Take one of the [guided tours](.tours) in VS Code through our CAP samples and learn which CAP features are showcased by the different parts of the repository. Just install the [CodeTour extension](https://marketplace.visualstudio.com/items?itemName=vsls-contrib.codetour) for VS Code. We'll add more code tours in the future. Stay tuned!
## Get Support
Check out the documentation at [https://cap.cloud.sap](https://cap.cloud.sap). <br>
In case you've a question, find a bug, or otherwise need support, use our [community](https://answers.sap.com/tags/9f13aee1-834c-4105-8e43-ee442775e5ce) to get more visibility.
## 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](LICENSE) file.

1
app/router/bookshop Symbolic link
View File

@@ -0,0 +1 @@
../../bookshop/app/vue

1
app/router/orders Symbolic link
View File

@@ -0,0 +1 @@
../../orders/app/orders

View File

@@ -6,7 +6,10 @@
"": { "": {
"name": "approuter", "name": "approuter",
"dependencies": { "dependencies": {
"@sap/approuter": "^20.0.0" "@sap/approuter": "^19.0.0"
},
"engines": {
"node": "^20"
} }
}, },
"node_modules/@colors/colors": { "node_modules/@colors/colors": {
@@ -25,18 +28,18 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/@sap/approuter": { "node_modules/@sap/approuter": {
"version": "20.0.0", "version": "19.0.4",
"resolved": "https://registry.npmjs.org/@sap/approuter/-/approuter-20.0.0.tgz", "resolved": "https://registry.npmjs.org/@sap/approuter/-/approuter-19.0.4.tgz",
"integrity": "sha512-rAeSkzyS605by327IonaBdbmhCC0GQeEmHavY52HAeCfQK75g+x2ACMC1buFxPP20i6O+OkERojZ6aM7Y9/8AQ==", "integrity": "sha512-rMOFwo+Ff1sBSQ4oRMUNwGqmF1WqCPWw8dEssnhj2GoGwTz4xkJ3bitVWfhsLQqLhLPdrH7wITUblLHdR/dbAg==",
"license": "SEE LICENSE IN LICENSE", "license": "SEE LICENSE IN LICENSE",
"dependencies": { "dependencies": {
"@sap/audit-logging": "6.4.0", "@sap/audit-logging": "6.4.0",
"@sap/e2e-trace": "5.3.0", "@sap/e2e-trace": "5.3.0",
"@sap/logging": "8.3.0", "@sap/logging": "8.3.0",
"@sap/xsenv": "5.4.0", "@sap/xsenv": "5.4.0",
"@sap/xssec": "4.4.0", "@sap/xssec": "3.6.1",
"agentkeepalive": "4.5.0", "agentkeepalive": "4.5.0",
"axios": "1.8.3", "axios": "1.8.2",
"axios-cookiejar-support": "5.0.5", "axios-cookiejar-support": "5.0.5",
"base64-url": "2.3.3", "base64-url": "2.3.3",
"basic-auth": "1.0.3", "basic-auth": "1.0.3",
@@ -84,15 +87,6 @@
"node": "^20.0.0 || ^22.0.0" "node": "^20.0.0 || ^22.0.0"
} }
}, },
"node_modules/@sap/approuter/node_modules/cookie": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-1.0.2.tgz",
"integrity": "sha512-9Kr/j4O16ISv8zBBhJoi4bXOYNTkFLOqSL3UDB0njXxCXNezjeyVrJyGOWtgfs/q2km1gwBcfH8q1yEGoMYunA==",
"license": "MIT",
"engines": {
"node": ">=18"
}
},
"node_modules/@sap/audit-logging": { "node_modules/@sap/audit-logging": {
"version": "6.4.0", "version": "6.4.0",
"resolved": "https://registry.npmjs.org/@sap/audit-logging/-/audit-logging-6.4.0.tgz", "resolved": "https://registry.npmjs.org/@sap/audit-logging/-/audit-logging-6.4.0.tgz",
@@ -110,21 +104,6 @@
"node": "^18.0.0 || ^20.0.0 || ^22.x" "node": "^18.0.0 || ^20.0.0 || ^22.x"
} }
}, },
"node_modules/@sap/audit-logging/node_modules/@sap/xssec": {
"version": "3.6.2",
"resolved": "https://registry.npmjs.org/@sap/xssec/-/xssec-3.6.2.tgz",
"integrity": "sha512-Wahh/YfCTnCoZ9wSElnvgDOYr4LxwWHFB6NsRA6UTsS+69ge6dIFAnQTCTuo1sLg1EPCJXwWOh3h9IA77ZwcPA==",
"license": "SAP DEVELOPER LICENSE AGREEMENT",
"dependencies": {
"axios": "^1.6",
"debug": "^4.3.4",
"jsonwebtoken": "^9.0.2",
"node-rsa": "^1.1.1"
},
"engines": {
"node": ">=14"
}
},
"node_modules/@sap/audit-logging/node_modules/debug": { "node_modules/@sap/audit-logging/node_modules/debug": {
"version": "4.3.5", "version": "4.3.5",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz",
@@ -239,16 +218,18 @@
} }
}, },
"node_modules/@sap/xssec": { "node_modules/@sap/xssec": {
"version": "4.4.0", "version": "3.6.1",
"resolved": "https://registry.npmjs.org/@sap/xssec/-/xssec-4.4.0.tgz", "resolved": "https://registry.npmjs.org/@sap/xssec/-/xssec-3.6.1.tgz",
"integrity": "sha512-tVPyF6z6lWN2cucT38kkTu6GTmFXhqd/xa0SrExZ+j8K1cNePEIDHvx/zfibubLeb198vyoreW4QOpR9+Vaj4A==", "integrity": "sha512-OJouwIWClefpsJ8rVCziEydeDHDNOMA4hjsjw9OqolbbObaiYMMDRU0YJbPe7XL5JkLgrtt+CLCBCsNERxcCZg==",
"license": "SAP DEVELOPER LICENSE AGREEMENT", "license": "SAP DEVELOPER LICENSE AGREEMENT",
"dependencies": { "dependencies": {
"axios": "^1.6",
"debug": "^4.3.4", "debug": "^4.3.4",
"jwt-decode": "^4" "jsonwebtoken": "^9.0.2",
"node-rsa": "^1.1.1"
}, },
"engines": { "engines": {
"node": ">=18" "node": ">=14"
} }
}, },
"node_modules/@sap/xssec/node_modules/debug": { "node_modules/@sap/xssec/node_modules/debug": {
@@ -268,15 +249,6 @@
} }
} }
}, },
"node_modules/@sap/xssec/node_modules/jwt-decode": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-4.0.0.tgz",
"integrity": "sha512-+KJGIyHgkGuIq3IEBNftfhW/LfWhXUIY6OmyVWjliu5KH1y0fw7VQ8YndE2O4qZdMSd9SqbnC8GOcZEy0Om7sA==",
"license": "MIT",
"engines": {
"node": ">=18"
}
},
"node_modules/@sap/xssec/node_modules/ms": { "node_modules/@sap/xssec/node_modules/ms": {
"version": "2.1.3", "version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
@@ -312,15 +284,12 @@
} }
}, },
"node_modules/agent-base": { "node_modules/agent-base": {
"version": "6.0.2", "version": "7.1.3",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.3.tgz",
"integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", "integrity": "sha512-jRR5wdylq8CkOe6hei19GGZnxM6rBGwFl3Bg0YItGDimvjGtAvdZk4Pu6Cl4u4Igsws4a1fd1Vq3ezrhn4KmFw==",
"license": "MIT", "license": "MIT",
"dependencies": {
"debug": "4"
},
"engines": { "engines": {
"node": ">= 6.0.0" "node": ">= 14"
} }
}, },
"node_modules/agentkeepalive": { "node_modules/agentkeepalive": {
@@ -376,9 +345,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/axios": { "node_modules/axios": {
"version": "1.8.3", "version": "1.8.2",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.8.3.tgz", "resolved": "https://registry.npmjs.org/axios/-/axios-1.8.2.tgz",
"integrity": "sha512-iP4DebzoNlP/YN2dpwCgb8zoCmhtkajzS48JvwmkSkXvPI3DHc7m+XYL5tGnSlJtR6nImXZmdCuN5aP8dh1d8A==", "integrity": "sha512-ls4GYBm5aig9vWx8AWDSGLpnpDQRtWAfrjU+EuytuODrFBkqesN2RkOQCBzrA1RQNHw1SmRMSDDDSwzNAYQ6Rg==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"follow-redirects": "^1.15.6", "follow-redirects": "^1.15.6",
@@ -672,12 +641,12 @@
} }
}, },
"node_modules/cookie": { "node_modules/cookie": {
"version": "0.7.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", "resolved": "https://registry.npmjs.org/cookie/-/cookie-1.0.2.tgz",
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", "integrity": "sha512-9Kr/j4O16ISv8zBBhJoi4bXOYNTkFLOqSL3UDB0njXxCXNezjeyVrJyGOWtgfs/q2km1gwBcfH8q1yEGoMYunA==",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": ">= 0.6" "node": ">=18"
} }
}, },
"node_modules/cookie-parser": { "node_modules/cookie-parser": {
@@ -693,6 +662,15 @@
"node": ">= 0.8.0" "node": ">= 0.8.0"
} }
}, },
"node_modules/cookie-parser/node_modules/cookie": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie-parser/node_modules/cookie-signature": { "node_modules/cookie-parser/node_modules/cookie-signature": {
"version": "1.0.6", "version": "1.0.6",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
@@ -909,6 +887,15 @@
"node": ">= 0.8.0" "node": ">= 0.8.0"
} }
}, },
"node_modules/express-session/node_modules/cookie": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/express-session/node_modules/cookie-signature": { "node_modules/express-session/node_modules/cookie-signature": {
"version": "1.0.7", "version": "1.0.7",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz", "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz",
@@ -1218,15 +1205,6 @@
} }
} }
}, },
"node_modules/http-cookie-agent/node_modules/agent-base": {
"version": "7.1.3",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.3.tgz",
"integrity": "sha512-jRR5wdylq8CkOe6hei19GGZnxM6rBGwFl3Bg0YItGDimvjGtAvdZk4Pu6Cl4u4Igsws4a1fd1Vq3ezrhn4KmFw==",
"license": "MIT",
"engines": {
"node": ">= 14"
}
},
"node_modules/http-errors": { "node_modules/http-errors": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
@@ -1275,6 +1253,18 @@
"node": ">= 6" "node": ">= 6"
} }
}, },
"node_modules/http-proxy-agent/node_modules/agent-base": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
"integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==",
"license": "MIT",
"dependencies": {
"debug": "4"
},
"engines": {
"node": ">= 6.0.0"
}
},
"node_modules/https-proxy-agent": { "node_modules/https-proxy-agent": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz",
@@ -1288,6 +1278,18 @@
"node": ">= 6" "node": ">= 6"
} }
}, },
"node_modules/https-proxy-agent/node_modules/agent-base": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
"integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==",
"license": "MIT",
"dependencies": {
"debug": "4"
},
"engines": {
"node": ">= 6.0.0"
}
},
"node_modules/humanize-ms": { "node_modules/humanize-ms": {
"version": "1.2.1", "version": "1.2.1",
"resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz",
@@ -1538,9 +1540,9 @@
} }
}, },
"node_modules/mime-db": { "node_modules/mime-db": {
"version": "1.53.0", "version": "1.54.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.53.0.tgz", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz",
"integrity": "sha512-oHlN/w+3MQ3rba9rqFr6V/ypF10LSkdwUysQL7GkXoTgIWeV+tcXGA852TBxH+gsh8UWoyhR1hKcoMJTuWflpg==", "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": ">= 0.6" "node": ">= 0.6"

View File

@@ -1,7 +1,10 @@
{ {
"name": "approuter", "name": "approuter",
"dependencies": { "dependencies": {
"@sap/approuter": "^20.0.0" "@sap/approuter": "^19.0.0"
},
"engines": {
"node": "^20"
}, },
"scripts": { "scripts": {
"start": "node node_modules/@sap/approuter/approuter.js" "start": "node node_modules/@sap/approuter/approuter.js"

1
app/router/reviews Symbolic link
View File

@@ -0,0 +1 @@
../../reviews/app/vue

View File

@@ -1,15 +1,15 @@
{ {
"welcomeFile": "app/bookshop/index.html", "welcomeFile": "app/bookshop/index.html",
"routes": [ "routes": [
{
"source": "^/-/cds/.*",
"destination": "mtx-api",
"authenticationType": "none"
},
{ {
"source": "^/app/(.*)$", "source": "^/app/(.*)$",
"target": "$1", "target": "$1",
"localDir": "resources", "localDir": ".",
"cacheControl": "no-cache, no-store, must-revalidate"
},
{
"source": "^/appconfig/",
"localDir": ".",
"cacheControl": "no-cache, no-store, must-revalidate" "cacheControl": "no-cache, no-store, must-revalidate"
}, },
{ {
@@ -41,6 +41,12 @@
"target": "/reviews/$1", "target": "/reviews/$1",
"destination": "reviews-api", "destination": "reviews-api",
"csrfProtection": true "csrfProtection": true
},
{
"source": "^(.*)$",
"target": "$1",
"localDir": ".",
"cacheControl": "no-cache, no-store, must-revalidate"
} }
] ]
} }

View File

@@ -3,7 +3,7 @@
<head> <head>
<title> Capire Books </title> <title> Capire Books </title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/primitive-ui/dist/css/main.css"> <link rel="stylesheet" href="https://unpkg.com/primitive-ui/dist/css/main.css">
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.prod.js"></script> <script src="https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.prod.js"></script>
<style> <style>

View File

@@ -1,6 +1,6 @@
ID,title,descr,author_ID,stock,price,currency_code,genre_ID ID,title,descr,author_ID,stock,price,currency_code,genre_ID
201,Wuthering Heights,"Wuthering Heights, Emily Brontë's only novel, was published in 1847 under the pseudonym ""Ellis Bell"". It was written between October 1845 and June 1846. Wuthering Heights and Anne Brontë's Agnes Grey were accepted by publisher Thomas Newby before the success of their sister Charlotte's novel Jane Eyre. After Emily's death, Charlotte edited the manuscript of Wuthering Heights and arranged for the edited version to be published as a posthumous second edition in 1850.",101,12,11.11,GBP,11aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 201,Wuthering Heights,"Wuthering Heights, Emily Brontë's only novel, was published in 1847 under the pseudonym ""Ellis Bell"". It was written between October 1845 and June 1846. Wuthering Heights and Anne Brontë's Agnes Grey were accepted by publisher Thomas Newby before the success of their sister Charlotte's novel Jane Eyre. After Emily's death, Charlotte edited the manuscript of Wuthering Heights and arranged for the edited version to be published as a posthumous second edition in 1850.",101,12,11.11,GBP,11
207,Jane Eyre,"Jane Eyre /ɛər/ (originally published as Jane Eyre: An Autobiography) is a novel by English writer Charlotte Brontë, published under the pen name ""Currer Bell"", on 16 October 1847, by Smith, Elder & Co. of London. The first American edition was published the following year by Harper & Brothers of New York. Primarily a bildungsroman, Jane Eyre follows the experiences of its eponymous heroine, including her growth to adulthood and her love for Mr. Rochester, the brooding master of Thornfield Hall. The novel revolutionised prose fiction in that the focus on Jane's moral and spiritual development is told through an intimate, first-person narrative, where actions and events are coloured by a psychological intensity. The book contains elements of social criticism, with a strong sense of Christian morality at its core and is considered by many to be ahead of its time because of Jane's individualistic character and how the novel approaches the topics of class, sexuality, religion and feminism.",107,11,12.34,GBP,11aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 207,Jane Eyre,"Jane Eyre /ɛər/ (originally published as Jane Eyre: An Autobiography) is a novel by English writer Charlotte Brontë, published under the pen name ""Currer Bell"", on 16 October 1847, by Smith, Elder & Co. of London. The first American edition was published the following year by Harper & Brothers of New York. Primarily a bildungsroman, Jane Eyre follows the experiences of its eponymous heroine, including her growth to adulthood and her love for Mr. Rochester, the brooding master of Thornfield Hall. The novel revolutionised prose fiction in that the focus on Jane's moral and spiritual development is told through an intimate, first-person narrative, where actions and events are coloured by a psychological intensity. The book contains elements of social criticism, with a strong sense of Christian morality at its core and is considered by many to be ahead of its time because of Jane's individualistic character and how the novel approaches the topics of class, sexuality, religion and feminism.",107,11,12.34,GBP,11
251,The Raven,"""The Raven"" is a narrative poem by American writer Edgar Allan Poe. First published in January 1845, the poem is often noted for its musicality, stylized language, and supernatural atmosphere. It tells of a talking raven's mysterious visit to a distraught lover, tracing the man's slow fall into madness. The lover, often identified as being a student, is lamenting the loss of his love, Lenore. Sitting on a bust of Pallas, the raven seems to further distress the protagonist with its constant repetition of the word ""Nevermore"". The poem makes use of folk, mythological, religious, and classical references.",150,333,13.13,USD,16aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 251,The Raven,"""The Raven"" is a narrative poem by American writer Edgar Allan Poe. First published in January 1845, the poem is often noted for its musicality, stylized language, and supernatural atmosphere. It tells of a talking raven's mysterious visit to a distraught lover, tracing the man's slow fall into madness. The lover, often identified as being a student, is lamenting the loss of his love, Lenore. Sitting on a bust of Pallas, the raven seems to further distress the protagonist with its constant repetition of the word ""Nevermore"". The poem makes use of folk, mythological, religious, and classical references.",150,333,13.13,USD,16
252,Eleonora,"""Eleonora"" is a short story by Edgar Allan Poe, first published in 1842 in Philadelphia in the literary annual The Gift. It is often regarded as somewhat autobiographical and has a relatively ""happy"" ending.",150,555,14,USD,15aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 252,Eleonora,"""Eleonora"" is a short story by Edgar Allan Poe, first published in 1842 in Philadelphia in the literary annual The Gift. It is often regarded as somewhat autobiographical and has a relatively ""happy"" ending.",150,555,14,USD,15
271,Catweazle,"Catweazle is a British fantasy television series, starring Geoffrey Bayldon in the title role, and created by Richard Carpenter for London Weekend Television. The first series, produced and directed by Quentin Lawrence, was screened in the UK on ITV in 1970. The second series, directed by David Reid and David Lane, was shown in 1971. Each series had thirteen episodes, most but not all written by Carpenter, who also published two books based on the scripts.",170,22,150,JPY,13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 271,Catweazle,"Catweazle is a British fantasy television series, starring Geoffrey Bayldon in the title role, and created by Richard Carpenter for London Weekend Television. The first series, produced and directed by Quentin Lawrence, was screened in the UK on ITV in 1970. The second series, directed by David Reid and David Lane, was shown in 1971. Each series had thirteen episodes, most but not all written by Carpenter, who also published two books based on the scripts.",170,22,150,JPY,13
1 ID title descr author_ID stock price currency_code genre_ID
2 201 Wuthering Heights Wuthering Heights, Emily Brontë's only novel, was published in 1847 under the pseudonym "Ellis Bell". It was written between October 1845 and June 1846. Wuthering Heights and Anne Brontë's Agnes Grey were accepted by publisher Thomas Newby before the success of their sister Charlotte's novel Jane Eyre. After Emily's death, Charlotte edited the manuscript of Wuthering Heights and arranged for the edited version to be published as a posthumous second edition in 1850. 101 12 11.11 GBP 11aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 11
3 207 Jane Eyre Jane Eyre /ɛər/ (originally published as Jane Eyre: An Autobiography) is a novel by English writer Charlotte Brontë, published under the pen name "Currer Bell", on 16 October 1847, by Smith, Elder & Co. of London. The first American edition was published the following year by Harper & Brothers of New York. Primarily a bildungsroman, Jane Eyre follows the experiences of its eponymous heroine, including her growth to adulthood and her love for Mr. Rochester, the brooding master of Thornfield Hall. The novel revolutionised prose fiction in that the focus on Jane's moral and spiritual development is told through an intimate, first-person narrative, where actions and events are coloured by a psychological intensity. The book contains elements of social criticism, with a strong sense of Christian morality at its core and is considered by many to be ahead of its time because of Jane's individualistic character and how the novel approaches the topics of class, sexuality, religion and feminism. 107 11 12.34 GBP 11aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 11
4 251 The Raven "The Raven" is a narrative poem by American writer Edgar Allan Poe. First published in January 1845, the poem is often noted for its musicality, stylized language, and supernatural atmosphere. It tells of a talking raven's mysterious visit to a distraught lover, tracing the man's slow fall into madness. The lover, often identified as being a student, is lamenting the loss of his love, Lenore. Sitting on a bust of Pallas, the raven seems to further distress the protagonist with its constant repetition of the word "Nevermore". The poem makes use of folk, mythological, religious, and classical references. 150 333 13.13 USD 16aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 16
5 252 Eleonora "Eleonora" is a short story by Edgar Allan Poe, first published in 1842 in Philadelphia in the literary annual The Gift. It is often regarded as somewhat autobiographical and has a relatively "happy" ending. 150 555 14 USD 15aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 15
6 271 Catweazle Catweazle is a British fantasy television series, starring Geoffrey Bayldon in the title role, and created by Richard Carpenter for London Weekend Television. The first series, produced and directed by Quentin Lawrence, was screened in the UK on ITV in 1970. The second series, directed by David Reid and David Lane, was shown in 1971. Each series had thirteen episodes, most but not all written by Carpenter, who also published two books based on the scripts. 170 22 150 JPY 13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 13

View File

@@ -1,5 +1,5 @@
ID_texts,ID,locale,title,descr ID,locale,title,descr
d2a65a27-9f2a-480f-bc38-84ee8ec5c13e,201,de,Sturmhöhe,"Sturmhöhe (Originaltitel: Wuthering Heights) ist der einzige Roman der englischen Schriftstellerin Emily Brontë (18181848). Der 1847 unter dem Pseudonym Ellis Bell veröffentlichte Roman wurde vom viktorianischen Publikum weitgehend abgelehnt, heute gilt er als ein Klassiker der britischen Romanliteratur des 19. Jahrhunderts." 201,de,Sturmhöhe,"Sturmhöhe (Originaltitel: Wuthering Heights) ist der einzige Roman der englischen Schriftstellerin Emily Brontë (18181848). Der 1847 unter dem Pseudonym Ellis Bell veröffentlichte Roman wurde vom viktorianischen Publikum weitgehend abgelehnt, heute gilt er als ein Klassiker der britischen Romanliteratur des 19. Jahrhunderts."
8c42c706-a979-41cf-9ffe-91e6cf1383a0,201,fr,Les Hauts de Hurlevent,"Les Hauts de Hurlevent (titre original : Wuthering Heights), parfois orthographié Les Hauts de Hurle-Vent, est l'unique roman d'Emily Brontë, publié pour la première fois en 1847 sous le pseudonyme dEllis Bell. Loin d'être un récit moralisateur, Emily Brontë achève néanmoins le roman dans une atmosphère sereine, suggérant le triomphe de la paix et du Bien sur la vengeance et le Mal." 201,fr,Les Hauts de Hurlevent,"Les Hauts de Hurlevent (titre original : Wuthering Heights), parfois orthographié Les Hauts de Hurle-Vent, est l'unique roman d'Emily Brontë, publié pour la première fois en 1847 sous le pseudonyme dEllis Bell. Loin d'être un récit moralisateur, Emily Brontë achève néanmoins le roman dans une atmosphère sereine, suggérant le triomphe de la paix et du Bien sur la vengeance et le Mal."
9e1c4c81-dc90-4600-85b1-e9dd4bf12ce0,207,de,Jane Eyre,"Jane Eyre. Eine Autobiographie (Originaltitel: Jane Eyre. An Autobiography), erstmals erschienen im Jahr 1847 unter dem Pseudonym Currer Bell, ist der erste veröffentlichte Roman der britischen Autorin Charlotte Brontë und ein Klassiker der viktorianischen Romanliteratur des 19. Jahrhunderts. Der Roman erzählt in Form einer Ich-Erzählung die Lebensgeschichte von Jane Eyre (ausgesprochen /ˌdʒeɪn ˈɛə/), die nach einer schweren Kindheit eine Stelle als Gouvernante annimmt und sich in ihren Arbeitgeber verliebt, jedoch immer wieder um ihre Freiheit und Selbstbestimmung kämpfen muss. Als klein, dünn, blass, stets schlicht dunkel gekleidet und mit strengem Mittelscheitel beschrieben, gilt die Heldin des Romans Jane Eyre nicht zuletzt aufgrund der Kino- und Fernsehversionen der melodramatischen Romanvorlage als die bekannteste englische Gouvernante der Literaturgeschichte" 207,de,Jane Eyre,"Jane Eyre. Eine Autobiographie (Originaltitel: Jane Eyre. An Autobiography), erstmals erschienen im Jahr 1847 unter dem Pseudonym Currer Bell, ist der erste veröffentlichte Roman der britischen Autorin Charlotte Brontë und ein Klassiker der viktorianischen Romanliteratur des 19. Jahrhunderts. Der Roman erzählt in Form einer Ich-Erzählung die Lebensgeschichte von Jane Eyre (ausgesprochen /ˌdʒeɪn ˈɛə/), die nach einer schweren Kindheit eine Stelle als Gouvernante annimmt und sich in ihren Arbeitgeber verliebt, jedoch immer wieder um ihre Freiheit und Selbstbestimmung kämpfen muss. Als klein, dünn, blass, stets schlicht dunkel gekleidet und mit strengem Mittelscheitel beschrieben, gilt die Heldin des Romans Jane Eyre nicht zuletzt aufgrund der Kino- und Fernsehversionen der melodramatischen Romanvorlage als die bekannteste englische Gouvernante der Literaturgeschichte"
9be0524b-4cb9-4fc1-9dc2-d65b1c13cf53,252,de,Eleonora,"“Eleonora” ist eine Erzählung von Edgar Allan Poe. Sie wurde 1841 erstveröffentlicht. In ihr geht es um das Paradox der Treue in der Treulosigkeit." 252,de,Eleonora,"“Eleonora” ist eine Erzählung von Edgar Allan Poe. Sie wurde 1841 erstveröffentlicht. In ihr geht es um das Paradox der Treue in der Treulosigkeit."
1 ID_texts ID locale title descr
2 d2a65a27-9f2a-480f-bc38-84ee8ec5c13e 201 de Sturmhöhe Sturmhöhe (Originaltitel: Wuthering Heights) ist der einzige Roman der englischen Schriftstellerin Emily Brontë (1818–1848). Der 1847 unter dem Pseudonym Ellis Bell veröffentlichte Roman wurde vom viktorianischen Publikum weitgehend abgelehnt, heute gilt er als ein Klassiker der britischen Romanliteratur des 19. Jahrhunderts.
3 8c42c706-a979-41cf-9ffe-91e6cf1383a0 201 fr Les Hauts de Hurlevent Les Hauts de Hurlevent (titre original : Wuthering Heights), parfois orthographié Les Hauts de Hurle-Vent, est l'unique roman d'Emily Brontë, publié pour la première fois en 1847 sous le pseudonyme d’Ellis Bell. Loin d'être un récit moralisateur, Emily Brontë achève néanmoins le roman dans une atmosphère sereine, suggérant le triomphe de la paix et du Bien sur la vengeance et le Mal.
4 9e1c4c81-dc90-4600-85b1-e9dd4bf12ce0 207 de Jane Eyre Jane Eyre. Eine Autobiographie (Originaltitel: Jane Eyre. An Autobiography), erstmals erschienen im Jahr 1847 unter dem Pseudonym Currer Bell, ist der erste veröffentlichte Roman der britischen Autorin Charlotte Brontë und ein Klassiker der viktorianischen Romanliteratur des 19. Jahrhunderts. Der Roman erzählt in Form einer Ich-Erzählung die Lebensgeschichte von Jane Eyre (ausgesprochen /ˌdʒeɪn ˈɛə/), die nach einer schweren Kindheit eine Stelle als Gouvernante annimmt und sich in ihren Arbeitgeber verliebt, jedoch immer wieder um ihre Freiheit und Selbstbestimmung kämpfen muss. Als klein, dünn, blass, stets schlicht dunkel gekleidet und mit strengem Mittelscheitel beschrieben, gilt die Heldin des Romans Jane Eyre nicht zuletzt aufgrund der Kino- und Fernsehversionen der melodramatischen Romanvorlage als die bekannteste englische Gouvernante der Literaturgeschichte
5 9be0524b-4cb9-4fc1-9dc2-d65b1c13cf53 252 de Eleonora “Eleonora” ist eine Erzählung von Edgar Allan Poe. Sie wurde 1841 erstveröffentlicht. In ihr geht es um das Paradox der Treue in der Treulosigkeit.

View File

@@ -1,43 +1,16 @@
ID,parent_ID,name ID,parent_ID,name
10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,,Fiction 10,,Fiction
11aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Drama 11,10,Drama
12aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Poetry 12,10,Poetry
13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Fantasy 13,10,Fantasy
131aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Fairy Tale 14,10,Science Fiction
132aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Epic Fantasy 15,10,Romance
133aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,High Fantasy 16,10,Mystery
134aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Gothic 17,10,Thriller
14aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Science Fiction 18,10,Dystopia
141aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,14aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Utopian and Dystopian 19,10,Fairy Tale
1411aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,141aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Utopian 20,,Non-Fiction
1412aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,141aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Dystopian 21,20,Biography
14121aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,1412aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Cyberpunk 22,21,Autobiography
141211aa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,14121aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Steampunk 23,20,Essay
142aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,14aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Space Opera 24,20,Speech
143aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,14aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Time Travel
144aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,14aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Tech Noir
15aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Romance
151aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,15aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Contemporary Romance
152aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,15aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Historical Romance
153aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,15aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Romantic Suspense
16aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Mystery
161aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,16aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Crime
1611aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,161aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Thriller
16111aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,1611aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Police Procedural
16112aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,1611aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Legal Thriller
16113aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,1611aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Medical Thriller
16114aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,1611aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Spy Thriller
1612aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,161aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Detective
1613aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,161aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Suspense
162aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,16aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Noir
1621aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,162aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Nordic Noir
1622aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,162aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Tart Noir
163aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,16aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Cozy Mystery
17aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Adventure
18aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Short Story
19aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Graphic Novel
20aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,,Non-Fiction
21aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,20aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Biography
22aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,21aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Autobiography
23aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,20aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Essay
24aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,20aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Speech
1 ID parent_ID name
2 10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 10 Fiction
3 11aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 11 10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 10 Drama
4 12aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 12 10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 10 Poetry
5 13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 13 10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 10 Fantasy
6 131aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 14 13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 10 Fairy Tale Science Fiction
7 132aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 15 13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 10 Epic Fantasy Romance
8 133aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 16 13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 10 High Fantasy Mystery
9 134aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 17 13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 10 Gothic Thriller
10 14aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 18 10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 10 Science Fiction Dystopia
11 141aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 19 14aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 10 Utopian and Dystopian Fairy Tale
12 1411aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 20 141aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Utopian Non-Fiction
13 1412aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 21 141aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 20 Dystopian Biography
14 14121aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 22 1412aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 21 Cyberpunk Autobiography
15 141211aa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 23 14121aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 20 Steampunk Essay
16 142aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 24 14aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 20 Space Opera Speech
143aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 14aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Time Travel
144aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 14aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Tech Noir
15aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Romance
151aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 15aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Contemporary Romance
152aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 15aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Historical Romance
153aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 15aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Romantic Suspense
16aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Mystery
161aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 16aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Crime
1611aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 161aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Thriller
16111aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 1611aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Police Procedural
16112aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 1611aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Legal Thriller
16113aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 1611aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Medical Thriller
16114aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 1611aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Spy Thriller
1612aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 161aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Detective
1613aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 161aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Suspense
162aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 16aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Noir
1621aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 162aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Nordic Noir
1622aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 162aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Tart Noir
163aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 16aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Cozy Mystery
17aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Adventure
18aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Short Story
19aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Graphic Novel
20aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Non-Fiction
21aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 20aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Biography
22aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 21aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Autobiography
23aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 20aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Essay
24aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa 20aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Speech

View File

@@ -8,7 +8,7 @@ entity Books : managed {
author : Association to Authors @mandatory; author : Association to Authors @mandatory;
genre : Association to Genres; genre : Association to Genres;
stock : Integer; stock : Integer;
price : Price; price : Decimal;
currency : Currency; currency : Currency;
image : LargeBinary @Core.MediaType: 'image/png'; image : LargeBinary @Core.MediaType: 'image/png';
} }
@@ -25,14 +25,7 @@ entity Authors : managed {
/** Hierarchically organized Code List for Genres */ /** Hierarchically organized Code List for Genres */
entity Genres : sap.common.CodeList { entity Genres : sap.common.CodeList {
key ID : UUID; key ID : Integer;
parent : Association to Genres; parent : Association to Genres;
children : Composition of many Genres on children.parent = $self; children : Composition of many Genres on children.parent = $self;
} }
type Price : Decimal(9,2);
// ------------------------------------------------------------------
// temporary workaround for reuse in fiori sample and hana deployment
annotate Books with @fiori.draft.enabled;

View File

@@ -6,7 +6,8 @@
"app", "app",
"srv", "srv",
"db", "db",
"index.cds" "index.cds",
"index.js"
], ],
"devDependencies": { "devDependencies": {
"@cap-js/sqlite": "*" "@cap-js/sqlite": "*"

View File

@@ -1,2 +0,0 @@
using { AdminService } from './admin-service';
annotate AdminService with @requires:'admin';

View File

@@ -1,6 +1,5 @@
using { sap.capire.bookshop as my } from '../db/schema'; using { sap.capire.bookshop as my } from '../db/schema';
service AdminService @(path:'/admin') { service AdminService @(requires:'admin', path:'/admin') {
entity Authors as projection on my.Authors;
entity Books as projection on my.Books; entity Books as projection on my.Books;
entity Genres as projection on my.Genres; entity Authors as projection on my.Authors;
} }

View File

@@ -1,6 +0,0 @@
// Add routes to UIs from imported packages
module.exports = (app) => {
app.serve ('/bookshop') .from ('@capire/bookshop','app/vue')
app.serve ('/reviews') .from ('@capire/reviews','app/vue')
app.serve ('/orders') .from('@capire/orders','app/orders')
}

View File

@@ -1 +0,0 @@
require('./srv/server')

View File

@@ -2,17 +2,20 @@
"name": "@capire/bookstore", "name": "@capire/bookstore",
"version": "1.0.0", "version": "1.0.0",
"dependencies": { "dependencies": {
"@cap-js/hana": "^1.7.0",
"@capire/bookshop": "*", "@capire/bookshop": "*",
"@capire/reviews": "*",
"@capire/orders": "*",
"@capire/common": "*", "@capire/common": "*",
"@capire/data-viewer": "*", "@capire/data-viewer": "*",
"@sap-cloud-sdk/http-client": "^4", "@capire/orders": "*",
"@sap-cloud-sdk/resilience": "^4", "@capire/reviews": "*",
"@sap-cloud-sdk/http-client": "^3.26.4",
"@sap-cloud-sdk/resilience": "^3.26.4",
"@sap/cds": ">=5", "@sap/cds": ">=5",
"express": "^4.17.1", "@sap/xssec": "^4.4.0",
"@cap-js/hana": "^1", "express": "^4.17.1"
"@sap/cds-mtxs": "^2" },
"scripts": {
"start": "cds-serve"
}, },
"cds": { "cds": {
"requires": { "requires": {
@@ -25,14 +28,12 @@
"model": "@capire/orders" "model": "@capire/orders"
}, },
"messaging": true, "messaging": true,
"db": true, "db": {
"multitenancy": true, "kind": "sql"
"auth": "xsuaa" }
}, },
"log": { "service": true } "log": {
}, "service": true
"scripts": { }
"start": "cds-serve"
} }
} }

20
bookstore/server.js Normal file
View File

@@ -0,0 +1,20 @@
const cds = require ('@sap/cds')
// Add mashup logic
cds.once('served', require('./srv/mashup'))
// Add routes to UIs from imported packages
cds.once('bootstrap',(app)=>{
try {
app.serve ('/bookshop') .from ('@capire/bookshop','app/vue')
app.serve ('/reviews') .from ('@capire/reviews','app/vue')
app.serve ('/orders') .from('@capire/orders','app/orders')
app.serve ('/data') .from('@capire/data-viewer','app/viewer')
} catch (err) {
if (err.code === 'MODULE_NOT_FOUND') throw new Error('Run "npm ci" to install the required dependencies', { cause: err })
throw err
}
})
// Add Swagger UI
require('./srv/swagger-ui')

View File

@@ -1,11 +1,10 @@
const cds = require ('@sap/cds') ////////////////////////////////////////////////////////////////////////////
//
// Add routes to UIs from imported packages // Mashing up bookshop services with required services...
if (!cds.env.production) cds.once ('bootstrap', require('../app/routes')) //
module.exports = async()=>{ // called by server.js
// Mashing up bookshop services with required services...
cds.once ('served', async ()=>{ // called by server.js
const cds = require('@sap/cds')
const CatalogService = await cds.connect.to ('CatalogService') const CatalogService = await cds.connect.to ('CatalogService')
const ReviewsService = await cds.connect.to ('ReviewsService') const ReviewsService = await cds.connect.to ('ReviewsService')
const OrdersService = await cds.connect.to ('OrdersService') const OrdersService = await cds.connect.to ('OrdersService')
@@ -56,4 +55,4 @@ cds.once ('served', async ()=>{ // called by server.js
.and ('stock >=', deltaQuantity) .and ('stock >=', deltaQuantity)
.set ('stock -=', deltaQuantity) .set ('stock -=', deltaQuantity)
}) })
}) }

View File

@@ -0,0 +1,10 @@
// -----------------------------------------------------------------------
// Adding Swagger UI - see https://cap.cloud.sap/docs/advanced/openapi
const cds = require ('@sap/cds')
try {
const cds_swagger = require ('cds-swagger-ui-express')
cds.once ('bootstrap', app => app.use (cds_swagger()) )
} catch (err) {
if (err.code !== 'MODULE_NOT_FOUND') throw err
}

1
db
View File

@@ -1 +0,0 @@
shared-db/db

View File

@@ -1,4 +0,0 @@
const cds = require("@sap/cds")
cds.on ('served', ()=> {
cds.app.serve ('/data') .from ('@capire/data-viewer','app/viewer')
})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 273 KiB

View File

@@ -1 +0,0 @@
cds.requires.[hybrid].messaging.kind=file-based-messaging

View File

@@ -1,7 +1,7 @@
Age = Age Age = Age
Lifetime = Lifetime Lifetime = Lifetime
SubGenres = Subgenre SubGenres = Sub Genres
NumCode = Numeric Code NumCode = Numeric Code
MinorUnit = Minor Unit MinorUnit = Minor Unit

View File

@@ -1,8 +1,6 @@
using { AdminService } from '@capire/bookstore'; using { AdminService } from '@capire/bookstore';
using from '../common'; // to help UI linter get the complete annotations using from '../common'; // to help UI linter get the complete annotations
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// //
// Books Object Page // Books Object Page
@@ -42,48 +40,7 @@ annotate AdminService.Books with @(
} }
); );
////////////////////////////////////////////////////////////////////////////
//
// Value Help for Tree Table
//
annotate AdminService.Books with {
genre @(Common: {
Label : 'Genre',
ValueList: {
CollectionPath : 'Genres',
Parameters : [
{
$Type : 'Common.ValueListParameterDisplayOnly',
ValueListProperty: 'name',
},
{
$Type : 'Common.ValueListParameterInOut',
LocalDataProperty: genre_ID,
ValueListProperty: 'ID',
}
],
PresentationVariantQualifier: 'VH',
}
});
}
annotate AdminService.Genres with @UI: {
PresentationVariant #VH: {
$Type : 'UI.PresentationVariantType',
Visualizations : ['@UI.LineItem'],
RecursiveHierarchyQualifier: 'GenreHierarchy'
},
LineItem : [{
$Type: 'UI.DataField',
Value: name,
Label :'{i18n>Name}'
}],
};
// Hide ID because of the ValueHelp
annotate AdminService.Genres with {
ID @UI.Hidden;
};
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// //
@@ -125,3 +82,5 @@ extend service AdminService {
// Workaround for Fiori popup for asking user to enter a new UUID on Create // Workaround for Fiori popup for asking user to enter a new UUID on Create
annotate AdminService.Books with { ID @Core.Computed; } annotate AdminService.Books with { ID @Core.Computed; }
// Show Genre as drop down, not a dialog
annotate AdminService.Books with { genre @Common.ValueListWithFixedValues; }

View File

@@ -3,6 +3,7 @@
"LaunchPage": { "LaunchPage": {
"adapter": { "adapter": {
"config": { "config": {
"catalogs": [],
"groups": [ "groups": [
{ {
"id": "Bookshop", "id": "Bookshop",
@@ -23,7 +24,7 @@
"id": "BrowseGenres", "id": "BrowseGenres",
"tileType": "sap.ushell.ui.tile.StaticTile", "tileType": "sap.ushell.ui.tile.StaticTile",
"properties": { "properties": {
"title": "Browse Genres", "title": "Browse Genres (OData v2)",
"targetURL": "#Genres-display" "targetURL": "#Genres-display"
} }
} }

View File

@@ -69,81 +69,28 @@ annotate my.Books with {
image @title: '{i18n>Image}'; image @title: '{i18n>Image}';
} }
////////////////////////////////////////////////////////////////////////////
//
// Computed Fields for Tree Tables
//
// DISCLAIMER: The below are an alpha version implementation and will change in final release !!!
//
aspect Hierarchy {
LimitedDescendantCount : Integer64 = null;
DistanceFromRoot : Integer64 = null;
DrillState : String = null;
Matched : Boolean = null;
MatchedDescendantCount : Integer64 = null;
LimitedRank : Integer64 = null;
}
annotate Hierarchy with @Capabilities.FilterRestrictions.NonFilterableProperties: [
'LimitedDescendantCount',
'DistanceFromRoot',
'DrillState',
'Matched',
'MatchedDescendantCount',
'LimitedRank'
];
annotate Hierarchy with @Capabilities.SortRestrictions.NonSortableProperties: [
'LimitedDescendantCount',
'DistanceFromRoot',
'DrillState',
'Matched',
'MatchedDescendantCount',
'LimitedRank'
];
extend my.Genres with Hierarchy;
////////////////////////////////////////////////////////////////////////////
//
// Genres Tree Table Annotations
//
// DISCLAIMER: The below are an alpha version implementation and will change in final release !!!
//
annotate my.Genres with @Aggregation.RecursiveHierarchy #GenreHierarchy: {
$Type : 'Aggregation.RecursiveHierarchyType',
NodeProperty : ID, // identifies a node
ParentNavigationProperty: parent // navigates to a node's parent
};
annotate my.Genres with @Hierarchy.RecursiveHierarchy #GenreHierarchy: {
$Type : 'Hierarchy.RecursiveHierarchyType',
LimitedDescendantCount: LimitedDescendantCount,
DistanceFromRoot : DistanceFromRoot,
DrillState : DrillState,
Matched : Matched,
MatchedDescendantCount: MatchedDescendantCount,
LimitedRank : LimitedRank
};
annotate my.Genres with @(
readonly,
cds.search: {name}
);
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// //
// Genres List // Genres List
// //
annotate my.Genres with @( annotate my.Genres with @(
Common.SemanticKey : [name], Common.SemanticKey : [name],
UI : { UI : {
SelectionFields : [name], SelectionFields : [name],
LineItem : [ LineItem : [
{ Value : name, Label : '{i18n>Name}' }, { Value: name },
], {
} Value : parent.name,
Label: 'Main Genre'
},
],
}
); );
annotate my.Genres with {
ID @Common.Text : name @Common.TextArrangement : #TextOnly;
}
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// //
// Genre Details // Genre Details
@@ -155,7 +102,12 @@ annotate my.Genres with @(UI : {
TypeNamePlural : '{i18n>Genres}', TypeNamePlural : '{i18n>Genres}',
Title : { Value: name }, Title : { Value: name },
Description : { Value: ID } Description : { Value: ID }
} },
Facets : [{
$Type : 'UI.ReferenceFacet',
Label : '{i18n>SubGenres}',
Target : 'children/@UI.LineItem'
}, ],
}); });
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
@@ -163,6 +115,7 @@ annotate my.Genres with @(UI : {
// Genres Elements // Genres Elements
// //
annotate my.Genres with { annotate my.Genres with {
ID @title: '{i18n>ID}';
name @title: '{i18n>Genre}'; name @title: '{i18n>Genre}';
} }

View File

@@ -1,3 +1,8 @@
/* using { sap.capire.bookshop } from '../../db/common';
All annotations needed for UI5 Tree Table View are located in '../common'
*/ annotate bookshop.GenreHierarchy {
ID @sap.hierarchy.node.for;
parent @sap.hierarchy.parent.node.for;
hierarchyLevel @sap.hierarchy.level.for;
drillState @sap.hierarchy.drill.state.for;
}

View File

@@ -1,3 +1,7 @@
sap.ui.define(["sap/fe/core/AppComponent"], ac => ac.extend("genres.Component", { sap.ui.define(["sap/suite/ui/generic/template/lib/AppComponent"], (AppComponent) =>
metadata:{ manifest:'json' } AppComponent.extend("genres.Component", {
})) metadata: {
manifest: "json",
},
})
);

View File

@@ -1,4 +1,4 @@
#XTIT #XTIT
appTitle=Browse Genres appTitle=Genres
#XTXT #XTXT
appDescription=Genres as Tree View appDescription=Browse Genres

View File

@@ -1,2 +0,0 @@
appTitle=Zeige Genres
appDescription=Genres als Baumansicht

View File

@@ -1,124 +1,155 @@
{ {
"_version": "1.8.0", "_version": "1.8.0",
"sap.app": { "sap.app": {
"id": "genres", "id": "genres",
"type": "application", "type": "application",
"title": "{{appTitle}}", "i18n": "i18n/i18n.properties",
"description": "{{appDescription}}", "applicationVersion": {
"applicationVersion": { "version": "1.0.0"
"version": "1.0.0" },
}, "title": "Browse Genres Hierarchy (OData v2)",
"dataSources": { "description": "{{appDescription}}",
"AdminService": { "tags": {
"uri": "admin/", "keywords": []
"type": "OData", },
"settings": { "crossNavigation": {
"odataVersion": "4.0" "inbounds": {
} "appShow": {
} "title": "{{appTitle}}",
}, "semanticObject": "GenreHierarchy",
"crossNavigation": { "action": "display",
"inbounds": { "deviceTypes": {
"Genres-display": { "desktop": true,
"signature": { "tablet": true,
"parameters": {}, "phone": true
"additionalParameters": "allowed" },
}, "icon": "sap-icon://settings",
"semanticObject": "Genres", "size": "1x1"
"action": "display" }
} },
} "outbounds": {}
} },
}, "ach": "",
"sap.ui5": { "resources": "resources.json",
"dependencies": { "dataSources": {
"minUI5Version": "1.122.0", "main": {
"libs": { "uri": "/odata/v2/browse",
"sap.fe.templates": {} "type": "OData",
} "settings": {
}, "annotations": ["localAnnotations"],
"models": { "localUri": "localService/metadata.xml"
"i18n": { }
"type": "sap.ui.model.resource.ResourceModel", },
"uri": "i18n/i18n.properties" "localAnnotations": {
}, "type": "ODataAnnotation",
"": { "uri": "annotations/localAnnotations.xml",
"dataSource": "AdminService", "settings": {
"settings": { "localUri": "annotations/localAnnotations.xml"
"synchronizationMode": "None", }
"operationMode": "Server", }
"autoExpandSelect": true, },
"earlyRequests": true, "offline": false,
"groupProperties": { "sourceTemplate": {
"default": { "id": "ui5template.smartTemplate",
"submit": "Auto" "version": "1.40.12"
} }
} },
} "sap.ui": {
} "technology": "UI5",
}, "icons": {
"routing": { "icon": "",
"routes": [ "favIcon": "",
{ "phone": "",
"pattern": ":?query:", "phone@2": "",
"name": "GenresList", "tablet": "",
"target": "GenresList" "tablet@2": ""
}, },
{ "deviceTypes": {
"pattern": "Genres({key}):?query:", "desktop": true,
"name": "GenresDetails", "tablet": true,
"target": "GenresDetails" "phone": true
} },
], "supportedThemes": ["sap_hcb", "sap_belize", "sap_belize_deep", "sap_fiori_3"]
"targets": { },
"GenresList": { "sap.ui5": {
"type": "Component", "resources": {
"id": "GenresList", "js": [],
"name": "sap.fe.templates.ListReport", "css": []
"options": { },
"settings": { "dependencies": {
"contextPath": "/Genres", "minUI5Version": "1.65.6",
"navigation": { "libs": {},
"Genres": { "components": {}
"detail": { },
"route": "GenresDetails" "models": {
} "i18n": {
} "type": "sap.ui.model.resource.ResourceModel",
}, "uri": "i18n/i18n.properties"
"controlConfiguration": { },
"@com.sap.vocabularies.UI.v1.LineItem": { "@i18n": {
"tableSettings": { "type": "sap.ui.model.resource.ResourceModel",
"hierarchyQualifier": "GenreHierarchy", "uri": "i18n/i18n.properties"
"type": "TreeTable" },
} "json": {
} "type": "sap.ui.model.json.JSONModel"
} },
} "i18n|sap.suite.ui.generic.template.ListReport|Genres": {
} "type": "sap.ui.model.resource.ResourceModel",
}, "uri": "i18n/ListReport/Genres/i18n.properties"
"GenresDetails": { },
"type": "Component", "": {
"id": "GenresDetails", "dataSource": "main",
"name": "sap.fe.templates.ObjectPage", "preload": true,
"options": { "settings": {
"settings": { "useBatch": true,
"contextPath": "/Genres" "defaultBindingMode": "TwoWay",
} "defaultCountMode": "Inline",
} "refreshAfterChange": true,
} "metadataUrlParams": {
} "sap-value-list": "none"
}, }
"contentDensities": { }
"compact": true, }
"cozy": true },
} "contentDensities": {
}, "compact": true,
"sap.ui": { "cozy": true
"technology": "UI5", }
"fullWidth": false },
}, "sap.ui.generic.app": {
"sap.fiori": { "_version": "1.3.0",
"registrationIds": [], "settings": {
"archeType": "transactional" "forceGlobalRefresh": false,
} "useColumnLayoutForSmartForm": false,
"showBasicSearch": false
},
"pages": {
"ListReport|Genres": {
"entitySet": "GenreHierarchy",
"component": {
"name": "sap.suite.ui.generic.template.ListReport",
"list": true,
"settings": {
"condensedTableLayout": true,
"smartVariantManagement": true,
"tableType": "TreeTable",
"enableTableFilterInPageVariant": true,
"dataLoadSettings": {
"loadDataOnAppLaunch": "always"
}
}
}
}
}
},
"sap.fiori": {
"registrationIds": [],
"archeType": "transactional"
},
"sap.platform.hcp": {
"uri": ""
},
"sap.platform.cf": {
"oAuthScopes": []
}
} }

View File

@@ -5,6 +5,6 @@
using from './admin-authors/fiori-service'; using from './admin-authors/fiori-service';
using from './admin-books/fiori-service'; using from './admin-books/fiori-service';
using from './browse/fiori-service'; using from './browse/fiori-service';
using from './genres/fiori-service';
using from './common'; using from './common';
using from '@capire/bookstore/srv/mashup'; using from '@capire/bookstore/srv/mashup';

14
fiori/db/common.cds Normal file
View File

@@ -0,0 +1,14 @@
namespace sap.capire.bookshop;
using { sap.capire.bookshop } from '@capire/bookstore/srv/mashup';
entity GenreHierarchy : bookshop.Genres {
hierarchyLevel : Integer default 0;
drillState : String default 'leaf';
parent : Association to GenreHierarchy;
children : Composition of many GenreHierarchy on children.parent = $self;
}
extend service CatalogService with {
@readonly entity GenreHierarchy as projection on bookshop.GenreHierarchy;
}

View File

@@ -0,0 +1,16 @@
ID;parent_ID;name;hierarchyLevel;drillState
10;;Fiction;0;expanded
11;10;Drama;1;leaf
12;10;Poetry;1;leaf
13;10;Fantasy;1;leaf
14;10;Science Fiction;1;leaf
15;10;Romance;1;leaf
16;10;Mystery;1;leaf
17;10;Thriller;1;leaf
18;10;Dystopia;1;leaf
20;;Non-Fiction;0;expanded
19;10;Fairy Tale;1;leaf
21;20;Biography;1;expanded
22;21;Autobiography;2;leaf
23;20;Essay;1;leaf
24;20;Speech;1;leaf
1 ID parent_ID name hierarchyLevel drillState
2 10 Fiction 0 expanded
3 11 10 Drama 1 leaf
4 12 10 Poetry 1 leaf
5 13 10 Fantasy 1 leaf
6 14 10 Science Fiction 1 leaf
7 15 10 Romance 1 leaf
8 16 10 Mystery 1 leaf
9 17 10 Thriller 1 leaf
10 18 10 Dystopia 1 leaf
11 20 Non-Fiction 0 expanded
12 19 10 Fairy Tale 1 leaf
13 21 20 Biography 1 expanded
14 22 21 Autobiography 2 leaf
15 23 20 Essay 1 leaf
16 24 20 Speech 1 leaf

View File

@@ -4,6 +4,7 @@
"dependencies": { "dependencies": {
"@capire/bookstore": "*", "@capire/bookstore": "*",
"@sap/cds": ">=5", "@sap/cds": ">=5",
"@cap-js-community/odata-v2-adapter": "^1",
"express": "^4.17.1" "express": "^4.17.1"
}, },
"devDependencies": { "devDependencies": {
@@ -23,8 +24,20 @@
"kind": "odata", "kind": "odata",
"model": "@capire/orders" "model": "@capire/orders"
}, },
"messaging": true, "messaging": {
"db": true, "[production]": {
"kind": "enterprise-messaging"
},
"[development]": {
"kind": "file-based-messaging"
},
"[hybrid]": {
"kind": "enterprise-messaging-shared"
}
},
"db": {
"kind": "sql"
},
"db-ext": { "db-ext": {
"[development]": { "[development]": {
"model": "db/sqlite" "model": "db/sqlite"
@@ -33,6 +46,9 @@
"model": "db/hana" "model": "db/hana"
} }
} }
},
"hana": {
"deploy-format": "hdbtable"
} }
}, },
"sapux": [ "sapux": [

View File

@@ -1,32 +0,0 @@
const cds = require('@sap/cds/lib')
if (cds.requires.db?.kind === 'sqlite') {
cds.on ('serving:AdminService', srv => srv.prepend(() => {
const {Genres} = srv.entities
// Register a simplistic handler for hierarchical queries
srv.on('READ', Genres, (req,next) => {
const q = req.query
// Expand query on a single row
if (q.SELECT.recurse?.where?.[0].ref[0] === 'Distance') {
q.SELECT.where[0] = 'parent_ID'
// Initial query
} else if (!q.SELECT.search && !is_count(q)) {
q.SELECT.where ??= [ 'parent_ID is null' ]
}
// Use scalar subselect for DrillState
q.SELECT.from.as = 'g'
q.SELECT.columns = q.SELECT.columns.map (c => {
if (c.ref == 'DrillState') return { xpr:[`
CASE WHEN ( SELECT count(1) from ${Genres} where parent_ID = g.ID ) > 0
THEN 'collapsed' ELSE 'leaf' END`
], as: 'DrillState' }
else return c
})
// Suppress error message: Feature "recurse" queries not supported.
delete q.SELECT.__proto__.recurse
delete q.SELECT.recurse
return next()
})
}))
}
const is_count = q => q.SELECT.columns?.length === 1 && q.SELECT.columns[0].func === 'count'

View File

@@ -1,3 +0,0 @@
export default {
silent: true
}

176
mta.yaml
View File

@@ -1,6 +1,6 @@
_schema-version: 3.3.0 _schema-version: 3.3.0
ID: capire.samples ID: capire.samples
version: 2.1.0 version: 3.0.0
description: "A monorepo with several samples for CAP." description: "A monorepo with several samples for CAP."
parameters: parameters:
enable-parallel-deployments: true enable-parallel-deployments: true
@@ -9,109 +9,104 @@ build-parameters:
- builder: custom - builder: custom
commands: commands:
- npm ci - npm ci
- npx cds build --production - npx cds build ./shared-db --for hana --production
- npx cds build orders --for nodejs --production --ws-pack - npx cds build ./orders --for nodejs --production --ws-pack
- npx cds build reviews --for nodejs --production - npx cds build ./reviews --for nodejs --production
- npx cds build bookstore --for nodejs --production --ws-pack - npx cds build ./bookstore --for nodejs --production --ws-pack
modules: modules:
- name: bookstore-srv
type: nodejs
path: bookstore/gen/srv
parameters:
instances: 1
buildpack: nodejs_buildpack
build-parameters:
builder: npm
properties:
cds_requires_ReviewsService_credentials: {"destination": "reviews-dest","path": "/reviews"}
cds_requires_OrdersService_credentials: {"destination": "orders-dest","path": "/odata/v4/orders"}
provides:
- name: bookstore-api # required by consumers of CAP services (e.g. approuter)
properties:
srv-url: ${default-url}
requires:
- name: samples-db
- name: samples-auth
- name: samples-messaging
- name: samples-destination
- name: orders-srv - name: orders-srv
type: nodejs type: nodejs
path: orders/gen/srv path: orders/gen/srv
parameters: parameters:
instances: 1
buildpack: nodejs_buildpack buildpack: nodejs_buildpack
readiness-health-check-type: http
readiness-health-check-http-endpoint: /health
disk-quota: 256M
memory: 256M
build-parameters: build-parameters:
builder: npm builder: npm
provides: provides:
- name: orders-api - name: orders-api # required by consumers of CAP services (e.g. approuter)
properties: properties:
srv-url: ${default-url} srv-url: ${default-url}
requires: requires:
- name: samples-messaging
- name: samples-db - name: samples-db
- name: samples-auth - name: samples-auth
- name: samples-messaging
- name: samples-destination
- name: reviews-srv - name: reviews-srv
type: nodejs type: nodejs
path: reviews/gen/srv path: reviews/gen/srv
parameters: parameters:
instances: 1
buildpack: nodejs_buildpack buildpack: nodejs_buildpack
readiness-health-check-type: http
readiness-health-check-http-endpoint: /health
disk-quota: 256M
memory: 256M
build-parameters: build-parameters:
builder: npm builder: npm
provides: provides:
- name: reviews-api - name: reviews-api # required by consumers of CAP services (e.g. approuter)
properties: properties:
srv-url: ${default-url} srv-url: ${default-url}
requires: requires:
- name: samples-messaging
- name: samples-db - name: samples-db
- name: samples-auth - name: samples-auth
- name: samples-messaging
- name: samples-destination
- name: bookstore-srv - name: samples-db-deployer
type: nodejs type: hdb
path: bookstore/gen/srv path: shared-db/gen/db
parameters: parameters:
buildpack: nodejs_buildpack buildpack: nodejs_buildpack
readiness-health-check-type: http
readiness-health-check-http-endpoint: /health
disk-quota: 256M
memory: 256M
properties:
cds_requires_ReviewsService_credentials: {"destination": "reviews-dest","path": "/reviews"}
cds_requires_OrdersService_credentials: {"destination": "orders-dest","path": "/odata/v4/orders"}
build-parameters:
builder: npm
provides:
- name: bookstore-api
properties:
srv-url: ${default-url}
requires: requires:
- name: samples-messaging
- name: samples-db - name: samples-db
- name: samples-auth
- name: samples-destination
- name: samples - name: samples
type: approuter.nodejs type: approuter.nodejs
path: .deploy/app-router path: app/router
parameters: parameters:
keep-existing-routes: true keep-existing-routes: true
disk-quota: 256M disk-quota: 256M
memory: 256M memory: 256M
properties:
TENANT_HOST_PATTERN: "^(.*)-${default-uri}"
requires: requires:
- name: orders-api - name: orders-api
group: destinations group: destinations
properties: properties:
name: orders-api # must be used in xs-app.json as well name: orders-api
url: ~{srv-url} url: ~{srv-url}
forwardAuthToken: true forwardAuthToken: true
- name: reviews-api - name: reviews-api
group: destinations group: destinations
properties: properties:
name: reviews-api # must be used in xs-app.json as well name: reviews-api
url: ~{srv-url} url: ~{srv-url}
forwardAuthToken: true forwardAuthToken: true
- name: bookstore-api - name: bookstore-api
group: destinations group: destinations
properties: properties:
name: bookstore-api # must be used in xs-app.json as well name: bookstore-api
url: ~{srv-url} url: ~{srv-url}
forwardAuthToken: true forwardAuthToken: true
- name: mtx-api
group: destinations
properties:
name: mtx-api # must be used in xs-app.json as well
url: ~{mtx-url}
- name: samples-auth - name: samples-auth
- name: samples-destination
provides: provides:
- name: app-api - name: app-api
properties: properties:
@@ -127,7 +122,7 @@ modules:
- name: samples-auth - name: samples-auth
parameters: parameters:
service-key: service-key:
name: xsuaa-service-key name: xsuaa_service-key
- name: samples-destination - name: samples-destination
parameters: parameters:
content-target: true content-target: true
@@ -142,35 +137,30 @@ modules:
URL: ~{orders-api/srv-url} URL: ~{orders-api/srv-url}
Authentication: OAuth2ClientCredentials Authentication: OAuth2ClientCredentials
TokenServiceInstanceName: samples-auth TokenServiceInstanceName: samples-auth
TokenServiceKeyName: xsuaa-service-key TokenServiceKeyName: xsuaa_service-key
- Name: reviews-dest - Name: reviews-dest
URL: ~{reviews-api/srv-url} URL: ~{reviews-api/srv-url}
Authentication: OAuth2ClientCredentials Authentication: OAuth2ClientCredentials
TokenServiceInstanceName: samples-auth TokenServiceInstanceName: samples-auth
TokenServiceKeyName: xsuaa-service-key TokenServiceKeyName: xsuaa_service-key
- name: samples-mtx
type: nodejs
path: gen/mtx/sidecar
build-parameters:
builder: npm
parameters:
instances: 1
memory: 256M
disk-quota: 512M
provides:
- name: mtx-api
properties:
mtx-url: ${default-url}
requires:
- name: samples-db
- name: samples-registry
- name: samples-auth
- name: app-api
properties:
SUBSCRIPTION_URL: ~{app-protocol}://\${tenant_subdomain}-~{app-uri}
resources: resources:
- name: samples-db
type: com.sap.xs.hdi-container
parameters:
service: hana
service-plan: hdi-shared
- name: samples-auth
type: org.cloudfoundry.managed-service
processed-after:
- samples-messaging
parameters:
service: xsuaa
service-plan: application
path: ./xs-security.json
config:
xsappname: samples-${org}-${space}
tenant-mode: dedicated
- name: samples-messaging - name: samples-messaging
type: org.cloudfoundry.managed-service type: org.cloudfoundry.managed-service
parameters: parameters:
@@ -180,52 +170,8 @@ resources:
config: config:
emname: bookstore-${org}-${space} emname: bookstore-${org}-${space}
namespace: cap/samples/${space} namespace: cap/samples/${space}
- name: samples-db
type: org.cloudfoundry.managed-service
parameters:
service: service-manager
service-plan: container
- name: samples-auth
type: org.cloudfoundry.managed-service
processed-after:
- samples-messaging
requires:
- name: app-api
parameters:
service: xsuaa
service-plan: application
path: ./xs-security.json
config:
xsappname: samples-${org}-${space}
tenant-mode: shared
oauth2-configuration:
redirect-uris:
- https://*-~{app-api/app-uri}/**
- name: samples-destination - name: samples-destination
type: org.cloudfoundry.managed-service type: org.cloudfoundry.managed-service
parameters: parameters:
service: destination service: destination
service-plan: lite service-plan: lite
- name: samples-registry
type: org.cloudfoundry.managed-service
requires:
- name: mtx-api
parameters:
service: saas-registry
service-plan: application
config:
xsappname: samples-${org}-${space}
appName: samples-${org}-${space}
displayName: samples-shared-db
description: CAP Samples with shared-db and multitenancy
category: 'Samples shared-db'
appUrls:
getDependencies: ~{mtx-api/mtx-url}/-/cds/saas-provisioning/dependencies
onSubscription: ~{mtx-api/mtx-url}/-/cds/saas-provisioning/tenant/{tenantId}
onSubscriptionAsync: true
onUnSubscriptionAsync: true
onUpdateDependenciesAsync: true
callbackTimeoutMillis: 300000 # Increase if your deployments are taking longer than that

View File

@@ -1,19 +0,0 @@
{
"name": "samples-mtx",
"dependencies": {
"@cap-js/hana": "^1",
"@sap/cds": "^8",
"@sap/cds-mtxs": "^2",
"@sap/xssec": "^4",
"express": "^4"
},
"devDependencies": {
"@cap-js/sqlite": "^1"
},
"scripts": {
"start": "cds-serve"
},
"cds": {
"profile": "mtx-sidecar"
}
}

View File

@@ -1 +1,2 @@
cds.requires.messaging.kind = file-based-messaging
PORT = 4006 PORT = 4006

View File

@@ -16,7 +16,7 @@
description: "CAP Sample App", description: "CAP Sample App",
additionalInformation: "SAPUI5.Component=orders", additionalInformation: "SAPUI5.Component=orders",
applicationType : "URL", applicationType : "URL",
url: "webapp", url: "/orders/webapp",
navigationMode: "embedded" navigationMode: "embedded"
} }
} }

View File

@@ -2,21 +2,18 @@
"name": "@capire/orders", "name": "@capire/orders",
"version": "1.0.0", "version": "1.0.0",
"dependencies": { "dependencies": {
"@cap-js/hana": "^1", "@cap-js/hana": "^1.7.0",
"@capire/common": "*", "@capire/common": "*",
"@sap/cds": ">=5", "@sap/cds": ">=5",
"@sap/xssec": "^4", "@sap/xssec": "^4.4.0"
"@sap/cds-mtxs": "^2" },
"scripts": {
"start": "cds-serve"
}, },
"cds": { "cds": {
"requires": { "requires": {
"messaging": true, "messaging": true,
"db": true, "db": true
"multitenancy": true,
"auth": "xsuaa"
} }
},
"scripts": {
"start": "cds-serve"
} }
} }

View File

@@ -3,13 +3,13 @@ using { sap.capire.orders as my } from '../db/schema';
service OrdersService { service OrdersService {
entity Orders as projection on my.Orders; entity Orders as projection on my.Orders;
@odata.draft.bypass
@(requires: 'system-user')
entity OrdersNoDraft as projection on my.Orders;
event OrderChanged { event OrderChanged {
product: String; product: String;
deltaQuantity: Integer; deltaQuantity: Integer;
} }
@odata.draft.bypass
@(requires: 'system-user')
entity OrdersNoDraft as projection on my.Orders;
} }

View File

@@ -8,14 +8,18 @@ class OrdersService extends cds.ApplicationService {
this.before ('UPDATE', 'Orders', async function(req) { this.before ('UPDATE', 'Orders', async function(req) {
const { ID, Items } = req.data const { ID, Items } = req.data
if (Items) for (let { product_ID, quantity } of Items) { if (Items) for (let { product_ID, quantity } of Items) {
const { quantity:before } = await SELECT.one.from (OrderItems, oi => oi.quantity) .where ({up__ID:ID, product_ID}) const { quantity:before } = await cds.tx(req).run (
SELECT.one.from (OrderItems, oi => oi.quantity) .where ({up__ID:ID, product_ID})
)
if (quantity != before) await this.orderChanged (product_ID, quantity-before) if (quantity != before) await this.orderChanged (product_ID, quantity-before)
} }
}) })
this.before ('DELETE', 'Orders', async function(req) { this.before ('DELETE', 'Orders', async function(req) {
const { ID } = req.data const { ID } = req.data
const Items = await SELECT.from (OrderItems, oi => { oi.product_ID, oi.quantity }) .where ({up__ID:ID}) const Items = await cds.tx(req).run (
SELECT.from (OrderItems, oi => { oi.product_ID, oi.quantity }) .where ({up__ID:ID})
)
if (Items) await Promise.all (Items.map(it => this.orderChanged (it.product_ID, -it.quantity))) if (Items) await Promise.all (Items.map(it => this.orderChanged (it.product_ID, -it.quantity)))
}) })

1701
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -4,28 +4,39 @@
"description": "A monorepo with several samples for CAP.", "description": "A monorepo with several samples for CAP.",
"repository": "https://github.com/sap-samples/cloud-cap-samples.git", "repository": "https://github.com/sap-samples/cloud-cap-samples.git",
"author": "daniel.hutzel@sap.com", "author": "daniel.hutzel@sap.com",
"dependencies": {
"@sap/cds": ">=8",
"@cap-js/hana": "^1",
"@sap/xssec": "^4"
},
"workspaces": [ "workspaces": [
"./*", "./bookshop",
"./etc/*" "./bookstore",
"./common",
"./fiori",
"./orders",
"./reviews",
"./etc/data-viewer",
"./etc/loggers"
], ],
"devDependencies": { "devDependencies": {
"@cap-js/cds-test": "^0" "@cap-js/cds-test": "^0",
"@cap-js/cds-types": "^0",
"@cap-js/sqlite": "^1",
"@sap/cds-dk": "^8",
"eslint": "^9",
"semver": "^7"
}, },
"scripts": { "scripts": {
"start": "cds watch bookshop --open http://localhost:4004",
"bookstore": "cds watch bookstore",
"bookshop": "cds watch bookshop",
"fiori": "cds watch fiori",
"orders": "cds watch orders",
"reviews": "cds watch reviews",
"lint": "npx eslint",
"test": "chest test",
"jest": "npx jest",
"mocha": "npx mocha",
"node:test": "node --test",
"build": "mbt build -t gen --mtar mta.tar", "build": "mbt build -t gen --mtar mta.tar",
"deploy": "cf deploy gen/mta.tar", "deploy": "cf deploy gen/mta.tar",
"undeploy": "cf undeploy capire.samples --delete-services --delete-service-keys" "undeploy": "cf undeploy capire.samples --delete-services --delete-service-keys",
"bookshop": "cds watch bookshop",
"fiori": "cds watch fiori",
"lint": "eslint",
"test": "npx jest --silent",
"jest": "npx jest --silent",
"mocha": "CDS_TEST_SILENT=y npx mocha"
}, },
"mocha": { "mocha": {
"recursive": true, "recursive": true,
@@ -34,14 +45,18 @@
}, },
"license": "SEE LICENSE IN LICENSE", "license": "SEE LICENSE IN LICENSE",
"private": true, "private": true,
"dependencies": {
"@sap/cds-mtxs": "^2"
},
"cds": { "cds": {
"profile": "with-mtx-sidecar", "sql": {
"native_hana_associations": false
},
"requires": { "requires": {
"multitenancy": true, "[production]": {
"auth": "xsuaa" "auth": "xsuaa"
},
"messaging": {
"kind": "enterprise-messaging"
},
"destinations": true
} }
} }
} }

View File

@@ -1,57 +0,0 @@
# 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).
![](https://github.com/SAP-samples/cloud-cap-samples/workflows/CI/badge.svg)
## Get Started
Assumed you did your [initial setup of CAP Node.js](https://cap.cloud.sap/docs/get-started/#setup), simply copy & paste these lines to a terminal for a jumpstart:
```sh
git clone -q https://github.com/sap-samples/cloud-cap-samples cap/samples
cd cap/samples
npm install
npm test
npm start
```
After download and setup this starts the bookshop server and opens a browser window on _http://localhost:4004_ looking like that:
<p align="center">
<img width=480 src="etc/index-html.png" alt="bookshop showing up in browser" />
</p>
Click on the *[/vue](http:/localhost:4004/vue)* link at the top to display the bookshop app (when asked to log in, type `alice` as user and leave the password field blank).
## Grow as you go...
After the jumpstart, have a look into the enclosed sub folders/projects, which are:
- [bookshop](bookshop) a simplistic [primer app](https://cap.cloud.sap/docs/get-started/in-a-nutshell)
- [reviews](reviews) - a generic reuse service
- [orders](orders) - a generic reuse service
- [common](common) - a reuse content package
- [bookstore](bookstore) - a composite app of the above
- [fiori](fiori) - Fiori elements UIs for the bookstore
- [etc/*](etc) - Plugins adding cross-cutting concerns
- [test](test) - Tests for all the above
> _see also [samples.md](samples.md)_
<p align="center">
<img width=480 src="etc/samples.drawio.svg">
</p>
## Get Help
- Visit the [*capire* docs](https://cap.cloud.sap) to learn about CAP, ...
- especially [*Getting Started in a Nutshell*](https://cap.cloud.sap/docs/get-started/in-a-nutshell).
- Visit our [*SAP Community*](https://answers.sap.com/tags/9f13aee1-834c-4105-8e43-ee442775e5ce) to ask questions.
## 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](LICENSE)_ file.

View File

@@ -69,25 +69,3 @@ const reviews = Vue.createApp ({
// initially fill list of my reviews // initially fill list of my reviews
reviews.fetch() reviews.fetch()
axios.interceptors.request.use(csrfToken)
function csrfToken (request) {
if (request.method === 'head' || request.method === 'get') return request
if ('csrfToken' in document) {
request.headers['x-csrf-token'] = document.csrfToken
return request
}
return fetchToken().then(token => {
document.csrfToken = token
request.headers['x-csrf-token'] = document.csrfToken
return request
}).catch(() => {
document.csrfToken = null // set mark to not try again
return request
})
function fetchToken() {
return axios.get('/', { headers: { 'x-csrf-token': 'fetch' } })
.then(res => res.headers['x-csrf-token'])
}
}

View File

@@ -3,7 +3,7 @@
<head> <head>
<title> Capire Reviews </title> <title> Capire Reviews </title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/primitive-ui/dist/css/main.css"> <link rel="stylesheet" href="https://unpkg.com/primitive-ui/dist/css/main.css">
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.prod.js"></script> <script src="https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.prod.js"></script>
<style> <style>

View File

@@ -1,5 +1,5 @@
ID;subject;rating;reviewer;title;text ID;subject;rating;reviewer;title;text
1689144d-3b10-4849-bcbe-2408a13e161d;201;5;bob;Intriguing;Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. 1689144d-3b10-4849-bcbe-2408a13e161a;201;5;bob;Intriguing;Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
539ab728-3068-450f-a617-ed5af9e9dbb7;201;4;bob;Fascinating;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Id diam maecenas ultricies mi eget mauris pharetra et. Risus at ultrices mi tempus imperdiet nulla malesuada pellentesque. Pulvinar mattis nunc sed blandit libero. Facilisis magna etiam tempor orci eu. Nec sagittis aliquam malesuada bibendum arcu. Eu consequat ac felis donec. Ultricies tristique nulla aliquet enim tortor at auctor urna nunc. Tortor posuere ac ut consequat semper viverra nam libero. Amet nisl suscipit adipiscing bibendum est ultricies integer quis auctor. Scelerisque purus semper eget duis at tellus. Elementum tempus egestas sed sed risus pretium. Arcu dictum varius duis at. Amet luctus venenatis lectus magna fringilla urna. Eget velit aliquet sagittis id consectetur purus ut faucibus. Vitae auctor eu augue ut lectus. Fermentum iaculis eu non diam phasellus vestibulum. 1689144d-3b10-4849-bcbe-2408a13e161b;201;4;bob;Fascinating;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Id diam maecenas ultricies mi eget mauris pharetra et. Risus at ultrices mi tempus imperdiet nulla malesuada pellentesque. Pulvinar mattis nunc sed blandit libero. Facilisis magna etiam tempor orci eu. Nec sagittis aliquam malesuada bibendum arcu. Eu consequat ac felis donec. Ultricies tristique nulla aliquet enim tortor at auctor urna nunc. Tortor posuere ac ut consequat semper viverra nam libero. Amet nisl suscipit adipiscing bibendum est ultricies integer quis auctor. Scelerisque purus semper eget duis at tellus. Elementum tempus egestas sed sed risus pretium. Arcu dictum varius duis at. Amet luctus venenatis lectus magna fringilla urna. Eget velit aliquet sagittis id consectetur purus ut faucibus. Vitae auctor eu augue ut lectus. Fermentum iaculis eu non diam phasellus vestibulum.
cd9bfd8d-eab4-40ee-9b46-770302533009;207;2;bob;What is this?;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Libero justo laoreet sit amet cursus sit amet dictum. Nunc faucibus a pellentesque sit. Dis parturient montes nascetur ridiculus mus mauris vitae ultricies. Enim nunc faucibus a pellentesque. Commodo quis imperdiet massa tincidunt nunc pulvinar sapien. Cras ornare arcu dui vivamus. Facilisi etiam dignissim diam quis enim lobortis. Et molestie ac feugiat sed. Urna neque viverra justo nec ultrices dui. Ullamcorper a lacus vestibulum sed arcu non. Volutpat ac tincidunt vitae semper quis. Dignissim sodales ut eu sem. Feugiat in fermentum posuere urna nec. At augue eget arcu dictum varius. 1689144d-3b10-4849-bcbe-2408a13e161c;207;2;bob;What is this?;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Libero justo laoreet sit amet cursus sit amet dictum. Nunc faucibus a pellentesque sit. Dis parturient montes nascetur ridiculus mus mauris vitae ultricies. Enim nunc faucibus a pellentesque. Commodo quis imperdiet massa tincidunt nunc pulvinar sapien. Cras ornare arcu dui vivamus. Facilisi etiam dignissim diam quis enim lobortis. Et molestie ac feugiat sed. Urna neque viverra justo nec ultrices dui. Ullamcorper a lacus vestibulum sed arcu non. Volutpat ac tincidunt vitae semper quis. Dignissim sodales ut eu sem. Feugiat in fermentum posuere urna nec. At augue eget arcu dictum varius.
f2896a44-637f-4198-a428-c0966d10b7ce;251;3;bob;It's dark...;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Suscipit tellus mauris a diam. Velit aliquet sagittis id consectetur purus ut. Viverra adipiscing at in tellus integer. Vitae elementum curabitur vitae nunc. Mattis ullamcorper velit sed ullamcorper morbi. Diam quis enim lobortis scelerisque. Auctor neque vitae tempus quam pellentesque nec nam aliquam. Semper auctor neque vitae tempus. Quis eleifend quam adipiscing vitae proin. Neque convallis a cras semper auctor neque vitae. Imperdiet massa tincidunt nunc pulvinar sapien et ligula. Sit amet consectetur adipiscing elit ut aliquam purus. Pretium quam vulputate dignissim suspendisse. 1689144d-3b10-4849-bcbe-2408a13e161d;251;3;bob;It's dark...;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Suscipit tellus mauris a diam. Velit aliquet sagittis id consectetur purus ut. Viverra adipiscing at in tellus integer. Vitae elementum curabitur vitae nunc. Mattis ullamcorper velit sed ullamcorper morbi. Diam quis enim lobortis scelerisque. Auctor neque vitae tempus quam pellentesque nec nam aliquam. Semper auctor neque vitae tempus. Quis eleifend quam adipiscing vitae proin. Neque convallis a cras semper auctor neque vitae. Imperdiet massa tincidunt nunc pulvinar sapien et ligula. Sit amet consectetur adipiscing elit ut aliquam purus. Pretium quam vulputate dignissim suspendisse.
1 ID subject rating reviewer title text
2 1689144d-3b10-4849-bcbe-2408a13e161d 1689144d-3b10-4849-bcbe-2408a13e161a 201 5 bob Intriguing Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
3 539ab728-3068-450f-a617-ed5af9e9dbb7 1689144d-3b10-4849-bcbe-2408a13e161b 201 4 bob Fascinating Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Id diam maecenas ultricies mi eget mauris pharetra et. Risus at ultrices mi tempus imperdiet nulla malesuada pellentesque. Pulvinar mattis nunc sed blandit libero. Facilisis magna etiam tempor orci eu. Nec sagittis aliquam malesuada bibendum arcu. Eu consequat ac felis donec. Ultricies tristique nulla aliquet enim tortor at auctor urna nunc. Tortor posuere ac ut consequat semper viverra nam libero. Amet nisl suscipit adipiscing bibendum est ultricies integer quis auctor. Scelerisque purus semper eget duis at tellus. Elementum tempus egestas sed sed risus pretium. Arcu dictum varius duis at. Amet luctus venenatis lectus magna fringilla urna. Eget velit aliquet sagittis id consectetur purus ut faucibus. Vitae auctor eu augue ut lectus. Fermentum iaculis eu non diam phasellus vestibulum.
4 cd9bfd8d-eab4-40ee-9b46-770302533009 1689144d-3b10-4849-bcbe-2408a13e161c 207 2 bob What is this? Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Libero justo laoreet sit amet cursus sit amet dictum. Nunc faucibus a pellentesque sit. Dis parturient montes nascetur ridiculus mus mauris vitae ultricies. Enim nunc faucibus a pellentesque. Commodo quis imperdiet massa tincidunt nunc pulvinar sapien. Cras ornare arcu dui vivamus. Facilisi etiam dignissim diam quis enim lobortis. Et molestie ac feugiat sed. Urna neque viverra justo nec ultrices dui. Ullamcorper a lacus vestibulum sed arcu non. Volutpat ac tincidunt vitae semper quis. Dignissim sodales ut eu sem. Feugiat in fermentum posuere urna nec. At augue eget arcu dictum varius.
5 f2896a44-637f-4198-a428-c0966d10b7ce 1689144d-3b10-4849-bcbe-2408a13e161d 251 3 bob It's dark... Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Suscipit tellus mauris a diam. Velit aliquet sagittis id consectetur purus ut. Viverra adipiscing at in tellus integer. Vitae elementum curabitur vitae nunc. Mattis ullamcorper velit sed ullamcorper morbi. Diam quis enim lobortis scelerisque. Auctor neque vitae tempus quam pellentesque nec nam aliquam. Semper auctor neque vitae tempus. Quis eleifend quam adipiscing vitae proin. Neque convallis a cras semper auctor neque vitae. Imperdiet massa tincidunt nunc pulvinar sapien et ligula. Sit amet consectetur adipiscing elit ut aliquam purus. Pretium quam vulputate dignissim suspendisse.

View File

@@ -7,21 +7,28 @@
"index.cds" "index.cds"
], ],
"dependencies": { "dependencies": {
"@cap-js/hana": "^1", "@cap-js/hana": "^1.7.0",
"@sap/cds": ">=5", "@sap/cds": ">=5",
"@sap/xssec": "^4.2.7", "@sap/xssec": "^4.4.0",
"express": "^4.17.1", "express": "^4.17.1"
"@sap/cds-mtxs": "^2"
},
"cds": {
"requires": {
"messaging": true,
"db": true,
"multitenancy": true,
"auth": "xsuaa"
}
}, },
"scripts": { "scripts": {
"start": "cds-serve" "start": "cds-serve"
},
"cds": {
"requires": {
"messaging": {
"[development]": {
"kind": "file-based-messaging"
},
"[hybrid]": {
"kind": "enterprise-messaging-shared"
},
"[production]": {
"kind": "enterprise-messaging"
}
},
"db": true
}
} }
} }

View File

@@ -12,7 +12,9 @@ module.exports = cds.service.impl (function(){
// Emit an event to inform subscribers about new avg ratings for reviewed subjects // Emit an event to inform subscribers about new avg ratings for reviewed subjects
this.after (['CREATE','UPDATE','DELETE'], 'Reviews', async function(_,req) { this.after (['CREATE','UPDATE','DELETE'], 'Reviews', async function(_,req) {
const {subject} = req.data const {subject} = req.data
const { count, rating } = await SELECT.one `round(avg(rating),2) as rating, count(*) as count` .from (Reviews) .where ({subject}) const { count, rating } = await cds.tx(req) .run (
SELECT.one `round(avg(rating),2) as rating, count(*) as count` .from (Reviews) .where ({subject})
)
global.it || console.log ('< emitting:', 'reviewed', { subject, count, rating }) // eslint-disable-line no-console global.it || console.log ('< emitting:', 'reviewed', { subject, count, rating }) // eslint-disable-line no-console
await this.emit ('reviewed', { subject, count, rating }) await this.emit ('reviewed', { subject, count, rating })
}) })
@@ -21,7 +23,8 @@ module.exports = cds.service.impl (function(){
this.on ('like', (req) => { this.on ('like', (req) => {
if (!req.user) return req.reject(400, 'You must be identified to like a review') if (!req.user) return req.reject(400, 'You must be identified to like a review')
const {review} = req.data, {user} = req const {review} = req.data, {user} = req
return cds.run ([ const tx = cds.tx(req)
return tx.run ([
INSERT.into (Likes) .entries ({review_ID: review, user: user.id}), INSERT.into (Likes) .entries ({review_ID: review, user: user.id}),
UPDATE (Reviews) .set({liked: {'+=': 1}}) .where({ID:review}) UPDATE (Reviews) .set({liked: {'+=': 1}}) .where({ID:review})
]).catch(() => req.reject(400, 'You already liked that review')) ]).catch(() => req.reject(400, 'You already liked that review'))
@@ -31,8 +34,9 @@ module.exports = cds.service.impl (function(){
this.on ('unlike', async (req) => { this.on ('unlike', async (req) => {
if (!req.user) return req.reject(400, 'You must be identified to remove a former like of yours') if (!req.user) return req.reject(400, 'You must be identified to remove a former like of yours')
const {review} = req.data, {user} = req const {review} = req.data, {user} = req
const affectedRows = await DELETE.from (Likes) .where ({review_ID: review,user: user.id}) const tx = cds.tx(req)
if (affectedRows === 1) return UPDATE (Reviews) .set ({liked: {'-=': 1}}) .where ({ID:review}) const affectedRows = await tx.run (DELETE.from (Likes) .where ({review_ID: review,user: user.id}))
if (affectedRows === 1) return tx.run (UPDATE (Reviews) .set ({liked: {'-=': 1}}) .where ({ID:review}))
}) })
}) })

View File

@@ -59,6 +59,8 @@ Each sub directory essentially is an individual npm package arranged in an [all-
- [The Vue.js app](reviews/app/vue) imported from `reviews` is served as well - [The Vue.js app](reviews/app/vue) imported from `reviews` is served as well
- [The Vue.js app](etc/data-viewer/app/data) imported from `data-viewer` is served as well - [The Vue.js app](etc/data-viewer/app/data) imported from `data-viewer` is served as well
- [The Fiori app](orders/app) imported from `orders` is served as well - [The Fiori app](orders/app) imported from `orders` is served as well
- [OpenAPI export + Swagger UI](https://cap.cloud.sap/docs/advanced/openapi)
## [@capire/fiori](fiori) ## [@capire/fiori](fiori)
@@ -68,6 +70,10 @@ Each sub directory essentially is an individual npm package arranged in an [all-
- Support for Fiori Draft - Support for Fiori Draft
- Support for Value Helps - Support for Value Helps
- Serving SAP Fiori apps locally - Serving SAP Fiori apps locally
- Fiori Elements V2
- OData V2 using CDS OData V2 Adapter Proxy
- List Report (type `TreeTable`)
- `@sap.hierarchy` annotations
See the [Serving Fiori UIs](https://cap.cloud.sap/docs/advanced/fiori) documentation for more information. See the [Serving Fiori UIs](https://cap.cloud.sap/docs/advanced/fiori) documentation for more information.

View File

@@ -1,7 +1,14 @@
{ {
"name": "@capire/shared-db", "name": "shared-db",
"version": "3.0.0", "version": "1.0.0",
"description": "CAP Sample CDS model deployment for shared-db scenario", "main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"cds": { "cds": {
"sql": { "sql": {
"native_hana_associations": false "native_hana_associations": false

View File

@@ -1,9 +1,9 @@
const cds = require('@sap/cds') const cds = require('@sap/cds')
const { expect } = cds.test ('@capire/bookshop')
cds.User.default = cds.User.privileged // disable auth checks
describe('cap/samples - Consuming Services locally', () => { describe('cap/samples - Consuming Services locally', () => {
const { expect } = cds.test ('@capire/bookshop')
it('bootstrapped the database successfully', ()=>{ it('bootstrapped the database successfully', ()=>{
const { AdminService } = cds.services const { AdminService } = cds.services
const { Authors } = AdminService.entities const { Authors } = AdminService.entities
@@ -33,11 +33,33 @@ describe('cap/samples - Consuming Services locally', () => {
}) })
}) })
}).where(`name like`, 'E%') }).where(`name like`, 'E%')
if (require('semver').gte(cds.version, '5.9.0')) {
expect(authors).to.containSubset([
{
name: 'Emily Brontë',
books: [
{
title: 'Wuthering Heights',
currency: { name: 'British Pound', symbol: '£' },
},
],
},
{
name: 'Edgar Allen Poe',
books: [
{ title: 'The Raven', currency: { name: 'US Dollar', symbol: '$' } },
{ title: 'Eleonora', currency: { name: 'US Dollar', symbol: '$' } },
],
},
])
return
}
expect(authors).to.containSubset([ expect(authors).to.containSubset([
{ {
name: 'Emily Brontë', name: 'Emily Brontë',
books: [ books: [
{ {
ID: 201,
title: 'Wuthering Heights', title: 'Wuthering Heights',
currency: { name: 'British Pound', symbol: '£' }, currency: { name: 'British Pound', symbol: '£' },
}, },
@@ -46,8 +68,8 @@ describe('cap/samples - Consuming Services locally', () => {
{ {
name: 'Edgar Allen Poe', name: 'Edgar Allen Poe',
books: [ books: [
{ title: 'The Raven', currency: { name: 'US Dollar', symbol: '$' } }, { ID: 251, title: 'The Raven', currency: { name: 'US Dollar', symbol: '$' } },
{ title: 'Eleonora', currency: { name: 'US Dollar', symbol: '$' } }, { ID: 252, title: 'Eleonora', currency: { name: 'US Dollar', symbol: '$' } },
], ],
}, },
]) ])

View File

@@ -1,9 +1,12 @@
const cds = require('@sap/cds') const cds = require('@sap/cds')
const { GET, POST, expect } = cds.test(__dirname+'/../bookshop')
cds.User.default = cds.User.Privileged // hard core monkey patch
describe('cap/samples - Custom Handlers', () => { describe('cap/samples - Custom Handlers', () => {
const { GET, POST, expect } = cds.test(__dirname+'/../bookshop')
beforeAll(()=>{
cds.User.default = cds.User.Privileged // hard core monkey patch
})
it('should reject out-of-stock orders', async () => { it('should reject out-of-stock orders', async () => {
await expect(POST `/browse/submitOrder ${{ book: 201, quantity: 5 }}`).to.be.fulfilled await expect(POST `/browse/submitOrder ${{ book: 201, quantity: 5 }}`).to.be.fulfilled
await expect(POST `/browse/submitOrder ${{ book: 201, quantity: 5 }}`).to.be.fulfilled await expect(POST `/browse/submitOrder ${{ book: 201, quantity: 5 }}`).to.be.fulfilled

29
test/fiori.test.js Normal file
View File

@@ -0,0 +1,29 @@
// Quick hack: suppress deprecation warnings w/ Node22 caused by http-proxy (used by OData v2 proxy)
// See also: https://github.com/http-party/node-http-proxy/pull/1666
require('util')._extend = Object.assign
const cds = require('@sap/cds')
describe('cap/samples - Fiori APIs - v2', function() {
const { GET, expect, axios } = cds.test ('@capire/fiori', '--with-mocks')
axios.defaults.auth = { username: 'alice', password: 'admin' }
// if (this.timeout) this.timeout(1e6)
it('serves $metadata documents in v2', async () => {
const { headers, data } = await GET `/odata/v2/browse/$metadata`
expect(headers).to.contain({
'content-type': 'application/xml',
'dataserviceversion': '2.0',
})
expect(data).to.contain('<EntitySet Name="GenreHierarchy" EntityType="CatalogService.GenreHierarchy"/>')
})
it('serves Books in v2', async () => {
const { data } = await GET `/odata/v2/browse/Books`
expect(data).to.containSubset({d:{results:[]}})
expect(data.d.results.length).to.be.greaterThanOrEqual(5)
})
})

View File

@@ -45,7 +45,6 @@ describe('cap/samples - Hierarchical Data', ()=>{
] ]
} }
}) })
/* temp skip for release
if (q.forSQL) expect (q.forSQL()) .to.eql ({ if (q.forSQL) expect (q.forSQL()) .to.eql ({
SELECT: { SELECT: {
from: { ref:[ "Categories" ], as: "Categories" }, from: { ref:[ "Categories" ], as: "Categories" },
@@ -76,7 +75,6 @@ describe('cap/samples - Hierarchical Data', ()=>{
`) as children FROM Categories as Categories` + `) as children FROM Categories as Categories` +
`)` `)`
) )
*/
}) })
it ('supports nested reads', ()=> expect ( it ('supports nested reads', ()=> expect (

View File

@@ -1,9 +1,13 @@
const cds = require('@sap/cds') const cds = require('@sap/cds')
const { GET, expect } = cds.test (__dirname)
cds.User.default = cds.User.Privileged // hard core monkey patch
describe('cap/samples - Localized Data', () => { describe('cap/samples - Localized Data', () => {
const { GET, expect } = cds.test (__dirname)
beforeAll(()=>{
cds.User.default = cds.User.Privileged // hard core monkey patch
})
it('serves localized $metadata documents', async () => { it('serves localized $metadata documents', async () => {
const { data } = await GET(`/browse/$metadata?sap-language=de`, { headers: { 'accept-language': 'de' }}) const { data } = await GET(`/browse/$metadata?sap-language=de`, { headers: { 'accept-language': 'de' }})
expect(data).to.contain('<Annotation Term="Common.Label" String="Währung"/>') expect(data).to.contain('<Annotation Term="Common.Label" String="Währung"/>')

View File

@@ -1,8 +1,8 @@
const cds = require('@sap/cds') const cds = require('@sap/cds')
const { expect } = cds.test.in(__dirname,'..')
describe('cap/samples - Messaging', ()=>{ describe('cap/samples - Messaging', ()=>{
const { expect } = cds.test.in(__dirname,'..')
const _model = '@capire/reviews' const _model = '@capire/reviews'
const Reviews = 'sap.capire.reviews.Reviews' const Reviews = 'sap.capire.reviews.Reviews'
beforeAll(()=>{ beforeAll(()=>{

View File

@@ -1,8 +1,8 @@
const cds = require('@sap/cds') const cds = require('@sap/cds')
const { GET, expect, axios } = cds.test ('@capire/bookshop')
axios.defaults.auth = { username: 'alice', password: 'admin' }
describe('cap/samples - Bookshop APIs', () => { describe('cap/samples - Bookshop APIs', () => {
const { GET, expect, axios } = cds.test ('@capire/bookshop')
axios.defaults.auth = { username: 'alice', password: 'admin' }
it('serves $metadata documents in v4', async () => { it('serves $metadata documents in v4', async () => {
const { headers, status, data } = await GET `/browse/$metadata` const { headers, status, data } = await GET `/browse/$metadata`
@@ -17,8 +17,8 @@ describe('cap/samples - Bookshop APIs', () => {
}) })
it('serves ListOfBooks?$expand=genre,currency', async () => { it('serves ListOfBooks?$expand=genre,currency', async () => {
const Mystery = { name: 'Mystery' } const Mystery = { ID: 16, name: 'Mystery', descr: null, parent_ID: 10 }
const Romance = { name: 'Romance' } const Romance = { ID: 15, name: 'Romance', descr: null, parent_ID: 10 }
const USD = { code: 'USD', name: 'US Dollar', descr: null, symbol: '$' } const USD = { code: 'USD', name: 'US Dollar', descr: null, symbol: '$' }
const { data } = await GET `/browse/ListOfBooks ${{ const { data } = await GET `/browse/ListOfBooks ${{
params: { $search: 'Po', $select: `title,author`, $expand:`genre,currency` }, params: { $search: 'Po', $select: `title,author`, $expand:`genre,currency` },
@@ -93,9 +93,9 @@ describe('cap/samples - Bookshop APIs', () => {
it('serves user info', async () => { it('serves user info', async () => {
const { data: alice } = await GET `/user/me` const { data: alice } = await GET `/user/me`
expect(alice).to.containSubset({ id: 'alice' }) expect(alice).to.containSubset({ id: 'alice', locale:'en' })
const { data: joe } = await GET (`/user/me`, {auth: { username: 'joe' }}) const { data: joe } = await GET (`/user/me`, {auth: { username: 'joe' }})
expect(joe).to.containSubset({ id: 'joe' }) expect(joe).to.containSubset({ id: 'joe', locale:'en' })
}) })
}) })

View File

@@ -14,13 +14,6 @@
{ {
"name": "$XSAPPNAME.emmanagement", "name": "$XSAPPNAME.emmanagement",
"description": "Enterprise-Messaging Management Access" "description": "Enterprise-Messaging Management Access"
},
{
"name": "$XSAPPNAME.mtcallback",
"description": "Subscription via SaaS Registry",
"grant-as-authority-to-apps": [
"$XSAPPNAME(application,sap-provisioning,tenant-onboarding)"
]
} }
], ],
"attributes": [], "attributes": [],
@@ -30,7 +23,7 @@
"scope-references": [ "scope-references": [
"$XSAPPNAME.admin" "$XSAPPNAME.admin"
], ],
"description": "cloud-cap-samples bookstore admin" "description": "cap samples multi-service shared-db"
} }
], ],
"authorities-inheritance": false, "authorities-inheritance": false,