Compare commits
33 Commits
openSAP-we
...
openSAP-we
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
359bfebcac | ||
|
|
569546258d | ||
|
|
36981144d5 | ||
|
|
66e043294f | ||
|
|
6f79882c57 | ||
|
|
62c11dee1a | ||
|
|
7ef5034b3e | ||
|
|
a8dee62f25 | ||
|
|
85498a9875 | ||
|
|
19b09645db | ||
|
|
9861b05f2d | ||
|
|
c58bcf905f | ||
|
|
50ab059c13 | ||
|
|
46960159d1 | ||
|
|
02228e5a96 | ||
|
|
d4793177fc | ||
|
|
2787284aad | ||
|
|
61a318b250 | ||
|
|
6e42e5a173 | ||
|
|
bf162c23cc | ||
|
|
9b41615ac8 | ||
|
|
29840afc0b | ||
|
|
fa880e2987 | ||
|
|
90881558dc | ||
|
|
6d3e9a211a | ||
|
|
e694fbaf13 | ||
|
|
43d0373d70 | ||
|
|
b632013b16 | ||
|
|
a6deddf022 | ||
|
|
513bf9711f | ||
|
|
00c99c0e0b | ||
|
|
e042317f82 | ||
|
|
04ab69c48f |
@@ -6,7 +6,7 @@
|
|||||||
"jest": true
|
"jest": true
|
||||||
},
|
},
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"ecmaVersion": 2018
|
"ecmaVersion": 2017
|
||||||
},
|
},
|
||||||
"globals": {
|
"globals": {
|
||||||
"SELECT": true,
|
"SELECT": true,
|
||||||
|
|||||||
2
.npmrc
2
.npmrc
@@ -1 +1 @@
|
|||||||
registry=https://registry.npmjs.org
|
@sap:registry=https://npm.sap.com
|
||||||
52
.vscode/launch.json
vendored
52
.vscode/launch.json
vendored
@@ -5,45 +5,20 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "bookshop",
|
"name": "cds run",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"type": "node",
|
"type": "node",
|
||||||
"runtimeExecutable": "npx",
|
"runtimeExecutable": "npx",
|
||||||
"runtimeArgs": [
|
"runtimeArgs": ["-n"],
|
||||||
"-n"
|
"args": ["--", "cds", "run", "--with-mocks", "--in-memory?"], // the leading "--" arg ensures it works with as well as without debugging
|
||||||
],
|
|
||||||
"args": [
|
|
||||||
"--",
|
|
||||||
"cds",
|
|
||||||
"run",
|
|
||||||
"--in-memory"
|
|
||||||
],
|
|
||||||
"cwd": "${workspaceFolder}/packages/bookshop",
|
|
||||||
"console": "integratedTerminal",
|
|
||||||
"skipFiles": [
|
|
||||||
"<node_internals>/**"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cds run ...",
|
|
||||||
"request": "launch",
|
|
||||||
"type": "node",
|
|
||||||
"runtimeExecutable": "npx",
|
|
||||||
"runtimeArgs": [
|
|
||||||
"-n"
|
|
||||||
],
|
|
||||||
"args": [
|
|
||||||
"--",
|
|
||||||
"cds",
|
|
||||||
"run",
|
|
||||||
"--with-mocks",
|
|
||||||
"--in-memory?"
|
|
||||||
],
|
|
||||||
"cwd": "${workspaceFolder}/packages/${input:service}",
|
"cwd": "${workspaceFolder}/packages/${input:service}",
|
||||||
"console": "integratedTerminal",
|
"console": "integratedTerminal",
|
||||||
"skipFiles": [
|
"serverReadyAction": {
|
||||||
"<node_internals>/**"
|
"pattern": "server listening on (https?://\\S+|[0-9]+)",
|
||||||
]
|
"uriFormat": "http://localhost:%s",
|
||||||
|
"action": "openExternally"
|
||||||
|
},
|
||||||
|
"skipFiles": ["<node_internals>/**"]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"inputs": [
|
"inputs": [
|
||||||
@@ -56,9 +31,12 @@
|
|||||||
"bookstore",
|
"bookstore",
|
||||||
"media-server",
|
"media-server",
|
||||||
"office-supplies",
|
"office-supplies",
|
||||||
"reviews-service"
|
"orders-service",
|
||||||
|
"products-service",
|
||||||
|
"reviews-service",
|
||||||
|
"user-service"
|
||||||
],
|
],
|
||||||
"default": "bookshop"
|
"default": "bookstore"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"files.exclude": {
|
"files.exclude": {
|
||||||
"**/.gitignore": true,
|
"**/.gitignore": false,
|
||||||
"**/.vscode": true
|
"**/.git": false,
|
||||||
|
"**/.vscode": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
21
.vscode/tasks.json
vendored
21
.vscode/tasks.json
vendored
@@ -4,14 +4,23 @@
|
|||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"tasks": [
|
"tasks": [
|
||||||
{
|
{
|
||||||
"type": "npm", "script": "watch", "path": "packages/bookshop/",
|
"type": "shell", "label": "cds run bookshop",
|
||||||
"options": { "env": { "PORT": "4004" }},
|
"command": "npx", "args": [ "cds", "watch", "packages/bookshop" ],
|
||||||
"presentation": { "group": "A" }
|
"presentation": { "group": "A" },
|
||||||
|
"problemMatcher": []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "npm", "script": "watch", "path": "packages/reviews-service/",
|
"type": "shell", "label": "cds run bookshop-enhanced",
|
||||||
"options": { "env": { "PORT": "5005" }},
|
"command": "npx", "args": [ "cds", "watch", "packages/bookshop-enhanced" ],
|
||||||
"presentation": { "group": "A" }
|
"presentation": { "group": "A" },
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "shell", "label": "cds run reviews-service",
|
||||||
|
"command": "npx", "args": [ "cds", "watch", "packages/reviews-service" ],
|
||||||
|
"options": {"env": { "PORT":"5005" }},
|
||||||
|
"presentation": { "group": "A" },
|
||||||
|
"problemMatcher": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
78
README.md
78
README.md
@@ -11,7 +11,7 @@ In SAP Business Application Studio, open a terminal.
|
|||||||
Then clone the repo with this specific branch:
|
Then clone the repo with this specific branch:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git clone https://github.com/sap-samples/cloud-cap-samples projects/cloud-cap-samples -b openSAP-week3-unit5
|
git clone https://github.com/sap-samples/cloud-cap-samples projects/cloud-cap-samples -b openSAP-week4-unit1-final
|
||||||
cd projects/cloud-cap-samples
|
cd projects/cloud-cap-samples
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -25,87 +25,11 @@ npm install
|
|||||||
Now you're ready to run the samples, for example:
|
Now you're ready to run the samples, for example:
|
||||||
```sh
|
```sh
|
||||||
cd packages/bookshop
|
cd packages/bookshop
|
||||||
cds deploy
|
|
||||||
cds watch
|
cds watch
|
||||||
```
|
```
|
||||||
|
|
||||||
After that, watch out for the little popup in the lower right corner of SAP Business Application Studio that asks you to open the application in your browser.
|
After that, watch out for the little popup in the lower right corner of SAP Business Application Studio that asks you to open the application in your browser.
|
||||||
|
|
||||||
## Hints
|
|
||||||
- If your demo user logon window does not show up: clear the browsers login data
|
|
||||||
- If your port is still in use run in your terminal:
|
|
||||||
```
|
|
||||||
> pkill node //kill running node proceses
|
|
||||||
```
|
|
||||||
|
|
||||||
## Deploy to Cloud Foundry
|
|
||||||
|
|
||||||
Clean-up the CF space in your trial account if you already used it before. Make sure that there are no services or applications deployed.
|
|
||||||
|
|
||||||
Generation of the XSUAA service configuration file xs-security.json:
|
|
||||||
```sh
|
|
||||||
cds compile srv/ --to xsuaa > xs-security.json
|
|
||||||
```
|
|
||||||
|
|
||||||
In this unit we use [MTA](https://sap.github.io/cloud-mta-build-tool/) to do the deployment to CF
|
|
||||||
```sh
|
|
||||||
npm install -g mbt
|
|
||||||
```
|
|
||||||
You can generate the MTA.yaml from CDS and do manual modifications or simply use the already generated and adapted mta.yaml in the branch and directly generate the .mtar file
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### BEGIN OPTIONAL PART
|
|
||||||
|
|
||||||
If you want to generate the MTA.YAML yourself please do the following:
|
|
||||||
|
|
||||||
- Generate the mta.yaml with the HANA dependency
|
|
||||||
```sh
|
|
||||||
cds add hana --force
|
|
||||||
cds add mta
|
|
||||||
```
|
|
||||||
|
|
||||||
- Add the path to the generated xs-security.json in the MTA.YAML
|
|
||||||
```
|
|
||||||
parameters:
|
|
||||||
path: ./xs-security.json
|
|
||||||
service:xsuaa
|
|
||||||
service-plan: application
|
|
||||||
....
|
|
||||||
```
|
|
||||||
- Add the application block in the MTA.YAML
|
|
||||||
```
|
|
||||||
############## APP #########################
|
|
||||||
- name: capire-bookshop-app
|
|
||||||
type: nodejs
|
|
||||||
path: gen/app
|
|
||||||
parameters:
|
|
||||||
memory: 256M
|
|
||||||
build-parameters:
|
|
||||||
requires:
|
|
||||||
- name: capire-bookshop-srv
|
|
||||||
requires:
|
|
||||||
- name: capire-bookshop-uaa
|
|
||||||
- name: srv-binding
|
|
||||||
group: destinations
|
|
||||||
properties:
|
|
||||||
forwardAuthToken: true
|
|
||||||
name: srv-binding
|
|
||||||
url: ~{srv-url}
|
|
||||||
```
|
|
||||||
- Make sure to use service hanatrial instead of hana in the MTA.YAML
|
|
||||||
```
|
|
||||||
parameters:
|
|
||||||
service: hanatrial
|
|
||||||
```
|
|
||||||
#### END OPTIONAL PART
|
|
||||||
|
|
||||||
Generate the .mtar file for the deployment and deploy to cloud foundry:
|
|
||||||
```sh
|
|
||||||
mbt build -t ./
|
|
||||||
cf login -a https://api.cf.eu10.hana.ondemand.com
|
|
||||||
cf deploy sap.capire-bookshop_1.0.0.mtar
|
|
||||||
```
|
|
||||||
|
|
||||||
## Get Support
|
## Get Support
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "deploy",
|
|
||||||
"dependencies": {
|
|
||||||
"@sap/hdi-deploy": "^3.8.2"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": "^8"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"start": "node node_modules/@sap/hdi-deploy/deploy.js"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
1562
package-lock.json
generated
1562
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
17
package.json
17
package.json
@@ -5,20 +5,23 @@
|
|||||||
"author": "daniel.hutzel@sap.com",
|
"author": "daniel.hutzel@sap.com",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lerna": "npx --no-install lerna -v > /dev/null || npm i lerna --no-save",
|
|
||||||
"install": "(npm -s run lerna) && lerna bootstrap --hoist",
|
|
||||||
"cleanup": "lerna clean -y && rm -fr node_modules",
|
"cleanup": "lerna clean -y && rm -fr node_modules",
|
||||||
"bookshop": "cds watch packages/bookshop"
|
"install": "(npm -s run lerna) && lerna bootstrap --hoist",
|
||||||
|
"lerna": "npx --no-install lerna -v > /dev/null || npm i lerna --no-save",
|
||||||
|
"test": "jest",
|
||||||
|
"bookshop-enhanced": "cds watch packages/bookshop-enhanced",
|
||||||
|
"bookshop": "cds watch packages/bookshop",
|
||||||
|
"bookstore": "cds watch packages/bookstore",
|
||||||
|
"products-service": "cds watch packages/products-service",
|
||||||
|
"reviews-service": "cds watch packages/reviews-service"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sap/cds": "^4",
|
"@sap/cds": "^3",
|
||||||
"express": "^4"
|
"express": "^4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
|
||||||
"sqlite3": "*"
|
|
||||||
},
|
|
||||||
"--add-these-to-devDependencies-for-tests": {
|
"--add-these-to-devDependencies-for-tests": {
|
||||||
"@types/jest": "*",
|
"@types/jest": "*",
|
||||||
|
"sqlite3": "*",
|
||||||
"jest": "*"
|
"jest": "*"
|
||||||
},
|
},
|
||||||
"license": "SAP SAMPLE CODE LICENSE"
|
"license": "SAP SAMPLE CODE LICENSE"
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
{
|
|
||||||
"odata": {
|
|
||||||
"version": "v4"
|
|
||||||
},
|
|
||||||
"build": {
|
|
||||||
"target": "gen",
|
|
||||||
"tasks": [
|
|
||||||
{
|
|
||||||
"src": "db",
|
|
||||||
"for": "hana",
|
|
||||||
"options": {
|
|
||||||
"model": [
|
|
||||||
"db",
|
|
||||||
"srv"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "srv",
|
|
||||||
"for": "node-cf",
|
|
||||||
"options": {
|
|
||||||
"model": [
|
|
||||||
"db",
|
|
||||||
"srv",
|
|
||||||
"app"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "app",
|
|
||||||
"for": "fiori",
|
|
||||||
"options": {
|
|
||||||
"model": [
|
|
||||||
"app"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"auth": {
|
|
||||||
"passport": {
|
|
||||||
"strategy": "mock",
|
|
||||||
"users": {
|
|
||||||
"alice": {
|
|
||||||
"password": "123",
|
|
||||||
"ID": "alice",
|
|
||||||
"roles": [
|
|
||||||
"admin",
|
|
||||||
"authenticated-user"
|
|
||||||
],
|
|
||||||
"xs.user.attributes": {
|
|
||||||
"currency": [
|
|
||||||
"USD"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"bob": {
|
|
||||||
"password": "123",
|
|
||||||
"ID": "bob",
|
|
||||||
"roles": [
|
|
||||||
"authenticated-user"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
29
packages/bookshop/.vscode/launch.json
vendored
29
packages/bookshop/.vscode/launch.json
vendored
@@ -1,29 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Run bookshop",
|
|
||||||
"request": "launch",
|
|
||||||
"type": "node",
|
|
||||||
"cwd": "/home/user/projects/cloud-cap-samples/packages/bookshop",
|
|
||||||
"runtimeExecutable": "npx",
|
|
||||||
"runtimeArgs": [
|
|
||||||
"-n"
|
|
||||||
],
|
|
||||||
"args": [
|
|
||||||
"--",
|
|
||||||
"cds",
|
|
||||||
"run",
|
|
||||||
"--in-memory?"
|
|
||||||
],
|
|
||||||
"console": "internalConsole",
|
|
||||||
"internalConsoleOptions": "openOnSessionStart",
|
|
||||||
"skipFiles": [
|
|
||||||
"<node_internals>/**"
|
|
||||||
],
|
|
||||||
"env": {
|
|
||||||
"run.config": "{\"handlerId\":\"cap_run_config_handler_id\",\"runnableId\":\"/home/user/projects/cloud-cap-samples/packages/bookshop\"}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
<script src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
|
<script src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
|
||||||
data-sap-ui-libs="sap.m, sap.ushell, sap.collaboration, sap.ui.layout"
|
data-sap-ui-libs="sap.m, sap.ushell, sap.collaboration, sap.ui.layout"
|
||||||
data-sap-ui-compatVersion="edge"
|
data-sap-ui-compatVersion="edge"
|
||||||
data-sap-ui-theme="sap_fiori_3"
|
data-sap-ui-theme="sap_belize"
|
||||||
data-sap-ui-frameOptions="allow"
|
data-sap-ui-frameOptions="allow"
|
||||||
></script>
|
></script>
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "capire-bookshop-approuter",
|
|
||||||
"version": "0.0.1",
|
|
||||||
"description": "",
|
|
||||||
"dependencies": {
|
|
||||||
"@sap/approuter": "^8"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"start": "node node_modules/@sap/approuter/approuter.js"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
{
|
|
||||||
"welcomeFile": "/fiori.html",
|
|
||||||
"authenticationMethod": "route",
|
|
||||||
"routes": [
|
|
||||||
{
|
|
||||||
"source": "^/.*(html|js)$",
|
|
||||||
"localDir": "."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "^/sapui5/.*",
|
|
||||||
"localDir": "."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "^/.*/webapp/.*",
|
|
||||||
"localDir": "."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "/",
|
|
||||||
"destination": "srv-binding"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
ID;modifiedAt;createdAt;createdBy;modifiedBy;OrderNo;currency_code
|
ID;modifiedAt;createdAt;createdBy;modifiedBy;OrderNo;currency_code;status
|
||||||
7e2f2640-6866-4dcf-8f4d-3027aa831cad;;2019-01-31;john.doe@test.com;;1;EUR
|
da86efd0-4ba1-4078-b7f0-5c9c530297f7;;2019-01-31;ALICE;;1;EUR;processing
|
||||||
64e718c9-ff99-47f1-8ca3-950c850777d4;;2019-01-30;jane.doe@test.com;;2;EUR
|
2f2f2640-6866-4dcf-8f4d-3027aa831cad;;2019-03-25;ALICE;;10;EUR;completed
|
||||||
|
64e718c9-ff99-47f1-8ca3-950c850777d4;;2019-01-30;BOB;;2;EUR;processing
|
||||||
|
1af3322d-3cb1-46be-b312-0ae9ec311537;;2019-03-16;BOB;;9;EUR;completed
|
||||||
|
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "deploy",
|
|
||||||
"dependencies": {
|
|
||||||
"@sap/hdi-deploy": "^3.8.2"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": "^12"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"start": "node node_modules/@sap/hdi-deploy/deploy.js"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +1,50 @@
|
|||||||
namespace sap.capire.bookshop;
|
namespace sap.capire.bookshop;
|
||||||
using { Currency, managed, cuid } from '@sap/cds/common';
|
|
||||||
|
using {
|
||||||
|
Currency,
|
||||||
|
managed,
|
||||||
|
cuid
|
||||||
|
} from '@sap/cds/common';
|
||||||
|
|
||||||
|
type Status : String enum {
|
||||||
|
completed;
|
||||||
|
processing;
|
||||||
|
blocked;
|
||||||
|
}
|
||||||
|
|
||||||
entity Books : managed {
|
entity Books : managed {
|
||||||
key ID : Integer;
|
key ID : Integer;
|
||||||
title : localized String(111);
|
title : localized String(111);
|
||||||
descr : localized String(1111);
|
descr : localized String(1111);
|
||||||
author : Association to Authors;
|
author : Association to Authors;
|
||||||
stock : Integer;
|
stock : Integer;
|
||||||
price : Decimal(9,2);
|
price : Decimal(9, 2);
|
||||||
currency : Currency;
|
currency : Currency;
|
||||||
}
|
}
|
||||||
|
|
||||||
entity Authors : managed {
|
entity Authors : managed {
|
||||||
key ID : Integer;
|
key ID : Integer;
|
||||||
name : String(111);
|
name : String(111);
|
||||||
dateOfBirth : Date;
|
dateOfBirth : Date;
|
||||||
dateOfDeath : Date;
|
dateOfDeath : Date;
|
||||||
placeOfBirth : String;
|
placeOfBirth : String;
|
||||||
placeOfDeath : String;
|
placeOfDeath : String;
|
||||||
books : Association to many Books on books.author = $self;
|
books : Association to many Books
|
||||||
|
on books.author = $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
entity Orders : cuid, managed {
|
entity Orders : cuid, managed {
|
||||||
OrderNo : String @title:'Order Number'; //> readable key
|
OrderNo : String @title : 'Order Number'; //> readable key
|
||||||
Items : Composition of many OrderItems on Items.parent = $self;
|
status : Status default 'processing';
|
||||||
total : Decimal(9,2) @readonly;
|
Items : Composition of many OrderItems
|
||||||
|
on Items.parent = $self;
|
||||||
|
total : Decimal(9, 2)@readonly;
|
||||||
currency : Currency;
|
currency : Currency;
|
||||||
}
|
}
|
||||||
|
|
||||||
entity OrderItems : cuid {
|
entity OrderItems : cuid {
|
||||||
parent : Association to Orders;
|
parent : Association to Orders;
|
||||||
book : Association to Books;
|
book : Association to Books;
|
||||||
amount : Integer;
|
amount : Integer;
|
||||||
netAmount : Decimal(9,2);
|
netAmount : Decimal(9, 2);
|
||||||
}
|
}
|
||||||
@@ -1,136 +0,0 @@
|
|||||||
{
|
|
||||||
"file_suffixes": {
|
|
||||||
"csv": {
|
|
||||||
"plugin_name": "com.sap.hana.di.tabledata.source"
|
|
||||||
},
|
|
||||||
"hdbafllangprocedure": {
|
|
||||||
"plugin_name": "com.sap.hana.di.afllangprocedure"
|
|
||||||
},
|
|
||||||
"hdbanalyticprivilege": {
|
|
||||||
"plugin_name": "com.sap.hana.di.analyticprivilege"
|
|
||||||
},
|
|
||||||
"hdbcalculationview": {
|
|
||||||
"plugin_name": "com.sap.hana.di.calculationview"
|
|
||||||
},
|
|
||||||
"hdbcollection": {
|
|
||||||
"plugin_name": "com.sap.hana.di.collection"
|
|
||||||
},
|
|
||||||
"hdbconstraint": {
|
|
||||||
"plugin_name": "com.sap.hana.di.constraint"
|
|
||||||
},
|
|
||||||
"hdbdropcreatetable": {
|
|
||||||
"plugin_name": "com.sap.hana.di.dropcreatetable"
|
|
||||||
},
|
|
||||||
"hdbflowgraph": {
|
|
||||||
"plugin_name": "com.sap.hana.di.flowgraph"
|
|
||||||
},
|
|
||||||
"hdbfunction": {
|
|
||||||
"plugin_name": "com.sap.hana.di.function"
|
|
||||||
},
|
|
||||||
"hdbgraphworkspace": {
|
|
||||||
"plugin_name": "com.sap.hana.di.graphworkspace"
|
|
||||||
},
|
|
||||||
"hdbhadoopmrjob": {
|
|
||||||
"plugin_name": "com.sap.hana.di.virtualfunctionpackage.hadoop"
|
|
||||||
},
|
|
||||||
"hdbindex": {
|
|
||||||
"plugin_name": "com.sap.hana.di.index"
|
|
||||||
},
|
|
||||||
"hdblibrary": {
|
|
||||||
"plugin_name": "com.sap.hana.di.library"
|
|
||||||
},
|
|
||||||
"hdbmigrationtable": {
|
|
||||||
"plugin_name": "com.sap.hana.di.table.migration"
|
|
||||||
},
|
|
||||||
"hdbprocedure": {
|
|
||||||
"plugin_name": "com.sap.hana.di.procedure"
|
|
||||||
},
|
|
||||||
"hdbprojectionview": {
|
|
||||||
"plugin_name": "com.sap.hana.di.projectionview"
|
|
||||||
},
|
|
||||||
"hdbprojectionviewconfig": {
|
|
||||||
"plugin_name": "com.sap.hana.di.projectionview.config"
|
|
||||||
},
|
|
||||||
"hdbreptask": {
|
|
||||||
"plugin_name": "com.sap.hana.di.reptask"
|
|
||||||
},
|
|
||||||
"hdbresultcache": {
|
|
||||||
"plugin_name": "com.sap.hana.di.resultcache"
|
|
||||||
},
|
|
||||||
"hdbrole": {
|
|
||||||
"plugin_name": "com.sap.hana.di.role"
|
|
||||||
},
|
|
||||||
"hdbroleconfig": {
|
|
||||||
"plugin_name": "com.sap.hana.di.role.config"
|
|
||||||
},
|
|
||||||
"hdbsearchruleset": {
|
|
||||||
"plugin_name": "com.sap.hana.di.searchruleset"
|
|
||||||
},
|
|
||||||
"hdbsequence": {
|
|
||||||
"plugin_name": "com.sap.hana.di.sequence"
|
|
||||||
},
|
|
||||||
"hdbstatistics": {
|
|
||||||
"plugin_name": "com.sap.hana.di.statistics"
|
|
||||||
},
|
|
||||||
"hdbstructuredprivilege": {
|
|
||||||
"plugin_name": "com.sap.hana.di.structuredprivilege"
|
|
||||||
},
|
|
||||||
"hdbsynonym": {
|
|
||||||
"plugin_name": "com.sap.hana.di.synonym"
|
|
||||||
},
|
|
||||||
"hdbsynonymconfig": {
|
|
||||||
"plugin_name": "com.sap.hana.di.synonym.config"
|
|
||||||
},
|
|
||||||
"hdbsystemversioning": {
|
|
||||||
"plugin_name": "com.sap.hana.di.systemversioning"
|
|
||||||
},
|
|
||||||
"hdbtable": {
|
|
||||||
"plugin_name": "com.sap.hana.di.table"
|
|
||||||
},
|
|
||||||
"hdbtabledata": {
|
|
||||||
"plugin_name": "com.sap.hana.di.tabledata"
|
|
||||||
},
|
|
||||||
"hdbtabletype": {
|
|
||||||
"plugin_name": "com.sap.hana.di.tabletype"
|
|
||||||
},
|
|
||||||
"hdbtrigger": {
|
|
||||||
"plugin_name": "com.sap.hana.di.trigger"
|
|
||||||
},
|
|
||||||
"hdbview": {
|
|
||||||
"plugin_name": "com.sap.hana.di.view"
|
|
||||||
},
|
|
||||||
"hdbvirtualfunction": {
|
|
||||||
"plugin_name": "com.sap.hana.di.virtualfunction"
|
|
||||||
},
|
|
||||||
"hdbvirtualfunctionconfig": {
|
|
||||||
"plugin_name": "com.sap.hana.di.virtualfunction.config"
|
|
||||||
},
|
|
||||||
"hdbvirtualpackagehadoop": {
|
|
||||||
"plugin_name": "com.sap.hana.di.virtualpackage.hadoop"
|
|
||||||
},
|
|
||||||
"hdbvirtualpackagesparksql": {
|
|
||||||
"plugin_name": "com.sap.hana.di.virtualpackage.sparksql"
|
|
||||||
},
|
|
||||||
"hdbvirtualprocedure": {
|
|
||||||
"plugin_name": "com.sap.hana.di.virtualprocedure"
|
|
||||||
},
|
|
||||||
"hdbvirtualprocedureconfig": {
|
|
||||||
"plugin_name": "com.sap.hana.di.virtualprocedure.config"
|
|
||||||
},
|
|
||||||
"hdbvirtualtable": {
|
|
||||||
"plugin_name": "com.sap.hana.di.virtualtable"
|
|
||||||
},
|
|
||||||
"hdbvirtualtableconfig": {
|
|
||||||
"plugin_name": "com.sap.hana.di.virtualtable.config"
|
|
||||||
},
|
|
||||||
"properties": {
|
|
||||||
"plugin_name": "com.sap.hana.di.tabledata.properties"
|
|
||||||
},
|
|
||||||
"tags": {
|
|
||||||
"plugin_name": "com.sap.hana.di.tabledata.properties"
|
|
||||||
},
|
|
||||||
"txt": {
|
|
||||||
"plugin_name": "com.sap.hana.di.copyonly"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
####### Generated mta.yaml based on template version 0.2.0
|
|
||||||
####### appName = capire-bookshop
|
|
||||||
####### language=nodejs; multiTenant=
|
|
||||||
####### approuter=
|
|
||||||
_schema-version: '3.1'
|
|
||||||
ID: sap.capire-bookshop
|
|
||||||
version: 1.0.0
|
|
||||||
description: "A simple bookshop application, build in a self-contained all-in-one fashion, i.e. w/o reusing other packages."
|
|
||||||
|
|
||||||
build-parameters:
|
|
||||||
before-all:
|
|
||||||
- builder: custom
|
|
||||||
commands:
|
|
||||||
- npm install
|
|
||||||
- cds build/all
|
|
||||||
|
|
||||||
parameters:
|
|
||||||
enable-parallel-deployments: true
|
|
||||||
|
|
||||||
modules:
|
|
||||||
############## SERVER MODULE ##########################
|
|
||||||
- name: capire-bookshop-srv
|
|
||||||
type: nodejs
|
|
||||||
path: gen/srv
|
|
||||||
properties:
|
|
||||||
EXIT: 1 # required by deploy.js task to terminate
|
|
||||||
|
|
||||||
|
|
||||||
requires:
|
|
||||||
#### Resources extracted from CAP configuration ####
|
|
||||||
- name: capire-bookshop-db
|
|
||||||
- name: capire-bookshop-uaa
|
|
||||||
|
|
||||||
provides:
|
|
||||||
- name: srv-binding # required by consumers of CAP services (e.g. approuter)
|
|
||||||
properties:
|
|
||||||
srv-url: ${default-url}
|
|
||||||
|
|
||||||
############################################################
|
|
||||||
|
|
||||||
############## SIDECAR MODULE #########################
|
|
||||||
- name: db
|
|
||||||
|
|
||||||
type: hdb
|
|
||||||
path: gen/db
|
|
||||||
parameters:
|
|
||||||
app-name: capire-bookshop-db
|
|
||||||
requires:
|
|
||||||
#### Hana and xsuaa resources extracted from CAP configuration ####
|
|
||||||
- name: capire-bookshop-db
|
|
||||||
- name: capire-bookshop-uaa
|
|
||||||
############################################################
|
|
||||||
|
|
||||||
############## APP #########################
|
|
||||||
- name: capire-bookshop-app
|
|
||||||
type: nodejs
|
|
||||||
path: gen/app
|
|
||||||
parameters:
|
|
||||||
memory: 256M
|
|
||||||
build-parameters:
|
|
||||||
requires:
|
|
||||||
- name: capire-bookshop-srv
|
|
||||||
requires:
|
|
||||||
- name: capire-bookshop-uaa
|
|
||||||
- name: srv-binding
|
|
||||||
group: destinations
|
|
||||||
properties:
|
|
||||||
forwardAuthToken: true
|
|
||||||
name: srv-binding
|
|
||||||
url: ~{srv-url}
|
|
||||||
|
|
||||||
############## RESOURCES ##################################
|
|
||||||
resources:
|
|
||||||
##### Services extracted from CAP configuration ####
|
|
||||||
##### 'service-plan' can be configured via 'cds.requires.<name>.vcap.plan'
|
|
||||||
- name: capire-bookshop-db
|
|
||||||
type: com.sap.xs.hdi-container
|
|
||||||
|
|
||||||
parameters:
|
|
||||||
service: hanatrial
|
|
||||||
properties:
|
|
||||||
hdi-service-name: ${service-name} # required for Java case
|
|
||||||
- name: capire-bookshop-uaa
|
|
||||||
|
|
||||||
type: org.cloudfoundry.managed-service
|
|
||||||
parameters:
|
|
||||||
##### Path to xs-security.json to add roles and scopes ####
|
|
||||||
path: ./xs-security.json
|
|
||||||
service: xsuaa
|
|
||||||
service-plan: application
|
|
||||||
config:
|
|
||||||
xsappname: capire-bookshop-${space} # name + space dependency
|
|
||||||
tenant-mode: dedicated
|
|
||||||
############################################################
|
|
||||||
@@ -1,29 +1,25 @@
|
|||||||
{
|
{
|
||||||
"name": "@sap/capire-bookshop",
|
"name": "@sap/capire-bookshop",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "A simple bookshop application, build in a self-contained all-in-one fashion, i.e. w/o reusing other packages.",
|
"description": "A simple bookshop application, build in a self-contained all-in-one fashion, i.e. w/o reusing other packages.",
|
||||||
"license": "SAP SAMPLE CODE LICENSE",
|
"license": "SAP SAMPLE CODE LICENSE",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sap/cds": "^4",
|
"@sap/cds": "^3",
|
||||||
"express": "^4",
|
"express": "^4",
|
||||||
"hdb": "^0.18.1",
|
"@sap/xb-msg-amqp-v100": "^0.9.35"
|
||||||
"passport": "^0.4.1"
|
},
|
||||||
},
|
"devDependencies": {
|
||||||
"scripts": {
|
"sqlite3": "^4.1.1"
|
||||||
"start": "cds run --in-memory?",
|
},
|
||||||
"watch": "cds watch"
|
"scripts": {
|
||||||
},
|
"start": "npx cds run"
|
||||||
"cds": {
|
},
|
||||||
"requires": {
|
"cds": {
|
||||||
"db": {
|
"requires": {
|
||||||
"kind": "sql",
|
"API_BUSINESS_PARTNER": {
|
||||||
"[production]": {
|
"kind": "odata",
|
||||||
"kind": "hana"
|
"model": "srv/external/API_BUSINESS_PARTNER"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"uaa": {
|
|
||||||
"kind": "xsuaa"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -14,7 +14,3 @@ annotate AdminService.Orders with @odata.draft.enabled;
|
|||||||
extend service AdminService with {
|
extend service AdminService with {
|
||||||
entity OrderItems as select from my.OrderItems;
|
entity OrderItems as select from my.OrderItems;
|
||||||
}
|
}
|
||||||
// Restrict access to orders to users with role "admin"
|
|
||||||
annotate AdminService.Orders with @(restrict: [
|
|
||||||
{ grant: 'READ', to: 'admin' }
|
|
||||||
]);
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
/** Service implementation for AdminService */
|
|
||||||
module.exports = cds.service.impl(function() {
|
|
||||||
this.before ('CREATE', 'Orders', _checkOrderCreateAuth)
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
/** Check authorization */
|
|
||||||
function _checkOrderCreateAuth (req) {
|
|
||||||
req.user.currency[0] === req.data.currency_code || req.reject(403)
|
|
||||||
}
|
|
||||||
@@ -8,10 +8,6 @@ service CatalogService {
|
|||||||
} excluding { createdBy, modifiedBy };
|
} excluding { createdBy, modifiedBy };
|
||||||
|
|
||||||
@requires_: 'authenticated-user'
|
@requires_: 'authenticated-user'
|
||||||
entity Orders as projection on my.Orders;
|
@insertonly entity Orders as projection on my.Orders;
|
||||||
|
|
||||||
}
|
}
|
||||||
// Example for an instance restriction
|
|
||||||
annotate CatalogService.Orders with @(restrict: [
|
|
||||||
{ grant: 'READ', where: 'currency_code = $user.currency' }
|
|
||||||
]);
|
|
||||||
@@ -1,33 +1,26 @@
|
|||||||
const cds = require('@sap/cds')
|
const cds = require('@sap/cds')
|
||||||
const { Books } = cds.entities
|
|
||||||
|
|
||||||
/** Service implementation for CatalogService */
|
/** Service implementation for CatalogService */
|
||||||
module.exports = cds.service.impl(function() {
|
module.exports = cds.service.impl(function () {
|
||||||
this.after ('READ', 'Books', each => each.stock > 111 && _addDiscount2(each,11))
|
const { Books, Orders } = this.entities
|
||||||
this.before ('CREATE', 'Orders', _reduceStock)
|
this.after('READ', Books, each => each.stock > 111 && _addDiscount2(each, 11))
|
||||||
|
this.before('CREATE', Orders, _reduceStock)
|
||||||
|
|
||||||
|
/** Add some discount for overstocked books */
|
||||||
|
function _addDiscount2(each, discount) {
|
||||||
|
each.title += ` -- ${discount}% discount!`
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Reduce stock of ordered books if available stock suffices */
|
||||||
|
async function _reduceStock(req) {
|
||||||
|
const { Items: OrderItems } = req.data
|
||||||
|
return cds.transaction(req).run(() => OrderItems.map(order =>
|
||||||
|
UPDATE(Books).set('stock -=', order.amount)
|
||||||
|
.where('ID =', order.book_ID).and('stock >=', order.amount)
|
||||||
|
)).then(all => all.forEach((affectedRows, i) => {
|
||||||
|
if (affectedRows === 0) req.error(409,
|
||||||
|
`${OrderItems[i].amount} exceeds stock for book #${OrderItems[i].book_ID}`
|
||||||
|
)
|
||||||
|
}))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
/** Add some discount for overstocked books */
|
|
||||||
function _addDiscount2 (each,discount) {
|
|
||||||
each.title += ` -- ${discount}% discount!`
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Reduce stock of ordered books if available stock suffices */
|
|
||||||
async function _reduceStock (req) {
|
|
||||||
const { Items: orderItems } = req.data
|
|
||||||
if (!Array.isArray(orderItems)) return
|
|
||||||
|
|
||||||
const all = await cds.transaction(req).run(orderItems.map(item =>
|
|
||||||
UPDATE(Books)
|
|
||||||
.set('stock -=', item.amount)
|
|
||||||
.where('ID =', item.book_ID).and('stock >=', item.amount)
|
|
||||||
))
|
|
||||||
all.forEach((affectedRows, i) => {
|
|
||||||
if (affectedRows === 0) {
|
|
||||||
req.error(409, `${orderItems[i].amount} exceeds stock for book #${orderItems[i].book_ID}`)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return all
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
2426
packages/bookshop/srv/external/API_BUSINESS_PARTNER.csn
vendored
Normal file
2426
packages/bookshop/srv/external/API_BUSINESS_PARTNER.csn
vendored
Normal file
File diff suppressed because it is too large
Load Diff
3261
packages/bookshop/srv/external/API_BUSINESS_PARTNER.edmx
vendored
Normal file
3261
packages/bookshop/srv/external/API_BUSINESS_PARTNER.edmx
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,37 +0,0 @@
|
|||||||
{
|
|
||||||
"xsappname": "capire-bookshop",
|
|
||||||
"tenant-mode": "dedicated",
|
|
||||||
"scopes": [
|
|
||||||
{
|
|
||||||
"name": "$XSAPPNAME.admin",
|
|
||||||
"description": "admin"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"attributes": [
|
|
||||||
{
|
|
||||||
"name": "currency",
|
|
||||||
"description": "currency",
|
|
||||||
"valueType": "s",
|
|
||||||
"valueRequired": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"role-templates": [
|
|
||||||
{
|
|
||||||
"name": "admin",
|
|
||||||
"description": "generated",
|
|
||||||
"scope-references": [
|
|
||||||
"$XSAPPNAME.admin"
|
|
||||||
],
|
|
||||||
"attribute-references": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "userattributes",
|
|
||||||
"description": "generated",
|
|
||||||
"default-role-name": "Attributes of a User",
|
|
||||||
"scope-references": [],
|
|
||||||
"attribute-references": [
|
|
||||||
"currency"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user