Compare commits
6 Commits
performanc
...
audit-log-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
08a3157f1d | ||
|
|
c9ecef4e21 | ||
|
|
46f1be4395 | ||
|
|
b932637400 | ||
|
|
3c6d49b88e | ||
|
|
6928ae907a |
8
.github/dependabot.yml
vendored
8
.github/dependabot.yml
vendored
@@ -1,8 +0,0 @@
|
|||||||
version: 2
|
|
||||||
|
|
||||||
updates:
|
|
||||||
- package-ecosystem: npm
|
|
||||||
directory: /
|
|
||||||
versioning-strategy: increase-if-necessary
|
|
||||||
schedule:
|
|
||||||
interval: daily
|
|
||||||
@@ -16,8 +16,7 @@ app.use('/-/:tarball', (req,res,next) => {
|
|||||||
console.debug ('GET', req.params)
|
console.debug ('GET', req.params)
|
||||||
try {
|
try {
|
||||||
const { tarball } = req.params
|
const { tarball } = req.params
|
||||||
const pkgFull = tarball.substring(0, tarball.lastIndexOf('-'))
|
const [, pkg ] = /^\w+-(\w+)/.exec(tarball)
|
||||||
const [, pkg ] = /^\w+-(.+)/.exec(pkgFull)
|
|
||||||
fs.lstat(tarball,(err => {
|
fs.lstat(tarball,(err => {
|
||||||
if (err) console.debug (`npm pack ../${pkg}`)
|
if (err) console.debug (`npm pack ../${pkg}`)
|
||||||
if (err) exec(`npm pack ../${pkg}`,{cwd},next)
|
if (err) exec(`npm pack ../${pkg}`,{cwd},next)
|
||||||
@@ -32,7 +31,7 @@ app.use('/-/:tarball', (req,res,next) => {
|
|||||||
app.use('/-', express.static(__dirname))
|
app.use('/-', express.static(__dirname))
|
||||||
|
|
||||||
app.get('/*', (req,res)=>{
|
app.get('/*', (req,res)=>{
|
||||||
const urlRegex = /^\/(@[\w-]+)\/(.+)/
|
const urlRegex = /^\/(@\w+)\/(\w+)/
|
||||||
const url = decodeURIComponent(req.url)
|
const url = decodeURIComponent(req.url)
|
||||||
console.debug ('GET',url)
|
console.debug ('GET',url)
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -3,15 +3,14 @@ const $ = sel => document.querySelector(sel)
|
|||||||
const GET = (url) => axios.get('/browse'+url)
|
const GET = (url) => axios.get('/browse'+url)
|
||||||
const POST = (cmd,data) => axios.post('/browse'+cmd,data)
|
const POST = (cmd,data) => axios.post('/browse'+cmd,data)
|
||||||
|
|
||||||
const books = Vue.createApp ({
|
const books = new Vue ({
|
||||||
|
|
||||||
data() {
|
el:'#app',
|
||||||
return {
|
|
||||||
|
data: {
|
||||||
list: [],
|
list: [],
|
||||||
book: undefined,
|
book: undefined,
|
||||||
order: { quantity:1, succeeded:'', failed:'' },
|
order: { quantity:1, succeeded:'', failed:'' }
|
||||||
user: {}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
@@ -38,24 +37,12 @@ const books = Vue.createApp ({
|
|||||||
book.stock = res.data.stock
|
book.stock = res.data.stock
|
||||||
books.order = { quantity, succeeded: `Successfully ordered ${quantity} item(s).` }
|
books.order = { quantity, succeeded: `Successfully ordered ${quantity} item(s).` }
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
books.order = { quantity, failed: e.response.data.error ? e.response.data.error.message : e.response.data }
|
books.order = { quantity, failed: e.response.data.error.message }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
async fetchUserInfo() {
|
|
||||||
try {
|
|
||||||
const { data } = await axios.get('/user/me')
|
|
||||||
books.user = data
|
|
||||||
} catch (err) { books.user = { id: err.message } }
|
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
}).mount("#app")
|
|
||||||
|
|
||||||
// initially fill list of books
|
// initially fill list of books
|
||||||
books.fetch()
|
books.fetch()
|
||||||
|
|
||||||
books.fetchUserInfo()
|
|
||||||
document.addEventListener('keydown', (event) => {
|
|
||||||
// hide user info on request
|
|
||||||
if (event.key === 'u') books.user = undefined
|
|
||||||
})
|
|
||||||
|
|||||||
@@ -5,26 +5,19 @@
|
|||||||
<title> Capire Books </title>
|
<title> Capire Books </title>
|
||||||
<link rel="stylesheet" href="https://unpkg.com/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"></script>
|
||||||
<style>
|
<style>
|
||||||
.hovering tr:hover td { color:cyan; background: #123; cursor: pointer; }
|
.hovering tr:hover td { color:cyan; background: #123; cursor: pointer; }
|
||||||
.rating-stars { color:teal }
|
.rating-stars { color:teal }
|
||||||
.succeeded { color:teal }
|
.succeeded { color:teal }
|
||||||
.failed { color:red }
|
.failed { color:red }
|
||||||
.user {text-align: end; color: grey;}
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="small-container", style="margin-top: 70px;">
|
<body class="small-container", style="margin-top: 70px;">
|
||||||
<div id='app'>
|
<div id='app'>
|
||||||
|
|
||||||
<div v-if="user" class="user">
|
<h1> {{ document.title }} </h1>
|
||||||
<div>User: {{ user.id || 'anonymous' }}</div>
|
|
||||||
<div>Locale: {{ user.locale }}</div>
|
|
||||||
<div v-if="user.tenant">Tenant: {{ user.tenant }}</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h1> Capire Books </h1>
|
|
||||||
|
|
||||||
<input type="text" placeholder="Search..." @input="search">
|
<input type="text" placeholder="Search..." @input="search">
|
||||||
|
|
||||||
|
|||||||
1226
bookshop/package-lock.json
generated
1226
bookshop/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -2,17 +2,10 @@
|
|||||||
"name": "@capire/bookshop",
|
"name": "@capire/bookshop",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "A simple self-contained bookshop service.",
|
"description": "A simple self-contained bookshop service.",
|
||||||
"files": [
|
|
||||||
"app",
|
|
||||||
"srv",
|
|
||||||
"db",
|
|
||||||
"index.cds",
|
|
||||||
"index.js"
|
|
||||||
],
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sap/cds": "^6.1.1",
|
"@sap/cds": "^5.0.4",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"passport": ">=0.4.1"
|
"passport": "0.4.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"genres": "cds serve test/genres.cds",
|
"genres": "cds serve test/genres.cds",
|
||||||
@@ -22,10 +15,7 @@
|
|||||||
"cds": {
|
"cds": {
|
||||||
"requires": {
|
"requires": {
|
||||||
"db": {
|
"db": {
|
||||||
"kind": "sqlite",
|
"kind": "sql"
|
||||||
"credentials": {
|
|
||||||
"database": "sqlite.db"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -1,16 +0,0 @@
|
|||||||
/**
|
|
||||||
* Exposes user information
|
|
||||||
*/
|
|
||||||
@requires: 'authenticated-user'
|
|
||||||
service UserService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The current user
|
|
||||||
*/
|
|
||||||
@odata.singleton entity me {
|
|
||||||
id : String; // user id
|
|
||||||
locale : String;
|
|
||||||
tenant : String;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
const cds = require('@sap/cds')
|
|
||||||
module.exports = cds.service.impl((srv) => {
|
|
||||||
srv.on('READ', 'me', ({ tenant, user, locale }) => ({ id: user.id, locale, tenant }))
|
|
||||||
})
|
|
||||||
@@ -16,9 +16,9 @@ GET {{server}}/browse/$metadata
|
|||||||
|
|
||||||
### ------------------------------------------------------------------------
|
### ------------------------------------------------------------------------
|
||||||
# Browse Books as any user
|
# Browse Books as any user
|
||||||
GET {{server}}/browse/ListOfBooks?
|
GET {{server}}/browse/Books?
|
||||||
# &$select=title,stock
|
# &$select=title,stock
|
||||||
&$expand=genre
|
# &$expand=currency
|
||||||
# &sap-language=de
|
# &sap-language=de
|
||||||
{{me}}
|
{{me}}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
"@capire/orders": "*",
|
"@capire/orders": "*",
|
||||||
"@capire/common": "*",
|
"@capire/common": "*",
|
||||||
"@capire/data-viewer": "*",
|
"@capire/data-viewer": "*",
|
||||||
"@sap/cds": ">=5",
|
"@sap/cds": "^5",
|
||||||
"express": "^4.17.1"
|
"express": "^4.17.1"
|
||||||
},
|
},
|
||||||
"cds": {
|
"cds": {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"description": "A generic browser for data",
|
"description": "A generic browser for data",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sap/cds": ">=5.0.4"
|
"@sap/cds": "^5.0.4"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"app",
|
"app",
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
},
|
},
|
||||||
"dataSources": {
|
"dataSources": {
|
||||||
"AdminService": {
|
"AdminService": {
|
||||||
"uri": "admin/",
|
"uri": "/admin/",
|
||||||
"type": "OData",
|
"type": "OData",
|
||||||
"settings": {
|
"settings": {
|
||||||
"odataVersion": "4.0"
|
"odataVersion": "4.0"
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
"i18n": "i18n/i18n.properties",
|
"i18n": "i18n/i18n.properties",
|
||||||
"dataSources": {
|
"dataSources": {
|
||||||
"AdminService": {
|
"AdminService": {
|
||||||
"uri": "admin/",
|
"uri": "/admin/",
|
||||||
"type": "OData",
|
"type": "OData",
|
||||||
"settings": {
|
"settings": {
|
||||||
"odataVersion": "4.0"
|
"odataVersion": "4.0"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
},
|
},
|
||||||
"dataSources": {
|
"dataSources": {
|
||||||
"CatalogService": {
|
"CatalogService": {
|
||||||
"uri": "browse/",
|
"uri": "/browse/",
|
||||||
"type": "OData",
|
"type": "OData",
|
||||||
"settings": {
|
"settings": {
|
||||||
"odataVersion": "4.0"
|
"odataVersion": "4.0"
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<script id="sap-ui-bootstrap" src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
|
<script id="sap-ui-bootstrap" 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_horizon"
|
data-sap-ui-theme="sap_fiori_3"
|
||||||
data-sap-ui-frameOptions="allow"
|
data-sap-ui-frameOptions="allow"
|
||||||
></script>
|
></script>
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@capire/bookstore": "*",
|
"@capire/bookstore": "*",
|
||||||
"@sap/cds": ">=5",
|
"@sap/cds": "^5",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"passport": ">=0.4.1"
|
"passport": "^0.4.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "cds run --in-memory?",
|
"start": "cds run --in-memory?",
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
"cds": {
|
"cds": {
|
||||||
"requires": {
|
"requires": {
|
||||||
"auth": {
|
"auth": {
|
||||||
"kind": "dummy-auth"
|
"strategy": "dummy"
|
||||||
},
|
},
|
||||||
"ReviewsService": {
|
"ReviewsService": {
|
||||||
"kind": "odata",
|
"kind": "odata",
|
||||||
|
|||||||
28
gdpr/.cdsrc.json
Normal file
28
gdpr/.cdsrc.json
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"build": {
|
||||||
|
"target": "gen",
|
||||||
|
"tasks": [{
|
||||||
|
"for": "hana",
|
||||||
|
"src": "db",
|
||||||
|
"options": {
|
||||||
|
"model": [
|
||||||
|
"db",
|
||||||
|
"srv",
|
||||||
|
"app"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"for": "node-cf",
|
||||||
|
"src": "srv",
|
||||||
|
"options": {
|
||||||
|
"model": [
|
||||||
|
"db",
|
||||||
|
"srv",
|
||||||
|
"app"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
4
gdpr/.etc/deploy.sh
Normal file
4
gdpr/.etc/deploy.sh
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
npm run build
|
||||||
|
cf create-service-push
|
||||||
|
cf bind-service gdpr-srv gdpr-pdm -c .pdm/pdm-binding-config.json
|
||||||
|
cf restage gdpr-srv
|
||||||
7
gdpr/.etc/undeploy.sh
Normal file
7
gdpr/.etc/undeploy.sh
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
cf delete gdpr-srv -f
|
||||||
|
cf delete gdpr-db-deployer -f
|
||||||
|
cf delete-service gdpr-pdm -f
|
||||||
|
cf delete-service gdpr-auditlog -f
|
||||||
|
cf delete-service gdpr-uaa -f
|
||||||
|
cf delete-service gdpr-hdi -f
|
||||||
|
cf delete-service gdpr-logs -f
|
||||||
16
gdpr/.pdm/pdm-binding-config.json
Normal file
16
gdpr/.pdm/pdm-binding-config.json
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"fullyQualifiedApplicationName": "capire-gdpr",
|
||||||
|
"fullyQualifiedModuleName": "gdpr-srv",
|
||||||
|
"applicationTitle": "Capire GDPR Sample App",
|
||||||
|
"applicationTitleKey": "Capire GDPR Sample App",
|
||||||
|
"applicationURL": "https://capire-gdpr-srv.cfapps.eu10.hana.ondemand.com",
|
||||||
|
"endPoints": [{
|
||||||
|
"type": "odatav4",
|
||||||
|
"serviceName": "PDMService",
|
||||||
|
"serviceURI": "/pdm",
|
||||||
|
"serviceTitle": "Capire GDPR Sample App PDM Service",
|
||||||
|
"serviceTitleKey": "Capire GDPR Sample App PDM Service",
|
||||||
|
"hasGdprV4Annotations": true,
|
||||||
|
"cacheControl": "no-cache"
|
||||||
|
}]
|
||||||
|
}
|
||||||
8
gdpr/.pdm/pdm-instance-config.json
Normal file
8
gdpr/.pdm/pdm-instance-config.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"xs-security": {
|
||||||
|
"xsappname": "capire-gdpr",
|
||||||
|
"authorities": ["$ACCEPT_GRANTED_AUTHORITIES"]
|
||||||
|
},
|
||||||
|
"fullyQualifiedApplicationName": "capire-gdpr",
|
||||||
|
"appConsentServiceEnabled": true
|
||||||
|
}
|
||||||
317
gdpr/app/fiori.cds
Normal file
317
gdpr/app/fiori.cds
Normal file
@@ -0,0 +1,317 @@
|
|||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Note: this is designed for the GDPRService being co-located with
|
||||||
|
// orders. It does not work if GDPRService is run as a separate
|
||||||
|
// process, and is not intended to do so.
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
using {GDPRService} from '../srv/gdpr-service';
|
||||||
|
|
||||||
|
annotate cds.UUID with @Core.Computed;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Orders
|
||||||
|
*/
|
||||||
|
@odata.draft.enabled
|
||||||
|
annotate GDPRService.Orders with @(UI : {
|
||||||
|
SelectionFields : [
|
||||||
|
createdAt,
|
||||||
|
createdBy
|
||||||
|
],
|
||||||
|
LineItem : [
|
||||||
|
{
|
||||||
|
Value : OrderNo,
|
||||||
|
Label : 'Order number'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Value : customer.firstName,
|
||||||
|
Label : 'First Name'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Value : customer.lastName,
|
||||||
|
Label : 'Last Name'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
HeaderInfo : {
|
||||||
|
TypeName : 'Order',
|
||||||
|
TypeNamePlural : 'Orders',
|
||||||
|
Title : {
|
||||||
|
Value : OrderNo,
|
||||||
|
Label : 'Order number'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Identification : [
|
||||||
|
{
|
||||||
|
Value : createdBy,
|
||||||
|
Label : 'Created by'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Value : createdAt,
|
||||||
|
Label : 'Created at'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
HeaderFacets : [
|
||||||
|
{
|
||||||
|
$Type : 'UI.ReferenceFacet',
|
||||||
|
Label : '{i18n>Created}',
|
||||||
|
Target : '@UI.FieldGroup#Created'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$Type : 'UI.ReferenceFacet',
|
||||||
|
Label : '{i18n>Modified}',
|
||||||
|
Target : '@UI.FieldGroup#Modified'
|
||||||
|
},
|
||||||
|
],
|
||||||
|
Facets : [
|
||||||
|
{
|
||||||
|
$Type : 'UI.ReferenceFacet',
|
||||||
|
Label : '{i18n>Details}',
|
||||||
|
Target : '@UI.FieldGroup#Details'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$Type : 'UI.ReferenceFacet',
|
||||||
|
Label : '{i18n>OrderItems}',
|
||||||
|
Target : 'Items/@UI.LineItem'
|
||||||
|
},
|
||||||
|
],
|
||||||
|
FieldGroup #Details : {Data : [
|
||||||
|
{
|
||||||
|
Value : customer_ID,
|
||||||
|
Label : 'Customer'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Value : customer.firstName,
|
||||||
|
Label : 'First Name'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Value : customer.lastName,
|
||||||
|
Label : 'Last Name'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Value : currency_code,
|
||||||
|
Label : 'Currency'
|
||||||
|
}
|
||||||
|
]},
|
||||||
|
FieldGroup #Created : {Data : [
|
||||||
|
{
|
||||||
|
Value : createdBy,
|
||||||
|
Label : 'Created by'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Value : createdAt,
|
||||||
|
Label : 'Created at'
|
||||||
|
}
|
||||||
|
]},
|
||||||
|
FieldGroup #Modified : {Data : [
|
||||||
|
{
|
||||||
|
Value : modifiedBy,
|
||||||
|
Label : 'Modified by'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Value : modifiedAt,
|
||||||
|
Label : 'Modified at'
|
||||||
|
}
|
||||||
|
]},
|
||||||
|
}, ) {
|
||||||
|
createdAt @UI.HiddenFilter : false;
|
||||||
|
createdBy @UI.HiddenFilter : false;
|
||||||
|
customer @ValueList.entity : 'Customers';
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO: Order Items are not really maintainable in Fiori preview app
|
||||||
|
*/
|
||||||
|
annotate GDPRService.Orders.Items with @(UI : {
|
||||||
|
LineItem : [
|
||||||
|
{
|
||||||
|
Value : product_ID,
|
||||||
|
Label : 'Product ID'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Value : title,
|
||||||
|
Label : 'Product Name'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Value : price,
|
||||||
|
Label : 'Price'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Value : quantity,
|
||||||
|
Label : 'Quantity'
|
||||||
|
},
|
||||||
|
],
|
||||||
|
Identification : [
|
||||||
|
{
|
||||||
|
Value : product_ID,
|
||||||
|
Label : 'Product ID'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Value : title,
|
||||||
|
Label : 'Product Name'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Value : quantity,
|
||||||
|
Label : 'Quantity'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Value : price,
|
||||||
|
Label : 'Price'
|
||||||
|
},
|
||||||
|
],
|
||||||
|
Facets : [{
|
||||||
|
$Type : 'UI.ReferenceFacet',
|
||||||
|
Label : 'Order Items',
|
||||||
|
Target : '@UI.Identification'
|
||||||
|
}, ],
|
||||||
|
}, ) {
|
||||||
|
ID @Core.Computed @UI.Hidden : true;
|
||||||
|
title @Core.Computed;
|
||||||
|
price @Core.Computed;
|
||||||
|
quantity @(Common.FieldControl : #Mandatory);
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Customers
|
||||||
|
*/
|
||||||
|
@odata.draft.enabled
|
||||||
|
annotate GDPRService.Customers with @(UI : {
|
||||||
|
SelectionFields : [
|
||||||
|
firstName,
|
||||||
|
lastName
|
||||||
|
],
|
||||||
|
LineItem : [
|
||||||
|
{
|
||||||
|
Value : firstName,
|
||||||
|
Label : 'First Name'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Value : lastName,
|
||||||
|
Label : 'Last Name'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Value : dateOfBirth,
|
||||||
|
Label : 'Date of Birth'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
HeaderInfo : {
|
||||||
|
TypeName : 'Customer',
|
||||||
|
TypeNamePlural : 'Customers',
|
||||||
|
Title : {
|
||||||
|
Value : lastName,
|
||||||
|
Label : 'Last Name'
|
||||||
|
},
|
||||||
|
Description : {
|
||||||
|
Value : firstName,
|
||||||
|
Label : 'First Name'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Identification : [
|
||||||
|
{
|
||||||
|
Value : createdBy,
|
||||||
|
Label : 'Created by'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Value : createdAt,
|
||||||
|
Label : 'Created at'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
HeaderFacets : [
|
||||||
|
{
|
||||||
|
$Type : 'UI.ReferenceFacet',
|
||||||
|
Label : '{i18n>Created}',
|
||||||
|
Target : '@UI.FieldGroup#Created'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$Type : 'UI.ReferenceFacet',
|
||||||
|
Label : '{i18n>Modified}',
|
||||||
|
Target : '@UI.FieldGroup#Modified'
|
||||||
|
},
|
||||||
|
],
|
||||||
|
Facets : [
|
||||||
|
{
|
||||||
|
$Type : 'UI.ReferenceFacet',
|
||||||
|
Label : '{i18n>Details}',
|
||||||
|
Target : '@UI.FieldGroup#Details'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$Type : 'UI.ReferenceFacet',
|
||||||
|
Label : '{i18n>Addresses}',
|
||||||
|
Target : 'addresses/@UI.LineItem'
|
||||||
|
},
|
||||||
|
],
|
||||||
|
FieldGroup #Details : {Data : [
|
||||||
|
{
|
||||||
|
Value : dateOfBirth,
|
||||||
|
Label : 'Date of Birth'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Value : email,
|
||||||
|
Label : 'E-Mail'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Value : creditCardNo,
|
||||||
|
Label : 'Credit Card Number'
|
||||||
|
}
|
||||||
|
]},
|
||||||
|
FieldGroup #Created : {Data : [
|
||||||
|
{
|
||||||
|
Value : createdBy,
|
||||||
|
Label : 'Created by'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Value : createdAt,
|
||||||
|
Label : 'Created at'
|
||||||
|
}
|
||||||
|
]},
|
||||||
|
FieldGroup #Modified : {Data : [
|
||||||
|
{
|
||||||
|
Value : modifiedBy,
|
||||||
|
Label : 'Modified by'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Value : modifiedAt,
|
||||||
|
Label : 'Modified at'
|
||||||
|
}
|
||||||
|
]},
|
||||||
|
}, ) {
|
||||||
|
createdAt @UI.HiddenFilter : false;
|
||||||
|
createdBy @UI.HiddenFilter : false;
|
||||||
|
};
|
||||||
|
|
||||||
|
annotate GDPRService.CustomerPostalAddresses with @(UI : {
|
||||||
|
LineItem : [
|
||||||
|
{
|
||||||
|
Value : town,
|
||||||
|
Label : 'Town'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Value : street,
|
||||||
|
Label : 'Street'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Value : country.name,
|
||||||
|
Label : 'Country'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
Identification : [
|
||||||
|
{
|
||||||
|
Value : town,
|
||||||
|
Label : 'Town'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Value : street,
|
||||||
|
Label : 'Street'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Value : country_code,
|
||||||
|
Label : 'Country Code'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
Facets : [{
|
||||||
|
$Type : 'UI.ReferenceFacet',
|
||||||
|
Label : 'Customer Postal Address',
|
||||||
|
Target : '@UI.Identification'
|
||||||
|
}, ],
|
||||||
|
}, );
|
||||||
56
gdpr/db/data-privacy.cds
Normal file
56
gdpr/db/data-privacy.cds
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
using {sap.capire.orders} from '@capire/orders';
|
||||||
|
using {sap.capire.gdpr} from './schema';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* annotations for Data Privacy (Personal Data Manager and Audit Logging)
|
||||||
|
*/
|
||||||
|
annotate gdpr.Customers with @PersonalData : {
|
||||||
|
DataSubjectRole : 'Customer',
|
||||||
|
EntitySemantics : 'DataSubject'
|
||||||
|
}{
|
||||||
|
ID @PersonalData.FieldSemantics : 'DataSubjectID';
|
||||||
|
email @PersonalData.IsPotentiallyPersonal;
|
||||||
|
firstName @PersonalData.IsPotentiallyPersonal;
|
||||||
|
lastName @PersonalData.IsPotentiallyPersonal;
|
||||||
|
creditCardNo @PersonalData.IsPotentiallySensitive;
|
||||||
|
dateOfBirth @PersonalData.IsPotentiallyPersonal;
|
||||||
|
}
|
||||||
|
|
||||||
|
annotate gdpr.CustomerPostalAddresses with @PersonalData : {
|
||||||
|
DataSubjectRole : 'Customer',
|
||||||
|
EntitySemantics : 'DataSubjectDetails'
|
||||||
|
}{
|
||||||
|
customer @PersonalData.FieldSemantics : 'DataSubjectID';
|
||||||
|
street @PersonalData.IsPotentiallyPersonal;
|
||||||
|
town @PersonalData.IsPotentiallyPersonal;
|
||||||
|
country @PersonalData.IsPotentiallyPersonal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO: Personal Data Manager doesn't know EntitySemantics: 'Other' and FieldSemantics: 'ContractRelatedID'
|
||||||
|
* see: https://help.sap.com/viewer/620a3ea6aaf64610accdd05cca9e3de2/Cloud/en-US/5a55fae1eb7c496c92c56071186d76b3.html
|
||||||
|
*/
|
||||||
|
annotate orders.Orders with @PersonalData : {
|
||||||
|
DataSubjectRole : 'Customer',
|
||||||
|
EntitySemantics : 'LegalGround'
|
||||||
|
}{
|
||||||
|
ID @PersonalData.FieldSemantics : 'LegalGroundID';
|
||||||
|
customer @PersonalData.FieldSemantics : 'DataSubjectID';
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* additional annotations for Audit Logging
|
||||||
|
*/
|
||||||
|
annotate gdpr.Customers with @AuditLog.Operation : {
|
||||||
|
Read : true,
|
||||||
|
Insert : true,
|
||||||
|
Update : true,
|
||||||
|
Delete : true
|
||||||
|
};
|
||||||
|
|
||||||
|
annotate gdpr.CustomerPostalAddresses with @AuditLog.Operation : {
|
||||||
|
Read : true,
|
||||||
|
Insert : true,
|
||||||
|
Update : true,
|
||||||
|
Delete : true
|
||||||
|
};
|
||||||
3
gdpr/db/data/sap.capire.gdpr-CustomerPostalAddresses.csv
Normal file
3
gdpr/db/data/sap.capire.gdpr-CustomerPostalAddresses.csv
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
ID;modifiedAt;createdAt;createdBy;modifiedBy;customer_ID;street;town;country_code
|
||||||
|
1e2f2640-6866-4dcf-8f4d-3027aa831cad;2019-04-04;2019-01-31;admin@business.com;admin@business.com;8e2f2640-6866-4dcf-8f4d-3027aa831cad;Hauptstrasse 11;Berlin;DE
|
||||||
|
24e718c9-ff99-47f1-8ca3-950c850777d4;2019-04-04;2019-01-30;admin@business.com;admin@business.com;74e718c9-ff99-47f1-8ca3-950c850777d4;Main Street 22;London;GB
|
||||||
|
3
gdpr/db/data/sap.capire.gdpr-Customers.csv
Normal file
3
gdpr/db/data/sap.capire.gdpr-Customers.csv
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
ID;modifiedAt;createdAt;createdBy;modifiedBy;email;firstName;lastName;creditCardNo;dateOfBirth
|
||||||
|
8e2f2640-6866-4dcf-8f4d-3027aa831cad;2019-04-04;2019-01-31;admin@business.com;admin@business.com;john.doe@test.com;John;Doe;9977-6655-4433-2211;1970-01-01
|
||||||
|
74e718c9-ff99-47f1-8ca3-950c850777d4;2019-04-04;2019-01-30;admin@business.com;admin@business.com;jane.doe@sap.com;Jane;Doe;2211-3344-5566-7788;1980-11-11
|
||||||
|
4
gdpr/db/data/sap.capire.orders-Orders.Items.csv
Normal file
4
gdpr/db/data/sap.capire.orders-Orders.Items.csv
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
ID;up__ID;quantity;product_ID;title;price
|
||||||
|
4bd2c9df-c19f-47b8-a921-3cde0d863b52;29f15ef6-4a13-47d4-aef4-329a403b49eb;1;201;Wuthering Heights;11.11
|
||||||
|
6c42a40d-5f7c-4c2f-816b-a73c7c28d722;29f15ef6-4a13-47d4-aef4-329a403b49eb;1;271;Catweazle;15
|
||||||
|
748555fc-2cb0-42b5-a361-dd19a50bd682;31c2bd15-5146-4418-b574-866a08911de7;2;252;Eleonora;28
|
||||||
|
3
gdpr/db/data/sap.capire.orders-Orders.csv
Normal file
3
gdpr/db/data/sap.capire.orders-Orders.csv
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
ID;createdAt;createdBy;customer_ID;OrderNo;currency_code
|
||||||
|
29f15ef6-4a13-47d4-aef4-329a403b49eb;2019-01-31;john.doe@test.com;8e2f2640-6866-4dcf-8f4d-3027aa831cad;1;EUR
|
||||||
|
31c2bd15-5146-4418-b574-866a08911de7;2019-01-30;jane.doe@test.com;74e718c9-ff99-47f1-8ca3-950c850777d4;2;EUR
|
||||||
|
30
gdpr/db/schema.cds
Normal file
30
gdpr/db/schema.cds
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using {
|
||||||
|
Country,
|
||||||
|
managed,
|
||||||
|
cuid
|
||||||
|
} from '@sap/cds/common';
|
||||||
|
using {sap.capire.orders} from '@capire/orders';
|
||||||
|
|
||||||
|
namespace sap.capire.gdpr;
|
||||||
|
|
||||||
|
extend orders.Orders with {
|
||||||
|
customer : Association to Customers;
|
||||||
|
}
|
||||||
|
|
||||||
|
entity Customers : cuid, managed {
|
||||||
|
email : String;
|
||||||
|
firstName : String;
|
||||||
|
lastName : String;
|
||||||
|
creditCardNo : String;
|
||||||
|
dateOfBirth : Date;
|
||||||
|
addresses : Composition of many CustomerPostalAddresses
|
||||||
|
on addresses.customer = $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
entity CustomerPostalAddresses : cuid, managed {
|
||||||
|
customer : Association to Customers;
|
||||||
|
street : String(128);
|
||||||
|
town : String(128);
|
||||||
|
@assert.integrity : false
|
||||||
|
country : Country;
|
||||||
|
};
|
||||||
136
gdpr/db/src/.hdiconfig
Normal file
136
gdpr/db/src/.hdiconfig
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
31
gdpr/manifest.yml
Normal file
31
gdpr/manifest.yml
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
---
|
||||||
|
applications:
|
||||||
|
# -----------------------------------------------------------------------------------
|
||||||
|
# HANA Database Content Deployer App
|
||||||
|
# -----------------------------------------------------------------------------------
|
||||||
|
- name: gdpr-db-deployer
|
||||||
|
path: gen/db
|
||||||
|
no-route: true
|
||||||
|
health-check-type: process
|
||||||
|
memory: 256M
|
||||||
|
buildpack: nodejs_buildpack
|
||||||
|
services:
|
||||||
|
- gdpr-logs
|
||||||
|
- gdpr-hdi
|
||||||
|
# -----------------------------------------------------------------------------------
|
||||||
|
# Backend Service
|
||||||
|
# -----------------------------------------------------------------------------------
|
||||||
|
- name: gdpr-srv
|
||||||
|
path: gen/srv
|
||||||
|
memory: 256M
|
||||||
|
buildpack: nodejs_buildpack
|
||||||
|
routes:
|
||||||
|
- route: capire-gdpr-srv.cfapps.eu10.hana.ondemand.com
|
||||||
|
services:
|
||||||
|
- gdpr-logs
|
||||||
|
- gdpr-hdi
|
||||||
|
- gdpr-uaa
|
||||||
|
- gdpr-auditlog
|
||||||
|
# binding with parameters not yet supported -> binding done manually in .etc/deploy.sh
|
||||||
|
#- name: gdpr-pdm
|
||||||
|
# parameters: ./pdm-binding-config.json
|
||||||
49
gdpr/package.json
Normal file
49
gdpr/package.json
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
{
|
||||||
|
"name": "@capire/gdpr",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"dependencies": {
|
||||||
|
"@capire/orders": "../orders",
|
||||||
|
"@sap/audit-logging": "^5.1.0",
|
||||||
|
"@sap/cds": "^5.9",
|
||||||
|
"express": "^4.17.1",
|
||||||
|
"hdb": "^0.19.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "rm -rf gen && cds build --production",
|
||||||
|
"deploy": "sh .etc/deploy.sh",
|
||||||
|
"undeploy": "sh .etc/undeploy.sh",
|
||||||
|
"start": "cds run"
|
||||||
|
},
|
||||||
|
"cds": {
|
||||||
|
"requires": {
|
||||||
|
"auth": {
|
||||||
|
"__comment__": "workaround to avoid approuter et al. setup",
|
||||||
|
"impl": "srv/auth.js"
|
||||||
|
},
|
||||||
|
"audit-log": {
|
||||||
|
"[development]": {
|
||||||
|
"kind": "audit-log-to-console"
|
||||||
|
},
|
||||||
|
"[production]": {
|
||||||
|
"kind": "audit-log-service"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"db": {
|
||||||
|
"kind": "sql"
|
||||||
|
},
|
||||||
|
"uaa": {
|
||||||
|
"kind": "xsuaa"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"features": {
|
||||||
|
"audit_personal_data": true,
|
||||||
|
"fiori_preview": true,
|
||||||
|
"[production]": {
|
||||||
|
"kibana_formatter": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"hana": {
|
||||||
|
"deploy-format": "hdbtable"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
35
gdpr/readme.md
Normal file
35
gdpr/readme.md
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# how-to
|
||||||
|
|
||||||
|
## required services and subscriptions
|
||||||
|
|
||||||
|
services:
|
||||||
|
- Audit Log Service
|
||||||
|
- SAP HANA Cloud
|
||||||
|
- SAP HANA Schemas & HDI Containers
|
||||||
|
- Application Logging Service
|
||||||
|
- Personal Data Manager
|
||||||
|
- Authorization and Trust Management Service
|
||||||
|
|
||||||
|
subscriptions:
|
||||||
|
- Audit Log Viewer Service
|
||||||
|
- Personal Data Manager
|
||||||
|
|
||||||
|
## deploy
|
||||||
|
|
||||||
|
after adding the necessary entitlements, do:
|
||||||
|
- `cf l` to log into the respective account
|
||||||
|
- `cd gdpr` (if still in root of `cloud-cap-samples`)
|
||||||
|
- `npm run deploy`, which executes build and deployment via `.etc/deploy.sh`
|
||||||
|
|
||||||
|
## authorization
|
||||||
|
|
||||||
|
create roles for Audit Log Viewer Service and Personal Data Manager, and assign the roles to the respective users
|
||||||
|
|
||||||
|
# open issues
|
||||||
|
|
||||||
|
- deploy via mta, which can bind with parameters, and get rid of scripts in `.etc`
|
||||||
|
- use approuter to remove hacky custom auth impl (`srv/auth.js`)
|
||||||
|
- clarify annotation `EntitySemantics`, which differs between audit logging (`Other`) and personal data manager (`LegalGround`)
|
||||||
|
- annotations for order items Fiori preview app
|
||||||
|
+ `Products` has `@cds.persistence.skip:'always'`
|
||||||
|
- how to reuse intial data from `common`?
|
||||||
20
gdpr/services-manifest.yml
Normal file
20
gdpr/services-manifest.yml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
create-services:
|
||||||
|
- name: gdpr-logs # > for kibana
|
||||||
|
broker: application-logs
|
||||||
|
plan: standard
|
||||||
|
- name: gdpr-hdi # > hana
|
||||||
|
broker: hana
|
||||||
|
plan: hdi-shared
|
||||||
|
- name: gdpr-auditlog # > audit log sink
|
||||||
|
broker: auditlog
|
||||||
|
plan: standard
|
||||||
|
# gdpr-pdm needs to exist before creating gdpr-uaa for authorization grant
|
||||||
|
- name: gdpr-pdm # > personal data manager
|
||||||
|
broker: personal-data-manager-service
|
||||||
|
plan: standard
|
||||||
|
parameters: ./.pdm/pdm-instance-config.json
|
||||||
|
- name: gdpr-uaa # > uaa for authentication
|
||||||
|
broker: xsuaa
|
||||||
|
plan: application
|
||||||
|
parameters: xs-security.json
|
||||||
43
gdpr/srv/auth.js
Normal file
43
gdpr/srv/auth.js
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* workaround to avoid approuter et al. setup
|
||||||
|
*/
|
||||||
|
|
||||||
|
const jwt = require('jsonwebtoken')
|
||||||
|
const tenant = process.env.VCAP_SERVICES
|
||||||
|
? JSON.parse(process.env.VCAP_SERVICES).xsuaa[0].credentials.tenantid
|
||||||
|
: 'anonymous'
|
||||||
|
|
||||||
|
module.exports = (req, res, next) => {
|
||||||
|
/*
|
||||||
|
* decode JWT coming from Personal Data Manager
|
||||||
|
*
|
||||||
|
* DO NOT USE FOR PRODUCTION!
|
||||||
|
* - no token validation
|
||||||
|
* - no xsappname check
|
||||||
|
*/
|
||||||
|
const bearer = req.headers.authorization && req.headers.authorization.split('Bearer ')[1]
|
||||||
|
if (bearer) {
|
||||||
|
const { client_id: id, zid: tenant, scope: roles } = jwt.decode(bearer)
|
||||||
|
req.user = {
|
||||||
|
id,
|
||||||
|
tenant,
|
||||||
|
is: role => roles.some(r => r.endsWith(`.${role}`))
|
||||||
|
}
|
||||||
|
return next()
|
||||||
|
}
|
||||||
|
|
||||||
|
// mock user that has every role EXCEPT PersonalDataManagerUser
|
||||||
|
const basic = req.headers.authorization && req.headers.authorization.split('Basic ')[1]
|
||||||
|
if (basic) {
|
||||||
|
const [id] = Buffer.from(basic, 'base64').toString('utf-8').split(':')
|
||||||
|
req.user = {
|
||||||
|
id,
|
||||||
|
tenant,
|
||||||
|
is: role => role !== 'PersonalDataManagerUser'
|
||||||
|
}
|
||||||
|
return next()
|
||||||
|
}
|
||||||
|
|
||||||
|
// no bearer & no basic -> 401
|
||||||
|
res.set('WWW-Authenticate', 'Basic realm="Users"').status(401).end()
|
||||||
|
}
|
||||||
10
gdpr/srv/gdpr-service.cds
Normal file
10
gdpr/srv/gdpr-service.cds
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using {
|
||||||
|
sap.capire.orders,
|
||||||
|
sap.capire.gdpr
|
||||||
|
} from '../db/schema';
|
||||||
|
|
||||||
|
@requires : 'admin' // > authorization check
|
||||||
|
service GDPRService {
|
||||||
|
entity Customers as projection on gdpr.Customers;
|
||||||
|
entity Orders as projection on orders.Orders;
|
||||||
|
}
|
||||||
24
gdpr/srv/pdm-service.cds
Normal file
24
gdpr/srv/pdm-service.cds
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using {
|
||||||
|
sap.capire.gdpr as gdpr,
|
||||||
|
sap.capire.orders as orders
|
||||||
|
} from '../db/data-privacy';
|
||||||
|
|
||||||
|
@requires : 'PersonalDataManagerUser' // > authorization check
|
||||||
|
service PDMService {
|
||||||
|
|
||||||
|
entity Customers as projection on gdpr.Customers;
|
||||||
|
entity CustomerPostalAddresses as projection on gdpr.CustomerPostalAddresses;
|
||||||
|
entity Orders as projection on orders.Orders;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* additional annotations for Personal Data Manager's Search Fields
|
||||||
|
*/
|
||||||
|
annotate Customers with @(Communication.Contact : {
|
||||||
|
n : {
|
||||||
|
surname : lastName,
|
||||||
|
given : firstName
|
||||||
|
},
|
||||||
|
bday : dateOfBirth
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
26
gdpr/srv/server.js
Normal file
26
gdpr/srv/server.js
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
const cds = require('@sap/cds')
|
||||||
|
|
||||||
|
/*
|
||||||
|
* in development, write audit logs to custom sink (i.e., to console in this example)
|
||||||
|
*/
|
||||||
|
cds.on('served', async () => {
|
||||||
|
if (process.env.NODE_ENV === 'production') return
|
||||||
|
|
||||||
|
const auditLogService = await cds.connect.to('audit-log')
|
||||||
|
// use prepend to get called before the generic implementation
|
||||||
|
auditLogService.prepend(function() {
|
||||||
|
const LOG = cds.log('my custom audit logging impl')
|
||||||
|
// triggered when reading sensitive personal data
|
||||||
|
this.on('dataAccessLog', function(req) {
|
||||||
|
const { accesses } = req.data
|
||||||
|
for (const access of accesses) LOG.info(access)
|
||||||
|
})
|
||||||
|
// triggered when modifying personal data
|
||||||
|
this.on('dataModificationLog', function(req) {
|
||||||
|
const { modifications } = req.data
|
||||||
|
for (const modification of modifications) LOG.info(modification)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
module.exports = cds.server
|
||||||
14
gdpr/xs-security.json
Normal file
14
gdpr/xs-security.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"xsappname": "capire-gdpr",
|
||||||
|
"tenant-mode": "shared",
|
||||||
|
"scopes": [{
|
||||||
|
"name": "$XSAPPNAME.PersonalDataManagerUser",
|
||||||
|
"description": "Authority for Personal Data Manager",
|
||||||
|
"grant-as-authority-to-apps": [
|
||||||
|
"$XSSERVICENAME(gdpr-pdm)"
|
||||||
|
]
|
||||||
|
}, {
|
||||||
|
"name": "$XSAPPNAME.admin",
|
||||||
|
"description": "Administrator"
|
||||||
|
}]
|
||||||
|
}
|
||||||
@@ -7,11 +7,11 @@
|
|||||||
"start:ts": "cds-ts serve srv/world.cds"
|
"start:ts": "cds-ts serve srv/world.cds"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sap/cds": ">=5.0.4"
|
"@sap/cds": "^5.0.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "*",
|
"@types/jest": "^27.0.2",
|
||||||
"@types/node": "*",
|
"@types/node": "^16.11.6",
|
||||||
"ts-jest": "^27.0.2",
|
"ts-jest": "^27.0.2",
|
||||||
"typescript": "^4.3.5"
|
"typescript": "^4.3.5"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,19 +2,19 @@
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Note: this is designed for the PerformanceService being co-located with
|
// Note: this is designed for the OrdersService being co-located with
|
||||||
// bookshop. It does not work if PerformanceService is run as a separate
|
// bookshop. It does not work if OrdersService is run as a separate
|
||||||
// process, and is not intended to do so.
|
// process, and is not intended to do so.
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
using { PerformanceService } from '../srv/performance-service';
|
using { OrdersService } from '../srv/orders-service';
|
||||||
|
|
||||||
|
|
||||||
@odata.draft.enabled
|
@odata.draft.enabled
|
||||||
annotate PerformanceService.Orders with @(
|
annotate OrdersService.Orders with @(
|
||||||
UI: {
|
UI: {
|
||||||
SelectionFields: [ createdAt, createdBy ],
|
SelectionFields: [ createdAt, createdBy ],
|
||||||
LineItem: [
|
LineItem: [
|
||||||
@@ -68,7 +68,7 @@ annotate PerformanceService.Orders with @(
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
annotate PerformanceService.Orders.Items with @(
|
annotate OrdersService.Orders.Items with @(
|
||||||
UI: {
|
UI: {
|
||||||
LineItem: [
|
LineItem: [
|
||||||
{Value: product_ID, Label:'Product ID'},
|
{Value: product_ID, Label:'Product ID'},
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
<script id="sap-ui-bootstrap" src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
|
<script id="sap-ui-bootstrap" 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_horizon"
|
data-sap-ui-theme="sap_fiori_3"
|
||||||
data-sap-ui-frameOptions="allow"
|
data-sap-ui-frameOptions="allow"
|
||||||
></script>
|
></script>
|
||||||
<script>
|
<script>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
ID;Header_ID;quantity;product_ID;title;price
|
ID;up__ID;quantity;product_ID;title;price
|
||||||
58040e66-1dcd-4ffb-ab10-fdce32028b79;7e2f2640-6866-4dcf-8f4d-3027aa831cad;10;201;Wuthering Heights;11.11
|
58040e66-1dcd-4ffb-ab10-fdce32028b79;7e2f2640-6866-4dcf-8f4d-3027aa831cad;1;201;Wuthering Heights;11.11
|
||||||
64e718c9-ff99-47f1-8ca3-950c850777d4;7e2f2640-6866-4dcf-8f4d-3027aa831cad;501;271;Catweazle;15
|
64e718c9-ff99-47f1-8ca3-950c850777d4;7e2f2640-6866-4dcf-8f4d-3027aa831cad;1;271;Catweazle;15
|
||||||
e9641166-e050-4261-bfee-d1e797e6cb7f;64e718c9-ff99-47f1-8ca3-950c850777d4;499;252;Eleonora;28
|
e9641166-e050-4261-bfee-d1e797e6cb7f;64e718c9-ff99-47f1-8ca3-950c850777d4;2;252;Eleonora;28
|
||||||
|
24
orders/db/schema.cds
Normal file
24
orders/db/schema.cds
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using { Currency, User, managed, cuid } from '@sap/cds/common';
|
||||||
|
namespace sap.capire.orders;
|
||||||
|
|
||||||
|
entity Orders : cuid, managed {
|
||||||
|
OrderNo : String @title:'Order Number'; //> readable key
|
||||||
|
Items : Composition of many {
|
||||||
|
key ID : UUID;
|
||||||
|
product : Association to Products;
|
||||||
|
quantity : Integer;
|
||||||
|
title : String; //> intentionally replicated as snapshot from product.title
|
||||||
|
price : Double; //> materialized calculated field
|
||||||
|
};
|
||||||
|
buyer : User;
|
||||||
|
currency : Currency;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This is a stand-in for arbitrary ordered Products */
|
||||||
|
entity Products @(cds.persistence.skip:'always') {
|
||||||
|
key ID : String;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// this is to ensure we have filled-in currencies
|
||||||
|
using from '@capire/common';
|
||||||
@@ -3,6 +3,6 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@capire/common": "*",
|
"@capire/common": "*",
|
||||||
"@sap/cds": ">=5"
|
"@sap/cds": "^5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
5
orders/srv/orders-service.cds
Normal file
5
orders/srv/orders-service.cds
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
using { sap.capire.orders as my } from '../db/schema';
|
||||||
|
|
||||||
|
service OrdersService {
|
||||||
|
entity Orders as projection on my.Orders;
|
||||||
|
}
|
||||||
@@ -5,14 +5,6 @@ class OrdersService extends cds.ApplicationService {
|
|||||||
init(){
|
init(){
|
||||||
const { 'Orders.Items':OrderItems } = this.entities
|
const { 'Orders.Items':OrderItems } = this.entities
|
||||||
|
|
||||||
// fill itemCategory at runtime
|
|
||||||
this.before (['CREATE', 'UPDATE'], async req =>{
|
|
||||||
if(req.data.quantity > 500) {req.data.itemCategory = 'Large'}
|
|
||||||
else if (req.data.quantity > 100) {req.data.itemCategory = 'Medium'}
|
|
||||||
else {req.data.itemCategory = 'Small'}
|
|
||||||
})
|
|
||||||
//
|
|
||||||
|
|
||||||
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) {
|
||||||
5181
package-lock.json
generated
5181
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -10,24 +10,25 @@
|
|||||||
"@capire/common": "./common",
|
"@capire/common": "./common",
|
||||||
"@capire/data-viewer": "./data-viewer",
|
"@capire/data-viewer": "./data-viewer",
|
||||||
"@capire/fiori": "./fiori",
|
"@capire/fiori": "./fiori",
|
||||||
|
"@capire/gdpr": "./gdpr",
|
||||||
"@capire/hello": "./hello",
|
"@capire/hello": "./hello",
|
||||||
"@capire/media": "./media",
|
"@capire/media": "./media",
|
||||||
"@capire/orders": "./orders",
|
"@capire/orders": "./orders",
|
||||||
"@capire/reviews": "./reviews",
|
"@capire/reviews": "./reviews",
|
||||||
"@sap/cds": ">=5.5.3"
|
"@sap/cds": "^5.5.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"chai": "^4.3.4",
|
"chai": "^4.3.4",
|
||||||
"chai-as-promised": "^7.1.1",
|
"chai-as-promised": "^7.1.1",
|
||||||
"chai-subset": "^1.6.0",
|
"chai-subset": "^1.6.0",
|
||||||
"semver": "^7",
|
"sqlite3": "npm:@mendix/sqlite3@^5"
|
||||||
"sqlite3": "^5"
|
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"cleanup": "rm -rf node_modules && rm -rf */node_modules && rm -rf */*/node_modules",
|
"cleanup": "rm -rf node_modules && rm -rf */node_modules && rm -rf */*/node_modules",
|
||||||
"registry": "node .registry/server.js",
|
"registry": "node .registry/server.js",
|
||||||
"bookshop": "cds watch bookshop",
|
"bookshop": "cds watch bookshop",
|
||||||
"fiori": "cds watch fiori",
|
"fiori": "cds watch fiori",
|
||||||
|
"gdpr": "cds watch gdpr",
|
||||||
"hello": "cds watch hello",
|
"hello": "cds watch hello",
|
||||||
"media": "cds watch media",
|
"media": "cds watch media",
|
||||||
"mocha": "npx mocha || echo",
|
"mocha": "npx mocha || echo",
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
ID;name;dateOfBirth;placeOfBirth;dateOfDeath;placeOfDeath
|
|
||||||
101;Emily Brontë;1818-07-30;Thornton, Yorkshire;1848-12-19;Haworth, Yorkshire
|
|
||||||
107;Charlotte Brontë;1818-04-21;Thornton, Yorkshire;1855-03-31;Haworth, Yorkshire
|
|
||||||
150;Edgar Allen Poe;1809-01-19;Boston, Massachusetts;1849-10-07;Baltimore, Maryland
|
|
||||||
170;Richard Carpenter;1929-08-14;King’s Lynn, Norfolk;2012-02-26;Hertfordshire, England
|
|
||||||
|
@@ -1,6 +0,0 @@
|
|||||||
ID;title;descr;author_ID;stock;price;currency_code
|
|
||||||
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
|
|
||||||
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
|
|
||||||
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
|
|
||||||
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
|
|
||||||
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
|
|
||||||
|
@@ -1,5 +0,0 @@
|
|||||||
ID;locale;title;descr
|
|
||||||
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.
|
|
||||||
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.
|
|
||||||
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
|
|
||||||
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,122 +0,0 @@
|
|||||||
using { Currency, cuid, managed } from '@sap/cds/common';
|
|
||||||
|
|
||||||
namespace sap.capire.performance;
|
|
||||||
|
|
||||||
|
|
||||||
entity OrdersHeaders : managed {
|
|
||||||
key ID : UUID;
|
|
||||||
OrderNo : String @title:'Order Number'; //> readable key
|
|
||||||
buyer : String;
|
|
||||||
currency : Currency;
|
|
||||||
Items : Composition of many OrdersItems on Items.Header = $self;
|
|
||||||
}
|
|
||||||
|
|
||||||
entity OrdersItems {
|
|
||||||
key ID : UUID;
|
|
||||||
product : Association to Books;
|
|
||||||
quantity : Integer;
|
|
||||||
title : String; //> intentionally replicated as snapshot from product.title
|
|
||||||
price : Double; //> materialized calculated field
|
|
||||||
Header : Association to OrdersHeaders;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
entity Books {
|
|
||||||
key ID : Integer;
|
|
||||||
title : localized String(111);
|
|
||||||
descr : localized String(1111);
|
|
||||||
author : Association to Authors;
|
|
||||||
stock : Integer;
|
|
||||||
price : Decimal;
|
|
||||||
currency : Currency;
|
|
||||||
}
|
|
||||||
|
|
||||||
entity Authors {
|
|
||||||
key ID : Integer;
|
|
||||||
name : String(111);
|
|
||||||
dateOfBirth : Date;
|
|
||||||
dateOfDeath : Date;
|
|
||||||
placeOfBirth : String;
|
|
||||||
placeOfDeath : String;
|
|
||||||
books : Association to many Books on books.author = $self;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
entity Apples : cuid, managed {
|
|
||||||
description : String;
|
|
||||||
vendor : association to one Vendor;
|
|
||||||
appleDetails : appleDetailsType;
|
|
||||||
}
|
|
||||||
|
|
||||||
entity Bananas : cuid, managed {
|
|
||||||
description : String;
|
|
||||||
vendor : association to one Vendor;
|
|
||||||
bananaDetails : bananaDetailsType;
|
|
||||||
}
|
|
||||||
|
|
||||||
entity Cherries : cuid, managed {
|
|
||||||
description : String;
|
|
||||||
vendor : association to one Vendor;
|
|
||||||
cherryDetails : cherryDetailsType;
|
|
||||||
}
|
|
||||||
|
|
||||||
entity Mangos : cuid, managed {
|
|
||||||
description : String;
|
|
||||||
vendor : association to one Vendor;
|
|
||||||
mangoDetails : mangoDetailsType;
|
|
||||||
}
|
|
||||||
|
|
||||||
entity Vendor : cuid, managed {
|
|
||||||
description : String;
|
|
||||||
}
|
|
||||||
|
|
||||||
type appleDetailsType : String;
|
|
||||||
type bananaDetailsType : String;
|
|
||||||
type cherryDetailsType : String;
|
|
||||||
type mangoDetailsType : String;
|
|
||||||
|
|
||||||
entity Fruit : cuid, managed {
|
|
||||||
type : String enum { apple; banana; cherry; mango };
|
|
||||||
description : String;
|
|
||||||
vendor : association to one Vendor;
|
|
||||||
appleDetails : composition of AppleDetails;
|
|
||||||
bananaDetails : composition of BananaDetails;
|
|
||||||
cherryDetails : composition of CherryDetails;
|
|
||||||
mangoDetails : composition of MangoDetails;
|
|
||||||
}
|
|
||||||
|
|
||||||
entity AppleDetails : cuid {
|
|
||||||
appleDetails : appleDetailsType;
|
|
||||||
}
|
|
||||||
|
|
||||||
entity BananaDetails : cuid {
|
|
||||||
bananaDetails : bananaDetailsType;
|
|
||||||
}
|
|
||||||
|
|
||||||
entity CherryDetails : cuid {
|
|
||||||
cherryDetails : cherryDetailsType;
|
|
||||||
}
|
|
||||||
|
|
||||||
entity MangoDetails : cuid {
|
|
||||||
mangoDetails : mangoDetailsType;
|
|
||||||
}
|
|
||||||
|
|
||||||
view Banana as select from Fruit
|
|
||||||
{
|
|
||||||
type,
|
|
||||||
description,
|
|
||||||
vendor,
|
|
||||||
bananaDetails,
|
|
||||||
}
|
|
||||||
where type = 'banana';
|
|
||||||
|
|
||||||
|
|
||||||
aspect apple { appleDetails : appleDetailsType; };
|
|
||||||
aspect banana { bananaDetails : bananaDetailsType;};
|
|
||||||
aspect cherry { cherryDetails : cherryDetailsType;};
|
|
||||||
aspect mango { mangoDetails : mangoDetailsType; };
|
|
||||||
entity Fruit_2 : apple, banana, cherry, mango, cuid, managed {
|
|
||||||
type : String enum { apple; banana; cherry; mango };
|
|
||||||
description : String;
|
|
||||||
vendor : association to one Vendor;
|
|
||||||
}
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
using { sap.capire.performance as my } from '../db/schema';
|
|
||||||
|
|
||||||
service PerformanceService {
|
|
||||||
entity OrdersHeaders as projection on my.OrdersHeaders;
|
|
||||||
entity OrdersItems as projection on my.OrdersItems;
|
|
||||||
entity Books as projection on my.Books;
|
|
||||||
entity Authors as projection on my.Authors;
|
|
||||||
|
|
||||||
// static
|
|
||||||
view OrdersItemsViewJoin as select
|
|
||||||
|
|
||||||
OrdersHeaders.ID as Header_ID,
|
|
||||||
OrdersHeaders.OrderNo as OrderNo,
|
|
||||||
OrdersHeaders.buyer as buyer,
|
|
||||||
OrdersHeaders.currency as currency,
|
|
||||||
key OrdersItems.ID as Item_ID,
|
|
||||||
OrdersItems.product as product,
|
|
||||||
OrdersItems.quantity as quantity,
|
|
||||||
OrdersItems.title as title,
|
|
||||||
OrdersItems.price as price
|
|
||||||
|
|
||||||
from OrdersHeaders JOIN OrdersItems on OrdersHeaders.ID = OrdersItems.Header.ID;
|
|
||||||
|
|
||||||
// dynamic entity
|
|
||||||
entity OrderItemsViewAssoc as projection on OrdersHeaders;
|
|
||||||
|
|
||||||
// sort on right table
|
|
||||||
view SortedOrdersJoin as select
|
|
||||||
OrdersHeaders.ID as Header_ID,
|
|
||||||
OrdersHeaders.OrderNo as OrderNo,
|
|
||||||
OrdersHeaders.buyer as buyer,
|
|
||||||
OrdersHeaders.currency as currency,
|
|
||||||
key OrdersItems.ID as Item_ID,
|
|
||||||
OrdersItems.product as product,
|
|
||||||
OrdersItems.quantity as quantity,
|
|
||||||
OrdersItems.title as title,
|
|
||||||
OrdersItems.price as price
|
|
||||||
from OrdersHeaders JOIN OrdersItems on OrdersHeaders.ID = OrdersItems.Header.ID
|
|
||||||
order by title;
|
|
||||||
|
|
||||||
// sort on items and join back to header via assoc
|
|
||||||
|
|
||||||
view SortedOrdersAssoc as select
|
|
||||||
from OrdersItems {*, Header.OrderNo, Header.buyer, Header.currency }
|
|
||||||
order by OrdersItems.title;
|
|
||||||
|
|
||||||
// filter on right table
|
|
||||||
|
|
||||||
view FilteredOrdersJoin as select
|
|
||||||
OrdersHeaders.ID as Header_ID,
|
|
||||||
OrdersHeaders.OrderNo as OrderNo,
|
|
||||||
OrdersHeaders.buyer as buyer,
|
|
||||||
OrdersHeaders.currency as currency,
|
|
||||||
key OrdersItems.ID as Item_ID,
|
|
||||||
OrdersItems.product as product,
|
|
||||||
OrdersItems.quantity as quantity,
|
|
||||||
OrdersItems.title as title,
|
|
||||||
OrdersItems.price as price
|
|
||||||
from OrdersHeaders JOIN OrdersItems on OrdersHeaders.ID = OrdersItems.Header.ID
|
|
||||||
where price > 100;
|
|
||||||
|
|
||||||
// filter on items and join back to header via assoc
|
|
||||||
|
|
||||||
view FilteredOrdersAssoc as select
|
|
||||||
from OrdersItems {*, Header.OrderNo, Header.buyer, Header.currency }
|
|
||||||
where OrdersItems.price > 100;
|
|
||||||
|
|
||||||
|
|
||||||
// TODO avoid CASE -- Denormalization of expensive complex structures,
|
|
||||||
// calculate on write instead of read
|
|
||||||
|
|
||||||
// CASE -> try to remodel to avoid CASE, if re-modelling is not possible,
|
|
||||||
// fill redundant fields at write
|
|
||||||
|
|
||||||
entity OrdersItemsCaseView as projection on OrdersItems {
|
|
||||||
*,
|
|
||||||
case
|
|
||||||
when quantity > 500 then 'Large'
|
|
||||||
when quantity > 100 then 'Medium'
|
|
||||||
else 'Small'
|
|
||||||
end as category : String
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
extend my.OrdersItems with {
|
|
||||||
itemCategory: String enum{ Small; Medium; Large;};
|
|
||||||
// fill itemCategory at runtime in performance-service.js
|
|
||||||
}
|
|
||||||
|
|
||||||
entity OrdersItemsNoCaseView as projection on OrdersItems {
|
|
||||||
*,
|
|
||||||
itemCategory as category
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -4,10 +4,11 @@ const GET = (url) => axios.get('/reviews'+url)
|
|||||||
const PUT = (cmd,data) => axios.patch('/reviews'+cmd,data)
|
const PUT = (cmd,data) => axios.patch('/reviews'+cmd,data)
|
||||||
const POST = (cmd,data) => axios.post('/reviews'+cmd,data)
|
const POST = (cmd,data) => axios.post('/reviews'+cmd,data)
|
||||||
|
|
||||||
const reviews = Vue.createApp ({
|
const reviews = new Vue ({
|
||||||
|
|
||||||
data() {
|
el:'#app',
|
||||||
return {
|
|
||||||
|
data: {
|
||||||
list: [],
|
list: [],
|
||||||
review: undefined,
|
review: undefined,
|
||||||
message: {},
|
message: {},
|
||||||
@@ -18,7 +19,6 @@ const reviews = Vue.createApp ({
|
|||||||
2 : '★★',
|
2 : '★★',
|
||||||
1 : '★',
|
1 : '★',
|
||||||
}).reverse()
|
}).reverse()
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
@@ -66,7 +66,7 @@ const reviews = Vue.createApp ({
|
|||||||
datetime: (d) => d && new Date(d).toLocaleString(),
|
datetime: (d) => d && new Date(d).toLocaleString(),
|
||||||
},
|
},
|
||||||
|
|
||||||
}).mount("#app")
|
})
|
||||||
|
|
||||||
// initially fill list of my reviews
|
// initially fill list of my reviews
|
||||||
reviews.fetch()
|
reviews.fetch()
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<title> Capire Reviews </title>
|
<title> Capire Reviews </title>
|
||||||
<link rel="stylesheet" href="https://unpkg.com/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"></script>
|
||||||
<style>
|
<style>
|
||||||
.hovering tr:hover td { color:cyan; background: #123; cursor: pointer; }
|
.hovering tr:hover td { color:cyan; background: #123; cursor: pointer; }
|
||||||
.rating-stars { color:teal }
|
.rating-stars { color:teal }
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
<body class="small-container", style="margin-top: 70px;">
|
<body class="small-container", style="margin-top: 70px;">
|
||||||
<div id='app'>
|
<div id='app'>
|
||||||
|
|
||||||
<h1> Capire Reviews </h1>
|
<h1> {{ document.title }} </h1>
|
||||||
|
|
||||||
<input type="text" placeholder="Search..." @input="search">
|
<input type="text" placeholder="Search..." @input="search">
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
"index.cds"
|
"index.cds"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sap/cds": ">=5",
|
"@sap/cds": "^5",
|
||||||
"express": "^4.17.1"
|
"express": "^4.17.1"
|
||||||
},
|
},
|
||||||
"cds": {
|
"cds": {
|
||||||
|
|||||||
@@ -81,8 +81,6 @@ describe('cds.ql → cqn', () => {
|
|||||||
.to.eql(SELECT('Foo','Boo').from('Bar'))
|
.to.eql(SELECT('Foo','Boo').from('Bar'))
|
||||||
.to.eql(SELECT(['Foo','Boo']).from('Bar'))
|
.to.eql(SELECT(['Foo','Boo']).from('Bar'))
|
||||||
.to.eql(SELECT `Bar` .columns `Foo, Boo`)
|
.to.eql(SELECT `Bar` .columns `Foo, Boo`)
|
||||||
.to.eql(SELECT `Bar` .columns `{ Foo, Boo }`)
|
|
||||||
.to.eql(SELECT `Bar` .columns ('{ Foo, Boo }'))
|
|
||||||
.to.eql(SELECT `Bar` .columns ('Foo','Boo'))
|
.to.eql(SELECT `Bar` .columns ('Foo','Boo'))
|
||||||
.to.eql(SELECT `Bar` .columns (['Foo','Boo']))
|
.to.eql(SELECT `Bar` .columns (['Foo','Boo']))
|
||||||
.to.eql(SELECT.from `Bar` .columns ('Foo','Boo'))
|
.to.eql(SELECT.from `Bar` .columns ('Foo','Boo'))
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const cds = require('@sap/cds/lib')
|
const cds = require('@sap/cds/lib')
|
||||||
const { expect } = cds.test ('@capire/bookshop')
|
const { expect } = cds.test ('@capire/bookshop')
|
||||||
|
|
||||||
describe('cap/samples - Consuming Services locally', () => {
|
describe('Consuming Services locally', () => {
|
||||||
//
|
//
|
||||||
it('bootstrapped the database successfully', ()=>{
|
it('bootstrapped the database successfully', ()=>{
|
||||||
const { AdminService } = cds.services
|
const { AdminService } = cds.services
|
||||||
@@ -32,27 +32,6 @@ 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ë',
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ const { GET, POST, expect } = cds.test(__dirname+'/../bookshop')
|
|||||||
if (cds.User.default) cds.User.default = cds.User.Privileged // hard core monkey patch
|
if (cds.User.default) cds.User.default = cds.User.Privileged // hard core monkey patch
|
||||||
else cds.User = cds.User.Privileged // hard core monkey patch for older cds releases
|
else cds.User = cds.User.Privileged // hard core monkey patch for older cds releases
|
||||||
|
|
||||||
describe('cap/samples - Custom Handlers', () => {
|
describe('Custom Handlers', () => {
|
||||||
|
|
||||||
it('should reject out-of-stock orders', async () => {
|
it('should reject out-of-stock orders', async () => {
|
||||||
await POST `/browse/submitOrder ${{ book: 201, quantity: 5 }}`
|
await POST `/browse/submitOrder ${{ book: 201, quantity: 5 }}`
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const cds = require('@sap/cds/lib')
|
const cds = require('@sap/cds/lib')
|
||||||
const { GET, expect } = cds.test (__dirname+'/../hello')
|
const { GET, expect } = cds.test (__dirname+'/../hello')
|
||||||
|
|
||||||
describe('cap/samples - Hello world!', () => {
|
describe('Hello world!', () => {
|
||||||
|
|
||||||
it('should say hello with class impl', async () => {
|
it('should say hello with class impl', async () => {
|
||||||
const {data} = await GET `/say/hello(to='world')`
|
const {data} = await GET `/say/hello(to='world')`
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ const model = cds.compile.to.csn (`
|
|||||||
const {Categories:Cats} = model.definitions
|
const {Categories:Cats} = model.definitions
|
||||||
|
|
||||||
|
|
||||||
describe('cap/samples - Hierarchical Data', ()=>{
|
describe('Hierarchical Data', ()=>{
|
||||||
|
|
||||||
before ('bootstrap sqlite in-memory db...', async()=>{
|
before ('bootstrap sqlite in-memory db...', async()=>{
|
||||||
await cds.deploy (model) .to ('sqlite::memory:')
|
await cds.deploy (model) .to ('sqlite::memory:')
|
||||||
@@ -35,21 +35,6 @@ describe('cap/samples - Hierarchical Data', ()=>{
|
|||||||
))
|
))
|
||||||
|
|
||||||
it ('supports nested reads', async()=>{
|
it ('supports nested reads', async()=>{
|
||||||
if (require('semver').gte(cds.version, '5.9.0')) {
|
|
||||||
expect (await
|
|
||||||
SELECT.one.from (Cats, c=>{
|
|
||||||
c.ID, c.name.as('parent'), c.children (c=>{
|
|
||||||
c.name.as('child')
|
|
||||||
})
|
|
||||||
}) .where ({name:'Cat'})
|
|
||||||
) .to.eql (
|
|
||||||
{ ID:101, parent:'Cat', children:[
|
|
||||||
{ child:'Kitty' },
|
|
||||||
{ child:'Catwoman' },
|
|
||||||
]}
|
|
||||||
)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
expect (await
|
expect (await
|
||||||
SELECT.one.from (Cats, c=>{
|
SELECT.one.from (Cats, c=>{
|
||||||
c.ID, c.name.as('parent'), c.children (c=>{
|
c.ID, c.name.as('parent'), c.children (c=>{
|
||||||
@@ -65,25 +50,6 @@ describe('cap/samples - Hierarchical Data', ()=>{
|
|||||||
})
|
})
|
||||||
|
|
||||||
it ('supports deeply nested reads', async()=>{
|
it ('supports deeply nested reads', async()=>{
|
||||||
if (require('semver').gte(cds.version, '5.9.0')) {
|
|
||||||
expect (await SELECT.one.from (Cats, c=>{
|
|
||||||
c.ID, c.name, c.children (
|
|
||||||
c => { c.name },
|
|
||||||
{levels:3}
|
|
||||||
)
|
|
||||||
}) .where ({name:'Cat'})
|
|
||||||
) .to.eql (
|
|
||||||
{ ID:101, name:'Cat', children:[
|
|
||||||
{ name:'Kitty', children:[
|
|
||||||
{ name:'Kitty Cat', children:[
|
|
||||||
{ name:'Aristocat' }, ]}, // level 3
|
|
||||||
{ name:'Kitty Bat', children:[] }, ]},
|
|
||||||
{ name:'Catwoman', children:[
|
|
||||||
{ name:'Catalina', children:[] } ]},
|
|
||||||
]}
|
|
||||||
)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
expect (await SELECT.one.from (Cats, c=>{
|
expect (await SELECT.one.from (Cats, c=>{
|
||||||
c.ID, c.name, c.children (
|
c.ID, c.name, c.children (
|
||||||
c => { c.name },
|
c => { c.name },
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ const { GET, expect, cds } = require('@sap/cds/lib').test (__dirname)
|
|||||||
if (cds.User.default) cds.User.default = cds.User.Privileged // hard core monkey patch
|
if (cds.User.default) cds.User.default = cds.User.Privileged // hard core monkey patch
|
||||||
else cds.User = cds.User.Privileged // hard core monkey patch for older cds releases
|
else cds.User = cds.User.Privileged // hard core monkey patch for older cds releases
|
||||||
|
|
||||||
describe('cap/samples - Localized Data', () => {
|
describe('Localized Data', () => {
|
||||||
|
|
||||||
it('serves localized $metadata documents', async () => {
|
it('serves localized $metadata documents', async () => {
|
||||||
const { data } = await GET`/browse/$metadata?sap-language=de`
|
const { data } = await GET`/browse/$metadata?sap-language=de`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ const _model = '@capire/reviews'
|
|||||||
if (cds.User.default) cds.User.default = cds.User.Privileged // hard core monkey patch
|
if (cds.User.default) cds.User.default = cds.User.Privileged // hard core monkey patch
|
||||||
else cds.User = cds.User.Privileged // hard core monkey patch for older cds releases
|
else cds.User = cds.User.Privileged // hard core monkey patch for older cds releases
|
||||||
|
|
||||||
describe('cap/samples - Messaging', ()=>{
|
describe('Messaging', ()=>{
|
||||||
|
|
||||||
it ('should bootstrap sqlite in-memory db', async()=>{
|
it ('should bootstrap sqlite in-memory db', async()=>{
|
||||||
const db = await cds.deploy (_model) .to ('sqlite::memory:')
|
const db = await cds.deploy (_model) .to ('sqlite::memory:')
|
||||||
|
|||||||
@@ -1,48 +1,9 @@
|
|||||||
const cds = require('@sap/cds/lib')
|
const cds = require('@sap/cds/lib')
|
||||||
const { GET, expect, axios } = cds.test ('@capire/bookshop')
|
const { GET, expect } = cds.test ('@capire/bookshop')
|
||||||
axios.defaults.auth = { username: 'alice', password: 'admin' }
|
if (cds.User.default) cds.User.default = cds.User.Privileged // hard core monkey patch
|
||||||
|
else cds.User = cds.User.Privileged // hard core monkey patch for older cds releases
|
||||||
|
|
||||||
describe('cap/samples - Bookshop APIs', () => {
|
describe('OData Protocol', () => {
|
||||||
|
|
||||||
// Genres
|
|
||||||
const Drama = {
|
|
||||||
"name": "Drama",
|
|
||||||
"descr": null,
|
|
||||||
"ID": 11,
|
|
||||||
"parent_ID": 10
|
|
||||||
}
|
|
||||||
const Mystery = {
|
|
||||||
"name": "Mystery",
|
|
||||||
"descr": null,
|
|
||||||
"ID": 16,
|
|
||||||
"parent_ID": 10
|
|
||||||
}
|
|
||||||
const Fantasy = {
|
|
||||||
"name": "Fantasy",
|
|
||||||
"descr": null,
|
|
||||||
"ID": 13,
|
|
||||||
"parent_ID": 10
|
|
||||||
}
|
|
||||||
|
|
||||||
// Currencies
|
|
||||||
const GBP = {
|
|
||||||
"name": "British Pound",
|
|
||||||
"descr": null,
|
|
||||||
"code": "GBP",
|
|
||||||
"symbol": "£"
|
|
||||||
}
|
|
||||||
const USD = {
|
|
||||||
"name": "US Dollar",
|
|
||||||
"descr": null,
|
|
||||||
"code": "USD",
|
|
||||||
"symbol": "$"
|
|
||||||
}
|
|
||||||
const JPY = {
|
|
||||||
"name": "Yen",
|
|
||||||
"descr": null,
|
|
||||||
"code": "JPY",
|
|
||||||
"symbol": "¥"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
it('serves $metadata documents in v4', async () => {
|
it('serves $metadata documents in v4', async () => {
|
||||||
@@ -56,16 +17,6 @@ describe('cap/samples - Bookshop APIs', () => {
|
|||||||
expect(data).to.contain('<Annotation Term="Common.Label" String="Currency"/>')
|
expect(data).to.contain('<Annotation Term="Common.Label" String="Currency"/>')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('serves ListOfBooks?$expand=genre,currency', async () => {
|
|
||||||
const { data } = await GET `/browse/ListOfBooks ${{
|
|
||||||
params: { $search: 'Po', $select: `title,author`, $expand:`genre,currency` },
|
|
||||||
}}`
|
|
||||||
expect(data.value).to.eql([
|
|
||||||
{ ID: 251, title: 'The Raven', author: 'Edgar Allen Poe', genre:Mystery, currency:USD },
|
|
||||||
{ ID: 252, title: 'Eleonora', author: 'Edgar Allen Poe', genre:Mystery, currency:USD },
|
|
||||||
])
|
|
||||||
})
|
|
||||||
|
|
||||||
it('supports $search in multiple fields', async () => {
|
it('supports $search in multiple fields', async () => {
|
||||||
const { data } = await GET `/browse/Books ${{
|
const { data } = await GET `/browse/Books ${{
|
||||||
params: { $search: 'Po', $select: `title,author` },
|
params: { $search: 'Po', $select: `title,author` },
|
||||||
@@ -124,16 +75,4 @@ describe('cap/samples - Bookshop APIs', () => {
|
|||||||
{ ID: 271, title: 'Catweazle' },
|
{ ID: 271, title: 'Catweazle' },
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('serves user info', async () => {
|
|
||||||
{
|
|
||||||
const { data } = await GET (`/user/me`)
|
|
||||||
expect(data).to.containSubset({ id: 'alice', locale:'en', tenant: null })
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const { data } = await GET (`/user/me`, {auth: { username: 'joe' }})
|
|
||||||
expect(data).to.containSubset({ id: 'joe', locale:'en', tenant: null })
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const { resolve } = require('path')
|
|||||||
const verbose = process.env.CDS_TEST_VERBOSE
|
const verbose = process.env.CDS_TEST_VERBOSE
|
||||||
// ||true
|
// ||true
|
||||||
|
|
||||||
describe('cap/samples - Local NPM registry', () => {
|
describe('Local NPM registry', () => {
|
||||||
let registry
|
let registry
|
||||||
let axios
|
let axios
|
||||||
const cwd = resolve(__dirname, '..')
|
const cwd = resolve(__dirname, '..')
|
||||||
@@ -20,7 +20,7 @@ describe('cap/samples - Local NPM registry', () => {
|
|||||||
|
|
||||||
after(() => { registry.kill() })
|
after(() => { registry.kill() })
|
||||||
|
|
||||||
for (const mod of ['bookshop', 'data-viewer', 'fiori','orders','reviews']) {
|
for (const mod of ['bookshop','fiori','orders','reviews']) {
|
||||||
it(`should serve ${mod}`, async () => {
|
it(`should serve ${mod}`, async () => {
|
||||||
const resp = await axios.get(`/@capire/${mod}`)
|
const resp = await axios.get(`/@capire/${mod}`)
|
||||||
expect(resp.data).to.containSubset({name: `@capire/${mod}`, versions:{}})
|
expect(resp.data).to.containSubset({name: `@capire/${mod}`, versions:{}})
|
||||||
|
|||||||
Reference in New Issue
Block a user