Compare commits
6 Commits
common-con
...
performanc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a10a30936a | ||
|
|
cae6a21b89 | ||
|
|
bf0587b028 | ||
|
|
76195703f4 | ||
|
|
7af4e94b69 | ||
|
|
1b220508c1 |
13
.eslintrc
13
.eslintrc
@@ -1,25 +1,22 @@
|
||||
{
|
||||
"extends": [
|
||||
"plugin:@sap/cds/recommended",
|
||||
"eslint:recommended"
|
||||
],
|
||||
"extends": "eslint:recommended",
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es2022": true,
|
||||
"node": true,
|
||||
"es6": true,
|
||||
"jest": true,
|
||||
"mocha": true
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2020
|
||||
},
|
||||
"globals": {
|
||||
"SELECT": true,
|
||||
"INSERT": true,
|
||||
"UPSERT": true,
|
||||
"UPDATE": true,
|
||||
"DELETE": true,
|
||||
"CREATE": true,
|
||||
"DROP": true,
|
||||
"CDL": true,
|
||||
"CQL": true,
|
||||
"cds": true
|
||||
},
|
||||
"rules": {
|
||||
|
||||
5
.github/ISSUE_TEMPLATE/config.yml
vendored
5
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1,5 +0,0 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: This channel is CLOSED.
|
||||
about: Use SAP community instead
|
||||
url: https://answers.sap.com/tags/9f13aee1-834c-4105-8e43-ee442775e5ce
|
||||
10
.github/ISSUE_TEMPLATE/question--feedback-or-bug-.md
vendored
Normal file
10
.github/ISSUE_TEMPLATE/question--feedback-or-bug-.md
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
---
|
||||
name: This channel is CLOSED.
|
||||
about: Use our community at https://answers.sap.com/tags/9f13aee1-834c-4105-8e43-ee442775e5ce
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
Please use our community on https://answers.sap.com/tags/9f13aee1-834c-4105-8e43-ee442775e5ce
|
||||
3
.github/workflows/node.js.yml
vendored
3
.github/workflows/node.js.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [18.x, 16.x, 14.x]
|
||||
node-version: [16.x, 14.x, 12.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@@ -24,6 +24,5 @@ jobs:
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- run: npm i -g npm@8
|
||||
- run: npm ci
|
||||
- run: npm test
|
||||
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -12,13 +12,8 @@ target/
|
||||
*.mtar
|
||||
connection.properties
|
||||
default-env.json
|
||||
.cdsrc-private.json
|
||||
packages/messageBox
|
||||
reviews/msg-box
|
||||
reviews/db/test.db
|
||||
|
||||
*.openapi3.json
|
||||
*.sqlite
|
||||
*.db
|
||||
|
||||
**/@types
|
||||
|
||||
1
.registry/.gitignore
vendored
Normal file
1
.registry/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.tgz
|
||||
81
.registry/server.js
Normal file
81
.registry/server.js
Normal file
@@ -0,0 +1,81 @@
|
||||
const { exec } = require ('child_process')
|
||||
const isWin = process.platform === 'win32'
|
||||
const express = require ('express')
|
||||
const fs = require ('fs')
|
||||
const app = express()
|
||||
|
||||
const { PORT=4444 } = process.env
|
||||
const [,,port=PORT,scope='@capire'] = process.argv
|
||||
const cwd = __dirname
|
||||
|
||||
// clean up on start (exit handler might not complete on Windows)
|
||||
exec(isWin ? 'del *.tgz' : 'rm *.tgz', {cwd})
|
||||
|
||||
|
||||
app.use('/-/:tarball', (req,res,next) => {
|
||||
console.debug ('GET', req.params)
|
||||
try {
|
||||
const { tarball } = req.params
|
||||
const pkgFull = tarball.substring(0, tarball.lastIndexOf('-'))
|
||||
const [, pkg ] = /^\w+-(.+)/.exec(pkgFull)
|
||||
fs.lstat(tarball,(err => {
|
||||
if (err) console.debug (`npm pack ../${pkg}`)
|
||||
if (err) exec(`npm pack ../${pkg}`,{cwd},next)
|
||||
else next()
|
||||
}))
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
res.sendStatus(500)
|
||||
}
|
||||
})
|
||||
|
||||
app.use('/-', express.static(__dirname))
|
||||
|
||||
app.get('/*', (req,res)=>{
|
||||
const urlRegex = /^\/(@[\w-]+)\/(.+)/
|
||||
const url = decodeURIComponent(req.url)
|
||||
console.debug ('GET',url)
|
||||
try {
|
||||
if (!urlRegex.test(url)) return res.sendStatus(404)
|
||||
const [, scpe, pkg ] = urlRegex.exec(url)
|
||||
const package = require (`${scpe}/${pkg}/package.json`)
|
||||
const tarball = `${scpe.slice(1)}-${pkg}-${package.version}.tgz`
|
||||
// https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md
|
||||
res.json({
|
||||
"name": package.name,
|
||||
"dist-tags": {
|
||||
"latest": package.version
|
||||
},
|
||||
"versions": {
|
||||
[package.version]: {
|
||||
"name": package.name,
|
||||
"version": package.version,
|
||||
"dist": {
|
||||
"tarball": `${server.url}/-/${tarball}`
|
||||
},
|
||||
}
|
||||
},
|
||||
})
|
||||
} catch (e) {
|
||||
if (e.code === 'MODULE_NOT_FOUND') return res.sendStatus(404)
|
||||
console.error(e); throw e
|
||||
}
|
||||
})
|
||||
|
||||
const server = app.listen(port, ()=>{
|
||||
const url = server.url = `http://localhost:${server.address().port}`
|
||||
console.log (`npm set ${scope}:registry=${url}`)
|
||||
exec(`npm set ${scope}:registry=${url}`)
|
||||
console.log (`${scope} registry listening on ${url}`)
|
||||
})
|
||||
|
||||
|
||||
const _exit = ()=>{
|
||||
server.close()
|
||||
exec(`npm conf rm "${scope}:registry"`, ()=> { process.exit() })
|
||||
}
|
||||
|
||||
process.on ('SIGTERM',_exit)
|
||||
process.on ('SIGHUP',_exit)
|
||||
process.on ('SIGINT',_exit)
|
||||
process.on ('SIGUSR2',_exit)
|
||||
@@ -104,7 +104,7 @@
|
||||
},
|
||||
{
|
||||
"file": "fiori/app/services.cds",
|
||||
"description": "### Annotations for SAP Fiori Elements\n\nAdds an SAP Fiori elements application to bookstore, thereby introducing:\n- OData Annotations in `.cds` files\n- Support for Fiori Draft\n- Support for Value Helps\n- Serving SAP Fiori apps locally\n\nSee the [Serving Fiori UIs](https://cap.cloud.sap/docs/advanced/fiori) documentation for more information.",
|
||||
"description": "### Annotations for SAP Fiori Elements\n\n- [Adds an SAP Fiori elements application](https://cap.cloud.sap/docs/guides/fiori/) to bookstore, thereby introducing to:\n- [OData Annotations](https://cap.cloud.sap/docs/guides/fiori#adding-odata-annotations) in `.cds` files\n- Support for [Fiori Draft](https://cap.cloud.sap/docs/guides/fiori#draft)\n- Support for [Value Helps](https://cap.cloud.sap/docs/guides/fiori#value-help)\n- Serving SAP Fiori apps locally\n",
|
||||
"line": 1,
|
||||
"selection": {
|
||||
"start": {
|
||||
|
||||
20
.vscode/launch.json
vendored
20
.vscode/launch.json
vendored
@@ -13,7 +13,7 @@
|
||||
"<node_internals>/**",
|
||||
"**/node_modules/**",
|
||||
"**/cds/lib/lazy.js",
|
||||
"**/cds/lib/req/cds-context.js",
|
||||
"**/cds/lib/req/cls.js",
|
||||
"**/odata-v4/okra/**"
|
||||
]
|
||||
},
|
||||
@@ -26,24 +26,10 @@
|
||||
"<node_internals>/**",
|
||||
"**/node_modules/**",
|
||||
"**/cds/lib/lazy.js",
|
||||
"**/cds/lib/req/cds-context.js",
|
||||
"**/cds/lib/req/cls.js",
|
||||
"**/odata-v4/okra/**"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Debug Mocha Tests",
|
||||
"type": "node",
|
||||
"request": "attach",
|
||||
"port": 9229,
|
||||
"continueOnAttach": true,
|
||||
"skipFiles": [
|
||||
"<node_internals>/**",
|
||||
"**/node_modules/**",
|
||||
"**/cds/lib/lazy.js",
|
||||
"**/cds/lib/req/cds-context.js",
|
||||
"**/odata-v4/okra/**",
|
||||
]
|
||||
},
|
||||
}
|
||||
],
|
||||
"inputs": [
|
||||
{
|
||||
|
||||
13
.vscode/settings.json
vendored
13
.vscode/settings.json
vendored
@@ -10,18 +10,9 @@
|
||||
"<node_internals>/**",
|
||||
"**/node_modules/**",
|
||||
"**/cds/lib/lazy.js",
|
||||
"**/cds/lib/req/cds-context.js",
|
||||
"**/cds/lib/req/cls.js",
|
||||
"**/odata-v4/okra/**"
|
||||
]
|
||||
},
|
||||
"mochaExplorer.debuggerConfig": "Debug Mocha Tests",
|
||||
"mochaExplorer.parallel": true,
|
||||
"eslint.probe": [
|
||||
"cds",
|
||||
"csn",
|
||||
"csv",
|
||||
"csv (semicolon)",
|
||||
"tsv",
|
||||
"tab"
|
||||
]
|
||||
"mochaExplorer.parallel": true
|
||||
}
|
||||
|
||||
@@ -7,14 +7,13 @@ Find here a collection of samples for the [SAP Cloud Application Programming Mod
|
||||
|
||||
### Preliminaries
|
||||
|
||||
1. Ensure you have the latest LTS version of Node.js installed (see [Getting Started](https://cap.cloud.sap/docs/get-started/))
|
||||
2. Install [**@sap/cds-dk**](https://cap.cloud.sap/docs/get-started/) globally:
|
||||
1. Install [**@sap/cds-dk**](https://cap.cloud.sap/docs/get-started/) globally:
|
||||
|
||||
```sh
|
||||
npm i -g @sap/cds-dk
|
||||
```
|
||||
|
||||
3. _Optional:_ [Use Visual Studio Code](https://cap.cloud.sap/docs/get-started/tools#vscode)
|
||||
2. _Optional:_ [Use Visual Studio Code](https://cap.cloud.sap/docs/get-started/tools#vscode)
|
||||
|
||||
### Download
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ const books = Vue.createApp ({
|
||||
list: [],
|
||||
book: undefined,
|
||||
order: { quantity:1, succeeded:'', failed:'' },
|
||||
user: undefined
|
||||
user: {}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -42,48 +42,20 @@ const books = Vue.createApp ({
|
||||
}
|
||||
},
|
||||
|
||||
async login() {
|
||||
async fetchUserInfo() {
|
||||
try {
|
||||
const { data:user } = await axios.post('/user/login',{})
|
||||
if (user.id !== 'anonymous') books.user = user
|
||||
const { data } = await axios.get('/user/me')
|
||||
books.user = data
|
||||
} catch (err) { books.user = { id: err.message } }
|
||||
},
|
||||
|
||||
async getUserInfo() {
|
||||
try {
|
||||
const { data:user } = await axios.get('/user/me')
|
||||
if (user.id !== 'anonymous') books.user = user
|
||||
} catch (err) { books.user = { id: err.message } }
|
||||
},
|
||||
}
|
||||
}).mount('#app')
|
||||
}
|
||||
}).mount("#app")
|
||||
|
||||
books.getUserInfo()
|
||||
books.fetch() // initially fill list of books
|
||||
// initially fill list of books
|
||||
books.fetch()
|
||||
|
||||
books.fetchUserInfo()
|
||||
document.addEventListener('keydown', (event) => {
|
||||
// hide user info on request
|
||||
if (event.key === 'u') books.user = undefined
|
||||
})
|
||||
|
||||
axios.interceptors.request.use(csrfToken)
|
||||
function csrfToken (request) {
|
||||
if (request.method === 'head' || request.method === 'get') return request
|
||||
if ('csrfToken' in document) {
|
||||
request.headers['x-csrf-token'] = document.csrfToken
|
||||
return request
|
||||
}
|
||||
return fetchToken().then(token => {
|
||||
document.csrfToken = token
|
||||
request.headers['x-csrf-token'] = document.csrfToken
|
||||
return request
|
||||
}).catch(_ => {
|
||||
document.csrfToken = null // set mark to not try again
|
||||
return request
|
||||
})
|
||||
|
||||
function fetchToken() {
|
||||
return axios.get('/', { headers: { 'x-csrf-token': 'fetch' } })
|
||||
.then(res => res.headers['x-csrf-token'])
|
||||
}
|
||||
}
|
||||
@@ -18,17 +18,11 @@
|
||||
<body class="small-container", style="margin-top: 70px;">
|
||||
<div id='app'>
|
||||
|
||||
<form class="user" @submit.prevent="login">
|
||||
<div v-if="user">
|
||||
<div v-if="user.tenant">Tenant: {{ user.tenant }}</div>
|
||||
<div> User: {{ user.id }}</div>
|
||||
<div v-if="user" class="user">
|
||||
<div>User: {{ user.id || 'anonymous' }}</div>
|
||||
<div>Locale: {{ user.locale }}</div>
|
||||
<div v-if="user.tenant">Tenant: {{ user.tenant }}</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<input type="submit" value="Login" class="muted-button">
|
||||
<!-- <a href="/user/login()">Login</a> -->
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<h1> Capire Books </h1>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
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"
|
||||
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 +1,6 @@
|
||||
ID,title,descr,author_ID,stock,price,currency_code,genre_ID
|
||||
201,Wuthering Heights,"Wuthering Heights, Emily Brontë's only novel, was published in 1847 under the pseudonym ""Ellis Bell"". It was written between October 1845 and June 1846. Wuthering Heights and Anne Brontë's Agnes Grey were accepted by publisher Thomas Newby before the success of their sister Charlotte's novel Jane Eyre. After Emily's death, Charlotte edited the manuscript of Wuthering Heights and arranged for the edited version to be published as a posthumous second edition in 1850.",101,12,11.11,GBP,11
|
||||
207,Jane Eyre,"Jane Eyre /ɛər/ (originally published as Jane Eyre: An Autobiography) is a novel by English writer Charlotte Brontë, published under the pen name ""Currer Bell"", on 16 October 1847, by Smith, Elder & Co. of London. The first American edition was published the following year by Harper & Brothers of New York. Primarily a bildungsroman, Jane Eyre follows the experiences of its eponymous heroine, including her growth to adulthood and her love for Mr. Rochester, the brooding master of Thornfield Hall. The novel revolutionised prose fiction in that the focus on Jane's moral and spiritual development is told through an intimate, first-person narrative, where actions and events are coloured by a psychological intensity. The book contains elements of social criticism, with a strong sense of Christian morality at its core and is considered by many to be ahead of its time because of Jane's individualistic character and how the novel approaches the topics of class, sexuality, religion and feminism.",107,11,12.34,GBP,11
|
||||
251,The Raven,"""The Raven"" is a narrative poem by American writer Edgar Allan Poe. First published in January 1845, the poem is often noted for its musicality, stylized language, and supernatural atmosphere. It tells of a talking raven's mysterious visit to a distraught lover, tracing the man's slow fall into madness. The lover, often identified as being a student, is lamenting the loss of his love, Lenore. Sitting on a bust of Pallas, the raven seems to further distress the protagonist with its constant repetition of the word ""Nevermore"". The poem makes use of folk, mythological, religious, and classical references.",150,333,13.13,USD,16
|
||||
252,Eleonora,"""Eleonora"" is a short story by Edgar Allan Poe, first published in 1842 in Philadelphia in the literary annual The Gift. It is often regarded as somewhat autobiographical and has a relatively ""happy"" ending.",150,555,14,USD,15
|
||||
271,Catweazle,"Catweazle is a British fantasy television series, starring Geoffrey Bayldon in the title role, and created by Richard Carpenter for London Weekend Television. The first series, produced and directed by Quentin Lawrence, was screened in the UK on ITV in 1970. The second series, directed by David Reid and David Lane, was shown in 1971. Each series had thirteen episodes, most but not all written by Carpenter, who also published two books based on the scripts.",170,22,150,JPY,13
|
||||
ID;title;descr;author_ID;stock;price;currency_code;genre_ID
|
||||
201;Wuthering Heights;"Wuthering Heights, Emily Brontë's only novel, was published in 1847 under the pseudonym ""Ellis Bell"". It was written between October 1845 and June 1846. Wuthering Heights and Anne Brontë's Agnes Grey were accepted by publisher Thomas Newby before the success of their sister Charlotte's novel Jane Eyre. After Emily's death, Charlotte edited the manuscript of Wuthering Heights and arranged for the edited version to be published as a posthumous second edition in 1850.";101;12;11.11;GBP;11
|
||||
207;Jane Eyre;"Jane Eyre /ɛər/ (originally published as Jane Eyre: An Autobiography) is a novel by English writer Charlotte Brontë, published under the pen name ""Currer Bell"", on 16 October 1847, by Smith, Elder & Co. of London. The first American edition was published the following year by Harper & Brothers of New York. Primarily a bildungsroman, Jane Eyre follows the experiences of its eponymous heroine, including her growth to adulthood and her love for Mr. Rochester, the brooding master of Thornfield Hall. The novel revolutionised prose fiction in that the focus on Jane's moral and spiritual development is told through an intimate, first-person narrative, where actions and events are coloured by a psychological intensity. The book contains elements of social criticism, with a strong sense of Christian morality at its core and is considered by many to be ahead of its time because of Jane's individualistic character and how the novel approaches the topics of class, sexuality, religion and feminism.";107;11;12.34;GBP;11
|
||||
251;The Raven;"""The Raven"" is a narrative poem by American writer Edgar Allan Poe. First published in January 1845, the poem is often noted for its musicality, stylized language, and supernatural atmosphere. It tells of a talking raven's mysterious visit to a distraught lover, tracing the man's slow fall into madness. The lover, often identified as being a student, is lamenting the loss of his love, Lenore. Sitting on a bust of Pallas, the raven seems to further distress the protagonist with its constant repetition of the word ""Nevermore"". The poem makes use of folk, mythological, religious, and classical references.";150;333;13.13;USD;16
|
||||
252;Eleonora;"""Eleonora"" is a short story by Edgar Allan Poe, first published in 1842 in Philadelphia in the literary annual The Gift. It is often regarded as somewhat autobiographical and has a relatively ""happy"" ending.";150;555;14;USD;16
|
||||
271;Catweazle;Catweazle is a British fantasy television series, starring Geoffrey Bayldon in the title role, and created by Richard Carpenter for London Weekend Television. The first series, produced and directed by Quentin Lawrence, was screened in the UK on ITV in 1970. The second series, directed by David Reid and David Lane, was shown in 1971. Each series had thirteen episodes, most but not all written by Carpenter, who also published two books based on the scripts.;170;22;150;JPY;13
|
||||
|
@@ -1,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."
|
||||
|
5
bookshop/db/data/sap.capire.bookshop-Books_texts.csv
Normal file
5
bookshop/db/data/sap.capire.bookshop-Books_texts.csv
Normal file
@@ -0,0 +1,5 @@
|
||||
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,16 +1,16 @@
|
||||
ID,parent_ID,name
|
||||
10,,Fiction
|
||||
11,10,Drama
|
||||
12,10,Poetry
|
||||
13,10,Fantasy
|
||||
14,10,Science Fiction
|
||||
15,10,Romance
|
||||
16,10,Mystery
|
||||
17,10,Thriller
|
||||
18,10,Dystopia
|
||||
19,10,Fairy Tale
|
||||
20,,Non-Fiction
|
||||
21,20,Biography
|
||||
22,21,Autobiography
|
||||
23,20,Essay
|
||||
24,20,Speech
|
||||
ID;parent_ID;name
|
||||
10;;Fiction
|
||||
11;10;Drama
|
||||
12;10;Poetry
|
||||
13;10;Fantasy
|
||||
14;10;Science Fiction
|
||||
15;10;Romance
|
||||
16;10;Mystery
|
||||
17;10;Thriller
|
||||
18;10;Dystopia
|
||||
19;10;Fairy Tale
|
||||
20;;Non-Fiction
|
||||
21;20;Biography
|
||||
22;21;Autobiography
|
||||
23;20;Essay
|
||||
24;20;Speech
|
||||
|
||||
|
@@ -4,21 +4,21 @@
|
||||
* currencies, if not obtained through @capire/common.
|
||||
*/
|
||||
|
||||
module.exports = async (tx)=>{
|
||||
module.exports = async (db)=>{
|
||||
|
||||
const has_common = tx.model.definitions['sap.common.Currencies']?.elements.numcode
|
||||
const has_common = db.model.definitions['sap.common.Currencies'].elements.numcode
|
||||
if (has_common) return
|
||||
|
||||
const already_filled = await tx.exists('sap.common.Currencies',{code:'EUR'})
|
||||
const already_filled = await db.exists('sap.common.Currencies',{code:'EUR'})
|
||||
if (already_filled) return
|
||||
|
||||
await tx.run (INSERT.into ('sap.common.Currencies') .columns (
|
||||
[ 'code', 'symbol', 'name' ]
|
||||
await INSERT.into ('sap.common.Currencies') .columns (
|
||||
'code','symbol','name'
|
||||
) .rows (
|
||||
[ 'EUR', '€', 'Euro' ],
|
||||
[ 'USD', '$', 'US Dollar' ],
|
||||
[ 'GBP', '£', 'British Pound' ],
|
||||
[ 'ILS', '₪', 'Shekel' ],
|
||||
[ 'JPY', '¥', 'Yen' ],
|
||||
))
|
||||
[ 'EUR','€','Euro' ],
|
||||
[ 'USD','$','US Dollar' ],
|
||||
[ 'GBP','£','British Pound' ],
|
||||
[ 'ILS','₪','Shekel' ],
|
||||
[ 'JPY','¥','Yen' ],
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2,4 +2,3 @@ namespace sap.capire.bookshop; //> important for reflection
|
||||
using from './db/schema';
|
||||
using from './srv/cat-service';
|
||||
using from './srv/admin-service';
|
||||
using from './srv/user-service';
|
||||
|
||||
1226
bookshop/package-lock.json
generated
Normal file
1226
bookshop/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -10,7 +10,7 @@
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"@sap/cds": ">=5.9",
|
||||
"@sap/cds": "^6.1.1",
|
||||
"express": "^4.17.1",
|
||||
"passport": ">=0.4.1"
|
||||
},
|
||||
@@ -21,7 +21,12 @@
|
||||
},
|
||||
"cds": {
|
||||
"requires": {
|
||||
"db": "sql"
|
||||
"db": {
|
||||
"kind": "sqlite",
|
||||
"credentials": {
|
||||
"database": "sqlite.db"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BIN
bookshop/sqlite.db
Normal file
BIN
bookshop/sqlite.db
Normal file
Binary file not shown.
@@ -1,10 +1,9 @@
|
||||
const cds = require('@sap/cds/lib')
|
||||
const cds = require('@sap/cds')
|
||||
|
||||
module.exports = class AdminService extends cds.ApplicationService { init(){
|
||||
module.exports = cds.service.impl (function(){
|
||||
this.before ('NEW','Authors', genid)
|
||||
this.before ('NEW','Books', genid)
|
||||
return super.init()
|
||||
}}
|
||||
})
|
||||
|
||||
/** Generate primary keys for target entity in request */
|
||||
async function genid (req) {
|
||||
|
||||
@@ -3,7 +3,6 @@ const cds = require('@sap/cds')
|
||||
class CatalogService extends cds.ApplicationService { init(){
|
||||
|
||||
const { Books } = cds.entities ('sap.capire.bookshop')
|
||||
const { ListOfBooks } = this.entities
|
||||
|
||||
// Reduce stock of ordered books if available stock suffices
|
||||
this.on ('submitOrder', async req => {
|
||||
@@ -19,7 +18,7 @@ class CatalogService extends cds.ApplicationService { init(){
|
||||
})
|
||||
|
||||
// Add some discount for overstocked books
|
||||
this.after ('READ', ListOfBooks, each => {
|
||||
this.after ('READ','ListOfBooks', each => {
|
||||
if (each.stock > 111) each.title += ` -- 11% discount!`
|
||||
})
|
||||
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
/**
|
||||
* Exposes user information
|
||||
*/
|
||||
@requires: 'authenticated-user'
|
||||
service UserService {
|
||||
|
||||
/**
|
||||
* The current user
|
||||
*/
|
||||
@odata.singleton entity me @cds.persistence.skip {
|
||||
@odata.singleton entity me {
|
||||
id : String; // user id
|
||||
locale : String;
|
||||
tenant : String;
|
||||
}
|
||||
|
||||
action login() returns me;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
const cds = require('@sap/cds')
|
||||
module.exports = class UserService extends cds.Service { init(){
|
||||
this.on('READ', 'me', ({ tenant, user, locale }) => ({ id: user.id, locale, tenant }))
|
||||
this.on('login', (req) => {
|
||||
if (req.user._is_anonymous)
|
||||
req._.res.set('WWW-Authenticate','Basic realm="Users"').sendStatus(401)
|
||||
else return this.read('me')
|
||||
})
|
||||
}}
|
||||
module.exports = cds.service.impl((srv) => {
|
||||
srv.on('READ', 'me', ({ tenant, user, locale }) => ({ id: user.id, locale, tenant }))
|
||||
})
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
"@capire/common": "*",
|
||||
"@capire/data-viewer": "*",
|
||||
"@sap/cds": ">=5",
|
||||
"@sap/cds-common-content": "^1.0.0",
|
||||
"express": "^4.17.1"
|
||||
},
|
||||
"cds": {
|
||||
@@ -27,8 +26,7 @@
|
||||
"[production]": { "kind": "enterprise-messaging" }
|
||||
},
|
||||
"db": {
|
||||
"kind": "sql",
|
||||
"schema_evolution": "auto"
|
||||
"kind": "sql"
|
||||
}
|
||||
},
|
||||
"log": { "service": true }
|
||||
|
||||
@@ -19,4 +19,4 @@ module.exports = cds.server
|
||||
|
||||
// For didactic reasons in capire
|
||||
const { ReviewsService, OrdersService } = cds.requires
|
||||
if (!ReviewsService?.credentials && !OrdersService?.credentials) cds.requires.messaging = false
|
||||
if (!ReviewsService.credentials && !OrdersService.credentials) cds.requires.messaging = false
|
||||
|
||||
@@ -12,11 +12,7 @@ using { sap.capire.bookshop.Books } from '@capire/bookshop';
|
||||
using { ReviewsService.Reviews } from '@capire/reviews';
|
||||
extend Books with {
|
||||
reviews : Composition of many Reviews on reviews.subject = $self.ID;
|
||||
|
||||
@Common.Label : '{i18n>Rating}'
|
||||
rating : Decimal;
|
||||
|
||||
@Common.Label : '{i18n>NumberOfReviews}'
|
||||
numberOfReviews : Integer;
|
||||
}
|
||||
|
||||
|
||||
12
common/data/sap.common-Countries.csv
Normal file
12
common/data/sap.common-Countries.csv
Normal file
@@ -0,0 +1,12 @@
|
||||
code;name;descr
|
||||
AU;Australia;Commonwealth of Australia
|
||||
CA;Canada;Canada
|
||||
CN;China;People's Republic of China (PRC)
|
||||
FR;France;French Republic
|
||||
DE;Germany;Federal Republic of Germany
|
||||
IN;India;Republic of India
|
||||
IL;Israel;State of Israel
|
||||
MM;Myanmar;Republic of the Union of Myanmar
|
||||
GB;United Kingdom;United Kingdom of Great Britain and Northern Ireland
|
||||
US;United States;United States of America (USA)
|
||||
EU;European Union;European Union
|
||||
|
12
common/data/sap.common-Countries_texts.csv
Normal file
12
common/data/sap.common-Countries_texts.csv
Normal file
@@ -0,0 +1,12 @@
|
||||
code;locale;name;descr
|
||||
AU;de;Australien;Commonwealth Australien
|
||||
CA;de;Kanada;Canada
|
||||
CN;de;China;Volksrepublik China
|
||||
FR;de;Frankreich;Republik Frankreich
|
||||
DE;de;Deutschland;Bundesrepublik Deutschland
|
||||
IN;de;Indien;Republik Indien
|
||||
IL;de;Israel;Staat Israel
|
||||
MM;de;Myanmar;Republik der Union Myanmar
|
||||
GB;de;Vereinigtes Königreich;Vereinigtes Königreich Großbritannien und Nordirland
|
||||
US;de;Vereinigte Staaten;Vereinigte Staaten von Amerika
|
||||
EU;de;Europäische Union;Europäische Union
|
||||
|
@@ -1,12 +1,12 @@
|
||||
code;symbol;numcode;minor;exponent
|
||||
EUR;€;978;Cent;2
|
||||
USD;$;840;Cent;2
|
||||
CAD;$;124;Cent;2
|
||||
AUD;$;036;Cent;2
|
||||
GBP;£;826;Penny;2
|
||||
ILS;₪;376;Agorat;2
|
||||
INR;₹;356;Paise;2
|
||||
QAR;﷼;634;Dirham;2
|
||||
SAR;﷼;682;Halala;2
|
||||
JPY;¥;392;Sen;2
|
||||
CNY;¥;156;Jiao;1
|
||||
code;symbol;name;descr;numcode;minor;exponent
|
||||
EUR;€;Euro;European Euro;978;Cent;2
|
||||
USD;$;US Dollar;United States Dollar;840;Cent;2
|
||||
CAD;$;Canadian Dollar;Canadian Dollar;124;Cent;2
|
||||
AUD;$;Australian Dollar;Australian Dollar;036;Cent;2
|
||||
GBP;£;British Pound;Great Britain Pound;826;Penny;2
|
||||
ILS;₪;Shekel;Israeli New Shekel;376;Agorat;2
|
||||
INR;₹;Rupee;Indian Rupee;356;Paise;2
|
||||
QAR;﷼;Riyal;Katar Riyal;356;Dirham;2
|
||||
SAR;﷼;Riyal;Saudi Riyal;682;Halala;2
|
||||
JPY;¥;Yen;Japanese Yen;392;Sen;2
|
||||
CNY;¥;Yuan;Chinese Yuan Renminbi;156;Jiao;1
|
||||
|
15
common/data/sap.common-Currencies_texts.csv
Normal file
15
common/data/sap.common-Currencies_texts.csv
Normal file
@@ -0,0 +1,15 @@
|
||||
code;locale;name;descr
|
||||
EUR;de;Euro;European Euro
|
||||
USD;de;US-Dollar;United States Dollar
|
||||
CAD;de;Kanadischer Dollar;Kanadischer Dollar
|
||||
AUD;de;Australischer Dollar;Australischer Dollar
|
||||
GBP;de;Pfund;Britische Pfund
|
||||
ILS;de;Schekel;Israelische Schekel
|
||||
JPY;de;Yen;Japanische Yen
|
||||
EUR;fr;euro;de la Zone euro
|
||||
USD;fr;dollar;dollar des États-Unis
|
||||
CAD;fr;dollar canadien;dollar canadien
|
||||
AUD;fr;dollar australien;dollar australien
|
||||
GBP;fr;livre sterling;pound sterling
|
||||
ILS;fr;Shekel;shekel israelien
|
||||
JPY;fr;Yen;Yen japonais
|
||||
|
5
common/data/sap.common-Languages.csv
Normal file
5
common/data/sap.common-Languages.csv
Normal file
@@ -0,0 +1,5 @@
|
||||
code;name
|
||||
de;German
|
||||
fr;French
|
||||
en;English
|
||||
en_GB;British English
|
||||
|
10
common/data/sap.common-Languages_texts.csv
Normal file
10
common/data/sap.common-Languages_texts.csv
Normal file
@@ -0,0 +1,10 @@
|
||||
code;locale;name
|
||||
de;en;German
|
||||
de;de;Deutsch
|
||||
de;fr;Allemande
|
||||
fr;en;French
|
||||
fr;de;Französisch
|
||||
fr;fr;Francais
|
||||
en;en;English
|
||||
en;de;Englisch
|
||||
en;fr;Anglais
|
||||
|
@@ -1,7 +1,5 @@
|
||||
using { sap } from '@sap/cds/common';
|
||||
|
||||
using from '@sap/cds-common-content';
|
||||
|
||||
extend sap.common.Currencies with {
|
||||
// Currencies.code = ISO 4217 alphabetic three-letter code
|
||||
// with the first two letters being equal to ISO 3166 alphabetic country codes
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
* Exposes data + entity metadata
|
||||
*/
|
||||
@requires:'authenticated-user'
|
||||
@odata service DataService @( path:'-data' ) {
|
||||
service DataService @( path:'-data' ) {
|
||||
|
||||
/**
|
||||
* Metadata like name and columns/elements
|
||||
*/
|
||||
entity Entities @cds.persistence.skip {
|
||||
entity Entities {
|
||||
key name : String;
|
||||
columns: Composition of many {
|
||||
name : String;
|
||||
@@ -19,7 +19,7 @@
|
||||
/**
|
||||
* The actual data, organized by column name
|
||||
*/
|
||||
entity Data @cds.persistence.skip {
|
||||
entity Data {
|
||||
record : array of {
|
||||
column : String;
|
||||
data : String;
|
||||
|
||||
@@ -6,33 +6,16 @@ Author = Author
|
||||
AuthorID = Author ID
|
||||
Stock = Stock
|
||||
Name = Name
|
||||
Description = Description
|
||||
Image = Image
|
||||
AuthorName = Author's Name
|
||||
DateOfBirth = Date of Birth
|
||||
DateOfDeath = Date of Death
|
||||
PlaceOfBirth = Place of Birth
|
||||
PlaceOfDeath = Place of Death
|
||||
Age = Age
|
||||
Lifetime = Lifetime
|
||||
Authors = Authors
|
||||
|
||||
Order = Order
|
||||
Orders = Orders
|
||||
OrderNo = Order Number
|
||||
OrderItems = Order Items
|
||||
Customer = Customer
|
||||
Product = Product
|
||||
ProductID = Product ID
|
||||
ProductTitle = Product Title
|
||||
UnitPrice = Unit Price
|
||||
Quantity = Quantity
|
||||
|
||||
Price = Price
|
||||
Currency = Currency
|
||||
Date = Date
|
||||
Rating = Rating
|
||||
NumberOfReviews = Number of Reviews
|
||||
|
||||
Genre = Genre
|
||||
Genres = Genres
|
||||
|
||||
@@ -43,10 +43,5 @@ extend sap.capire.bookshop.Authors with {
|
||||
virtual lifetime : String;
|
||||
}
|
||||
|
||||
annotate AdminService.Authors with {
|
||||
age @Common.Label : '{i18n>Age}';
|
||||
lifetime @Common.Label : '{i18n>Lifetime}'
|
||||
}
|
||||
|
||||
// Workaround for Fiori popup for asking user to enter a new UUID on Create
|
||||
annotate AdminService.Authors with { ID @Core.Computed; }
|
||||
|
||||
@@ -62,11 +62,6 @@ annotate AdminService.Books.texts with @(
|
||||
}
|
||||
);
|
||||
|
||||
annotate AdminService.Books.texts with {
|
||||
ID @UI.Hidden;
|
||||
ID_texts @UI.Hidden;
|
||||
};
|
||||
|
||||
// Add Value Help for Locales
|
||||
annotate AdminService.Books.texts {
|
||||
locale @(
|
||||
@@ -81,6 +76,3 @@ extend service AdminService {
|
||||
|
||||
// Workaround for Fiori popup for asking user to enter a new UUID on Create
|
||||
annotate AdminService.Books with { ID @Core.Computed; }
|
||||
|
||||
// Show Genre as drop down, not a dialog
|
||||
annotate AdminService.Books with { genre @Common.ValueListWithFixedValues; }
|
||||
|
||||
@@ -19,14 +19,6 @@
|
||||
"title": "Browse Books",
|
||||
"targetURL": "#Books-display"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "BrowseGenres",
|
||||
"tileType": "sap.ushell.ui.tile.StaticTile",
|
||||
"properties": {
|
||||
"title": "Browse Genres (OData v2)",
|
||||
"targetURL": "#Genres-display"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -115,24 +107,6 @@
|
||||
"url": "/admin-authors/webapp"
|
||||
}
|
||||
},
|
||||
"BrowseGenres": {
|
||||
"semanticObject": "Genres",
|
||||
"action": "display",
|
||||
"title": "Browse Genres",
|
||||
"signature": {
|
||||
"parameters": {
|
||||
"Genre.ID": {
|
||||
"renameTo": "ID"
|
||||
}
|
||||
},
|
||||
"additionalParameters": "ignored"
|
||||
},
|
||||
"resolutionResult": {
|
||||
"applicationType": "SAPUI5",
|
||||
"additionalInformation": "SAPUI5.Component=genres",
|
||||
"url": "/genres/webapp"
|
||||
}
|
||||
},
|
||||
"ManageBooks": {
|
||||
"semanticObject": "Books",
|
||||
"action": "manage",
|
||||
|
||||
@@ -33,7 +33,7 @@ annotate CatalogService.Books with @(UI : {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Books List Page
|
||||
// Books Object Page
|
||||
//
|
||||
annotate CatalogService.Books with @(UI : {
|
||||
SelectionFields : [
|
||||
@@ -52,6 +52,9 @@ annotate CatalogService.Books with @(UI : {
|
||||
},
|
||||
{Value : genre.name},
|
||||
{Value : price},
|
||||
{Value : currency.symbol},
|
||||
{
|
||||
Value : currency.symbol,
|
||||
Label : ' '
|
||||
},
|
||||
]
|
||||
}, );
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
using { sap.capire.bookshop as my } from '@capire/bookstore';
|
||||
using { sap.common } from '@capire/common';
|
||||
using { sap.common.Currencies } from '@sap/cds/common';
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@@ -13,7 +12,7 @@ using { sap.common.Currencies } from '@sap/cds/common';
|
||||
annotate my.Books with @(
|
||||
Common.SemanticKey : [ID],
|
||||
UI : {
|
||||
Identification : [{ Value: title }],
|
||||
Identification : [{Value : title}],
|
||||
SelectionFields : [
|
||||
ID,
|
||||
author_ID,
|
||||
@@ -21,12 +20,21 @@ annotate my.Books with @(
|
||||
currency_code
|
||||
],
|
||||
LineItem : [
|
||||
{ Value: ID, Label: '{i18n>Title}' },
|
||||
{ Value: author.ID, Label: '{i18n>Author}' },
|
||||
{ Value: genre.name },
|
||||
{ Value: stock },
|
||||
{ Value: price },
|
||||
{ Value: currency.symbol },
|
||||
{
|
||||
Value : ID,
|
||||
Label : '{i18n>Title}'
|
||||
},
|
||||
{
|
||||
Value : author.ID,
|
||||
Label : '{i18n>Author}'
|
||||
},
|
||||
{Value : genre.name},
|
||||
{Value : stock},
|
||||
{Value : price},
|
||||
{
|
||||
Value : currency.symbol,
|
||||
Label : ' '
|
||||
},
|
||||
]
|
||||
}
|
||||
) {
|
||||
@@ -38,10 +46,6 @@ annotate my.Books with @(
|
||||
author @ValueList.entity : 'Authors';
|
||||
};
|
||||
|
||||
annotate Currencies with {
|
||||
symbol @Common.Label : '{i18n>Currency}';
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Books Details
|
||||
@@ -49,8 +53,8 @@ annotate Currencies with {
|
||||
annotate my.Books with @(UI : {HeaderInfo : {
|
||||
TypeName : '{i18n>Book}',
|
||||
TypeNamePlural : '{i18n>Books}',
|
||||
Title : { Value: title },
|
||||
Description : { Value: author.name }
|
||||
Title : {Value : title},
|
||||
Description : {Value : author.name}
|
||||
}, });
|
||||
|
||||
|
||||
@@ -59,14 +63,19 @@ annotate my.Books with @(UI : {HeaderInfo : {
|
||||
// Books Elements
|
||||
//
|
||||
annotate my.Books with {
|
||||
ID @title: '{i18n>ID}';
|
||||
title @title: '{i18n>Title}';
|
||||
genre @title: '{i18n>Genre}' @Common: { Text: genre.name, TextArrangement: #TextOnly };
|
||||
author @title: '{i18n>Author}' @Common: { Text: author.name, TextArrangement: #TextOnly };
|
||||
price @title: '{i18n>Price}' @Measures.ISOCurrency : currency_code;
|
||||
stock @title: '{i18n>Stock}';
|
||||
descr @title: '{i18n>Description}' @UI.MultiLineText;
|
||||
image @title: '{i18n>Image}';
|
||||
ID @title : '{i18n>ID}';
|
||||
title @title : '{i18n>Title}';
|
||||
genre @title : '{i18n>Genre}' @Common : {
|
||||
Text : genre.name,
|
||||
TextArrangement : #TextOnly
|
||||
};
|
||||
author @title : '{i18n>Author}' @Common : {
|
||||
Text : author.name,
|
||||
TextArrangement : #TextOnly
|
||||
};
|
||||
price @title : '{i18n>Price}' @Measures.ISOCurrency : currency_code;
|
||||
stock @title : '{i18n>Stock}';
|
||||
descr @UI.MultiLineText;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
@@ -78,30 +87,26 @@ annotate my.Genres with @(
|
||||
UI : {
|
||||
SelectionFields : [name],
|
||||
LineItem : [
|
||||
{ Value: name },
|
||||
{Value : name},
|
||||
{
|
||||
Value : parent.name,
|
||||
Label: 'Main Genre'
|
||||
Label : 'Main Genre'
|
||||
},
|
||||
],
|
||||
}
|
||||
);
|
||||
|
||||
annotate my.Genres with {
|
||||
ID @Common.Text : name @Common.TextArrangement : #TextOnly;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Genre Details
|
||||
//
|
||||
annotate my.Genres with @(UI : {
|
||||
Identification : [{ Value: name}],
|
||||
Identification : [{Value : name}],
|
||||
HeaderInfo : {
|
||||
TypeName : '{i18n>Genre}',
|
||||
TypeNamePlural : '{i18n>Genres}',
|
||||
Title : { Value: name },
|
||||
Description : { Value: ID }
|
||||
Title : {Value : name},
|
||||
Description : {Value : ID}
|
||||
},
|
||||
Facets : [{
|
||||
$Type : 'UI.ReferenceFacet',
|
||||
@@ -115,8 +120,8 @@ annotate my.Genres with @(UI : {
|
||||
// Genres Elements
|
||||
//
|
||||
annotate my.Genres with {
|
||||
ID @title: '{i18n>ID}';
|
||||
name @title: '{i18n>Genre}';
|
||||
ID @title : '{i18n>ID}';
|
||||
name @title : '{i18n>Genre}';
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
@@ -126,14 +131,14 @@ annotate my.Genres with {
|
||||
annotate my.Authors with @(
|
||||
Common.SemanticKey : [ID],
|
||||
UI : {
|
||||
Identification : [{ Value: name}],
|
||||
Identification : [{Value : name}],
|
||||
SelectionFields : [name],
|
||||
LineItem : [
|
||||
{ Value: ID },
|
||||
{ Value: dateOfBirth },
|
||||
{ Value: dateOfDeath },
|
||||
{ Value: placeOfBirth },
|
||||
{ Value: placeOfDeath },
|
||||
{Value : ID},
|
||||
{Value : dateOfBirth},
|
||||
{Value : dateOfDeath},
|
||||
{Value : placeOfBirth},
|
||||
{Value : placeOfDeath},
|
||||
],
|
||||
}
|
||||
) {
|
||||
@@ -152,8 +157,8 @@ annotate my.Authors with @(UI : {
|
||||
HeaderInfo : {
|
||||
TypeName : '{i18n>Author}',
|
||||
TypeNamePlural : '{i18n>Authors}',
|
||||
Title : { Value: name },
|
||||
Description : { Value: dateOfBirth }
|
||||
Title : {Value : name},
|
||||
Description : {Value : dateOfBirth}
|
||||
},
|
||||
Facets : [{
|
||||
$Type : 'UI.ReferenceFacet',
|
||||
@@ -167,12 +172,12 @@ annotate my.Authors with @(UI : {
|
||||
// Authors Elements
|
||||
//
|
||||
annotate my.Authors with {
|
||||
ID @title: '{i18n>ID}';
|
||||
name @title: '{i18n>Name}';
|
||||
dateOfBirth @title: '{i18n>DateOfBirth}';
|
||||
dateOfDeath @title: '{i18n>DateOfDeath}';
|
||||
placeOfBirth @title: '{i18n>PlaceOfBirth}';
|
||||
placeOfDeath @title: '{i18n>PlaceOfDeath}';
|
||||
ID @title : '{i18n>ID}';
|
||||
name @title : '{i18n>Name}';
|
||||
dateOfBirth @title : '{i18n>DateOfBirth}';
|
||||
dateOfDeath @title : '{i18n>DateOfDeath}';
|
||||
placeOfBirth @title : '{i18n>PlaceOfBirth}';
|
||||
placeOfDeath @title : '{i18n>PlaceOfDeath}';
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
@@ -181,15 +186,15 @@ annotate my.Authors with {
|
||||
//
|
||||
annotate common.Languages with @(
|
||||
Common.SemanticKey : [code],
|
||||
Identification : [{ Value: code}],
|
||||
Identification : [{Value : code}],
|
||||
UI : {
|
||||
SelectionFields : [
|
||||
name,
|
||||
descr
|
||||
],
|
||||
LineItem : [
|
||||
{ Value: code },
|
||||
{ Value: name },
|
||||
{Value : code},
|
||||
{Value : name},
|
||||
],
|
||||
}
|
||||
);
|
||||
@@ -202,8 +207,8 @@ annotate common.Languages with @(UI : {
|
||||
HeaderInfo : {
|
||||
TypeName : '{i18n>Language}',
|
||||
TypeNamePlural : '{i18n>Languages}',
|
||||
Title : { Value: name },
|
||||
Description : { Value: descr }
|
||||
Title : {Value : name},
|
||||
Description : {Value : descr}
|
||||
},
|
||||
Facets : [{
|
||||
$Type : 'UI.ReferenceFacet',
|
||||
@@ -211,9 +216,9 @@ annotate common.Languages with @(UI : {
|
||||
Target : '@UI.FieldGroup#Details'
|
||||
}, ],
|
||||
FieldGroup #Details : {Data : [
|
||||
{ Value: code },
|
||||
{ Value: name },
|
||||
{ Value: descr }
|
||||
{Value : code},
|
||||
{Value : name},
|
||||
{Value : descr}
|
||||
]},
|
||||
});
|
||||
|
||||
@@ -223,16 +228,16 @@ annotate common.Languages with @(UI : {
|
||||
//
|
||||
annotate common.Currencies with @(
|
||||
Common.SemanticKey : [code],
|
||||
Identification : [{ Value: code}],
|
||||
Identification : [{Value : code}],
|
||||
UI : {
|
||||
SelectionFields : [
|
||||
name,
|
||||
descr
|
||||
],
|
||||
LineItem : [
|
||||
{ Value: descr },
|
||||
{ Value: symbol },
|
||||
{ Value: code },
|
||||
{Value : descr},
|
||||
{Value : symbol},
|
||||
{Value : code},
|
||||
],
|
||||
}
|
||||
);
|
||||
@@ -245,8 +250,8 @@ annotate common.Currencies with @(UI : {
|
||||
HeaderInfo : {
|
||||
TypeName : '{i18n>Currency}',
|
||||
TypeNamePlural : '{i18n>Currencies}',
|
||||
Title : { Value: descr },
|
||||
Description : { Value: code }
|
||||
Title : {Value : descr},
|
||||
Description : {Value : code}
|
||||
},
|
||||
Facets : [
|
||||
{
|
||||
@@ -261,15 +266,15 @@ annotate common.Currencies with @(UI : {
|
||||
},
|
||||
],
|
||||
FieldGroup #Details : {Data : [
|
||||
{ Value: name },
|
||||
{ Value: symbol },
|
||||
{ Value: code },
|
||||
{ Value: descr }
|
||||
{Value : name},
|
||||
{Value : symbol},
|
||||
{Value : code},
|
||||
{Value : descr}
|
||||
]},
|
||||
FieldGroup #Extended : {Data : [
|
||||
{ Value: numcode },
|
||||
{ Value: minor },
|
||||
{ Value: exponent }
|
||||
{Value : numcode},
|
||||
{Value : minor},
|
||||
{Value : exponent}
|
||||
]},
|
||||
});
|
||||
|
||||
@@ -278,7 +283,7 @@ annotate common.Currencies with @(UI : {
|
||||
// Currencies Elements
|
||||
//
|
||||
annotate common.Currencies with {
|
||||
numcode @title: '{i18n>NumCode}';
|
||||
minor @title: '{i18n>MinorUnit}';
|
||||
exponent @title: '{i18n>Exponent}';
|
||||
numcode @title : '{i18n>NumCode}';
|
||||
minor @title : '{i18n>MinorUnit}';
|
||||
exponent @title : '{i18n>Exponent}';
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
using { sap.capire.bookshop } from '../../db/common';
|
||||
|
||||
annotate bookshop.GenreHierarchy {
|
||||
ID @sap.hierarchy.node.for;
|
||||
parent @sap.hierarchy.parent.node.for;
|
||||
hierarchyLevel @sap.hierarchy.level.for;
|
||||
drillState @sap.hierarchy.drill.state.for;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
sap.ui.define(["sap/suite/ui/generic/template/lib/AppComponent"], (AppComponent) =>
|
||||
AppComponent.extend("genres.Component", {
|
||||
metadata: {
|
||||
manifest: "json",
|
||||
},
|
||||
})
|
||||
);
|
||||
@@ -1,4 +0,0 @@
|
||||
#XTIT
|
||||
appTitle=Genres
|
||||
#XTXT
|
||||
appDescription=Browse Genres
|
||||
@@ -1,155 +0,0 @@
|
||||
{
|
||||
"_version": "1.8.0",
|
||||
"sap.app": {
|
||||
"id": "genres",
|
||||
"type": "application",
|
||||
"i18n": "i18n/i18n.properties",
|
||||
"applicationVersion": {
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"title": "Browse Genres Hierarchy (OData v2)",
|
||||
"description": "{{appDescription}}",
|
||||
"tags": {
|
||||
"keywords": []
|
||||
},
|
||||
"crossNavigation": {
|
||||
"inbounds": {
|
||||
"appShow": {
|
||||
"title": "{{appTitle}}",
|
||||
"semanticObject": "GenreHierarchy",
|
||||
"action": "display",
|
||||
"deviceTypes": {
|
||||
"desktop": true,
|
||||
"tablet": true,
|
||||
"phone": true
|
||||
},
|
||||
"icon": "sap-icon://settings",
|
||||
"size": "1x1"
|
||||
}
|
||||
},
|
||||
"outbounds": {}
|
||||
},
|
||||
"ach": "",
|
||||
"resources": "resources.json",
|
||||
"dataSources": {
|
||||
"main": {
|
||||
"uri": "/v2/browse",
|
||||
"type": "OData",
|
||||
"settings": {
|
||||
"annotations": ["localAnnotations"],
|
||||
"localUri": "localService/metadata.xml"
|
||||
}
|
||||
},
|
||||
"localAnnotations": {
|
||||
"type": "ODataAnnotation",
|
||||
"uri": "annotations/localAnnotations.xml",
|
||||
"settings": {
|
||||
"localUri": "annotations/localAnnotations.xml"
|
||||
}
|
||||
}
|
||||
},
|
||||
"offline": false,
|
||||
"sourceTemplate": {
|
||||
"id": "ui5template.smartTemplate",
|
||||
"version": "1.40.12"
|
||||
}
|
||||
},
|
||||
"sap.ui": {
|
||||
"technology": "UI5",
|
||||
"icons": {
|
||||
"icon": "",
|
||||
"favIcon": "",
|
||||
"phone": "",
|
||||
"phone@2": "",
|
||||
"tablet": "",
|
||||
"tablet@2": ""
|
||||
},
|
||||
"deviceTypes": {
|
||||
"desktop": true,
|
||||
"tablet": true,
|
||||
"phone": true
|
||||
},
|
||||
"supportedThemes": ["sap_hcb", "sap_belize", "sap_belize_deep", "sap_fiori_3"]
|
||||
},
|
||||
"sap.ui5": {
|
||||
"resources": {
|
||||
"js": [],
|
||||
"css": []
|
||||
},
|
||||
"dependencies": {
|
||||
"minUI5Version": "1.65.6",
|
||||
"libs": {},
|
||||
"components": {}
|
||||
},
|
||||
"models": {
|
||||
"i18n": {
|
||||
"type": "sap.ui.model.resource.ResourceModel",
|
||||
"uri": "i18n/i18n.properties"
|
||||
},
|
||||
"@i18n": {
|
||||
"type": "sap.ui.model.resource.ResourceModel",
|
||||
"uri": "i18n/i18n.properties"
|
||||
},
|
||||
"json": {
|
||||
"type": "sap.ui.model.json.JSONModel"
|
||||
},
|
||||
"i18n|sap.suite.ui.generic.template.ListReport|Genres": {
|
||||
"type": "sap.ui.model.resource.ResourceModel",
|
||||
"uri": "i18n/ListReport/Genres/i18n.properties"
|
||||
},
|
||||
"": {
|
||||
"dataSource": "main",
|
||||
"preload": true,
|
||||
"settings": {
|
||||
"useBatch": true,
|
||||
"defaultBindingMode": "TwoWay",
|
||||
"defaultCountMode": "Inline",
|
||||
"refreshAfterChange": true,
|
||||
"metadataUrlParams": {
|
||||
"sap-value-list": "none"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"contentDensities": {
|
||||
"compact": true,
|
||||
"cozy": true
|
||||
}
|
||||
},
|
||||
"sap.ui.generic.app": {
|
||||
"_version": "1.3.0",
|
||||
"settings": {
|
||||
"forceGlobalRefresh": false,
|
||||
"useColumnLayoutForSmartForm": false,
|
||||
"showBasicSearch": false
|
||||
},
|
||||
"pages": {
|
||||
"ListReport|Genres": {
|
||||
"entitySet": "GenreHierarchy",
|
||||
"component": {
|
||||
"name": "sap.suite.ui.generic.template.ListReport",
|
||||
"list": true,
|
||||
"settings": {
|
||||
"condensedTableLayout": true,
|
||||
"smartVariantManagement": true,
|
||||
"tableType": "TreeTable",
|
||||
"enableTableFilterInPageVariant": true,
|
||||
"dataLoadSettings": {
|
||||
"loadDataOnAppLaunch": "always"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"sap.fiori": {
|
||||
"registrationIds": [],
|
||||
"archeType": "transactional"
|
||||
},
|
||||
"sap.platform.hcp": {
|
||||
"uri": ""
|
||||
},
|
||||
"sap.platform.cf": {
|
||||
"oAuthScopes": []
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,5 @@
|
||||
using from './admin-authors/fiori-service';
|
||||
using from './admin-books/fiori-service';
|
||||
using from './browse/fiori-service';
|
||||
using from './genres/fiori-service';
|
||||
using from './common';
|
||||
using from '@capire/bookstore/srv/mashup';
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
namespace sap.capire.bookshop;
|
||||
|
||||
using { sap.capire.bookshop } from '@capire/bookstore/srv/mashup';
|
||||
|
||||
entity GenreHierarchy : bookshop.Genres {
|
||||
hierarchyLevel : Integer default 0;
|
||||
drillState : String default 'leaf';
|
||||
parent : Association to GenreHierarchy;
|
||||
children : Composition of many GenreHierarchy on children.parent = $self;
|
||||
}
|
||||
|
||||
extend service CatalogService with {
|
||||
@readonly entity GenreHierarchy as projection on bookshop.GenreHierarchy;
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
ID_TEXTS;ID;locale;title;descr
|
||||
a5fe2682-fe60-4dc0-9218-695e501e42e6;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.
|
||||
4edebff3-8cde-4761-8cd3-bae7834fc5f5;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.
|
||||
b649031b-aacc-4dc3-838f-c36bae5d266e;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
|
||||
aa62f0e1-763c-4c92-a304-50c2b86e21f4;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,16 +0,0 @@
|
||||
ID;parent_ID;name;hierarchyLevel;drillState
|
||||
10;;Fiction;0;expanded
|
||||
11;10;Drama;1;leaf
|
||||
12;10;Poetry;1;leaf
|
||||
13;10;Fantasy;1;leaf
|
||||
14;10;Science Fiction;1;leaf
|
||||
15;10;Romance;1;leaf
|
||||
16;10;Mystery;1;leaf
|
||||
17;10;Thriller;1;leaf
|
||||
18;10;Dystopia;1;leaf
|
||||
20;;Non-Fiction;0;expanded
|
||||
19;10;Fairy Tale;1;leaf
|
||||
21;20;Biography;1;expanded
|
||||
22;21;Autobiography;2;leaf
|
||||
23;20;Essay;1;leaf
|
||||
24;20;Speech;1;leaf
|
||||
|
@@ -1 +0,0 @@
|
||||
using from './db/common';
|
||||
@@ -4,7 +4,6 @@
|
||||
"dependencies": {
|
||||
"@capire/bookstore": "*",
|
||||
"@sap/cds": ">=5",
|
||||
"@cap-js-community/odata-v2-adapter": "^1",
|
||||
"express": "^4.17.1",
|
||||
"passport": ">=0.4.1"
|
||||
},
|
||||
@@ -14,6 +13,9 @@
|
||||
},
|
||||
"cds": {
|
||||
"requires": {
|
||||
"auth": {
|
||||
"kind": "dummy-auth"
|
||||
},
|
||||
"ReviewsService": {
|
||||
"kind": "odata",
|
||||
"model": "@capire/reviews"
|
||||
@@ -29,13 +31,12 @@
|
||||
"[development]": {
|
||||
"kind": "file-based-messaging"
|
||||
},
|
||||
"[hybrid]": {
|
||||
"[hybrid!]": {
|
||||
"kind": "enterprise-messaging-shared"
|
||||
}
|
||||
},
|
||||
"db": {
|
||||
"kind": "sql",
|
||||
"schema_evolution": "auto"
|
||||
"kind": "sql"
|
||||
},
|
||||
"db-ext": {
|
||||
"[development]": {
|
||||
@@ -44,10 +45,10 @@
|
||||
"[production]": {
|
||||
"model": "db/hana"
|
||||
}
|
||||
}
|
||||
},
|
||||
"hana": {
|
||||
"deploy-format": "hdbtable"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1 @@
|
||||
// install OData v2 adapter
|
||||
const cds = require("@sap/cds")
|
||||
const proxy = require('@cap-js-community/odata-v2-adapter')
|
||||
const opts = global.it ? { target:'auto' } : {} // for tests, set 'auto' to detect port dynamically
|
||||
cds.on('bootstrap', app => app.use(proxy(opts))) // install proxy
|
||||
cds.log('cov2ap','silent') // suppress anoying log outpout, e.g. for `npm run mocha -- --reporter nyan`
|
||||
|
||||
module.exports = require('@capire/bookstore/server.js')
|
||||
|
||||
@@ -12,4 +12,4 @@ Then call the service at: http://localhost:4004/say/hello(to='world')
|
||||
Learn more about:
|
||||
|
||||
- [Hello World!](https://cap.cloud.sap/docs/get-started/hello-world)
|
||||
- [Using TypeScript](https://cap.cloud.sap/docs/node.js/typescript)
|
||||
- [Using TypeScript](https://cap.cloud.sap/docs/get-started/using-typescript)
|
||||
@@ -12,7 +12,22 @@
|
||||
"devDependencies": {
|
||||
"@types/jest": "*",
|
||||
"@types/node": "*",
|
||||
"typescript": ">=4.3.5"
|
||||
"ts-jest": "^27.0.2",
|
||||
"typescript": "^4.3.5"
|
||||
},
|
||||
"jest": {
|
||||
"testEnvironment": "node",
|
||||
"preset": "ts-jest",
|
||||
"globals": {
|
||||
"ts-jest": {
|
||||
"diagnostics": {
|
||||
"_comment": "see https://githubmemory.com/repo/kulshekhar/ts-jest/issues/2722",
|
||||
"ignoreCodes": [
|
||||
151001
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "eslint:recommended",
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
module.exports = class say {
|
||||
hello(req) {
|
||||
let {to} = req.data
|
||||
if (to === 'me') to = require('os').userInfo().username
|
||||
return `Hello ${to}!`
|
||||
}
|
||||
hello(req) { return `Hello ${req.data.to}!` }
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
const cds = require ('@sap/cds')
|
||||
describe('Hello world!', () => {
|
||||
|
||||
beforeAll (()=> process.env.CDS_TYPESCRIPT = true)
|
||||
afterAll (()=> delete process.env.CDS_TYPESCRIPT)
|
||||
const {GET} = cds.test.in(__dirname,'../srv').run('serve', 'world.cds')
|
||||
|
||||
it('should say hello with class impl', async () => {
|
||||
const {data} = await GET`/say/hello(to='world')`
|
||||
expect(data.value).toMatch(/Hello world.*typescript.*/i)
|
||||
})
|
||||
|
||||
})
|
||||
15
hello/test/hello-world-ts.test.ts
Normal file
15
hello/test/hello-world-ts.test.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
process.env.CDS_TYPESCRIPT = 'true';
|
||||
import * as cds from '@sap/cds';
|
||||
|
||||
//@ts-ignore
|
||||
const {GET} = cds.test.in(__dirname,'../srv').run('serve', 'world.cds');
|
||||
|
||||
describe('Hello world!', () => {
|
||||
afterAll(() => { delete process.env.CDS_TYPESCRIPT; });
|
||||
|
||||
it('should say hello with class impl from a typescript file', async () => {
|
||||
const {data} = await GET`/say/hello(to='world')`
|
||||
expect(data.value).toMatch(/Hello world.*typescript.*/i)
|
||||
})
|
||||
|
||||
})
|
||||
@@ -1,76 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title> cds.log </title>
|
||||
<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/vue@3/dist/vue.global.prod.js"></script>
|
||||
<style>
|
||||
select { border-color: transparent; padding: 4px 12px; margin: 0px; }
|
||||
button { padding: 2px 11px; margin: 0px 4px; font: 90% italic; }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body class="small-container" , style="margin-top: 70px;">
|
||||
<div id='app'>
|
||||
<h1> Log Levels </h1>
|
||||
<input type="text" placeholder="Search by ID or Log Level..." @input="fetch">
|
||||
<table id='loggers'>
|
||||
<thead>
|
||||
<th> Module ID </th>
|
||||
<th> Log Level </th>
|
||||
</thead>
|
||||
<tr v-for="each in list">
|
||||
<td>{{ each.id }}</td>
|
||||
<td><select v-bind:id="each.id" v-model="each.level" @change="set">
|
||||
<option>SILENT</option>
|
||||
<option>ERROR</option>
|
||||
<option>WARN</option>
|
||||
<option>INFO</option>
|
||||
<option>DEBUG</option>
|
||||
<option>TRACE</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h4>Log Format:</h4>
|
||||
[ <button class="round-button" :class={'muted-button':!format.timestamp} @click="toggle_format" id="timestamp">Timestamp </button>
|
||||
| <button class="round-button" :class={'muted-button':!format.level} @click="toggle_format" id="level">Log Level </button>
|
||||
| <button class="round-button" :class={'muted-button':!format.tenant} @click="toggle_format" id="tenant">Tenant </button>
|
||||
| <button class="round-button" :class={'muted-button':!format.reqid} @click="toggle_format" id="reqid">Request ID </button>
|
||||
| <button class="round-button" :class={'muted-button':!format.id} @click="toggle_format" id="module">Logger ID </button>
|
||||
] - <i>log message ...</i>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
<script>
|
||||
axios.defaults.headers['Content-Type'] = 'application/json'
|
||||
axios.defaults.baseURL = '/log'
|
||||
const loggers = Vue.createApp({ el: '#app',
|
||||
data() {
|
||||
return {
|
||||
format: { timestamp:false, level:false, tenant:false, reqid:false, id:true, },
|
||||
list: [],
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async fetch (eve) {
|
||||
this.list = (await axios.get (`/Loggers${
|
||||
eve && eve.target.value ? `?$search=${eve.target.value}` : ''
|
||||
}`)).data
|
||||
},
|
||||
async set (eve) {
|
||||
const { id, value:level } = eve.target
|
||||
await axios.put (`/Logger/${id}`, {id,level})
|
||||
},
|
||||
async toggle_format (eve) {
|
||||
this.format[eve.target.id] = !this.format[eve.target.id]
|
||||
await axios.post (`/format`, this.format)
|
||||
},
|
||||
},
|
||||
}).mount('#app')
|
||||
loggers.fetch() // initially fill list of loggers
|
||||
</script>
|
||||
|
||||
</html>
|
||||
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"name": "@capire/loggers",
|
||||
"version": "1.0.0",
|
||||
"description": "Simple sample on how to dynamically set cds.log levels and formats.",
|
||||
"files": [
|
||||
"app",
|
||||
"srv"
|
||||
],
|
||||
"dependencies": {
|
||||
"@sap/cds": ">=5.9",
|
||||
"express": "^4.17.1"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "cds run",
|
||||
"watch": "cds watch"
|
||||
},
|
||||
"cds": {
|
||||
"requires": {
|
||||
"db": "sql"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
# Dynamically Set `cds.log` Levels and Formats
|
||||
|
||||
### Run
|
||||
|
||||
```sh
|
||||
cds watch
|
||||
```
|
||||
|
||||
### Test
|
||||
|
||||
Either using the UI through http://localhost:4004/loggers.html, or try the requests in `test/requests.http`
|
||||
@@ -1,3 +0,0 @@
|
||||
service Sue {
|
||||
entity Dummy { key ID: UUID; title: String; }
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
@rest service LogService {
|
||||
|
||||
@readonly entity Loggers : Logger {};
|
||||
entity Logger {
|
||||
key id : String;
|
||||
level : String;
|
||||
}
|
||||
|
||||
action format (
|
||||
timestamp : Boolean,
|
||||
level : Boolean,
|
||||
tenant : Boolean,
|
||||
reqid : Boolean,
|
||||
id : Boolean,
|
||||
);
|
||||
|
||||
action debug (logger : String) returns Logger;
|
||||
action reset (logger : String) returns Logger;
|
||||
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
const cds = require ('@sap/cds/lib')
|
||||
const LOG = cds.log('cds.log')
|
||||
|
||||
module.exports = class LogService extends cds.Service {
|
||||
init(){
|
||||
|
||||
this.on('GET','Loggers', (req)=>{
|
||||
let loggers = Object.values(cds.log.loggers).map (_logger)
|
||||
let {$search} = req._.req.query
|
||||
if ($search) {
|
||||
const re = RegExp($search,'i')
|
||||
loggers = loggers.filter (l => re.test(l.id) || re.test(l.level))
|
||||
}
|
||||
return loggers.sort ((a,b) => a.id < b.id ? -1 : 1)
|
||||
})
|
||||
|
||||
this.on('PUT','Logger', (req)=>{
|
||||
const {id} = req.params[0] || req.data
|
||||
if (!id) return req.reject('No logger id specified in request')
|
||||
return _logger (cds.log (id, req.data))
|
||||
})
|
||||
|
||||
this.on('debug', (req)=>{
|
||||
const {logger:id} = req.params[0] || req.data
|
||||
if (!id) return req.reject('No logger id specified in request')
|
||||
return _logger (cds.log (id, {level:'debug'}))
|
||||
})
|
||||
|
||||
this.on('reset', (req)=>{
|
||||
const {logger:id} = req.params[0] || req.data
|
||||
if (!id) return req.reject('No logger id specified in request')
|
||||
return _logger (cds.log (id, {level:'info'}))
|
||||
})
|
||||
|
||||
this.on('format', (req)=>{
|
||||
const $ = req.data; LOG.info('format:',$)
|
||||
// Set format for new loggers constructed subsequently
|
||||
cds.log.format = (id, level, ...args) => {
|
||||
const fmt = []
|
||||
if ($.timestamp) fmt.push ('|', (new Date).toISOString())
|
||||
if ($.level) fmt.push ('|', _levels[level].padEnd(5))
|
||||
if ($.tenant) fmt.push ('|', cds.context && cds.context.tenant)
|
||||
if ($.reqid) fmt.push ('|', cds.context && cds.context.id)
|
||||
if ($.id) fmt.push ('|', id)
|
||||
fmt[0] = '[', fmt.push ('] -', ...args)
|
||||
return fmt
|
||||
}
|
||||
// Apply this format to all existing loggers
|
||||
Object.values(cds.log.loggers).forEach (l => l.setFormat (cds.log.format))
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const _logger = ({id,level}) => ({id, level:_levels[level] })
|
||||
const _levels = [ 'SILENT', 'ERROR', 'WARN', 'INFO', 'DEBUG', 'TRACE' ]
|
||||
@@ -1,18 +0,0 @@
|
||||
http://localhost:4004/loggers.html
|
||||
@body: = Content-Type: application/json\n\n
|
||||
|
||||
###
|
||||
GET http://localhost:4004/log/Loggers
|
||||
|
||||
###
|
||||
PUT http://localhost:4004/log/Logger/sqlite
|
||||
{{body:}} { "level": "debug" }
|
||||
|
||||
###
|
||||
POST http://localhost:4004/log/debug(logger='sqlite')
|
||||
|
||||
###
|
||||
POST http://localhost:4004/log/reset(logger='sqlite')
|
||||
|
||||
### Dummy request to see sqlite debug output
|
||||
GET http://localhost:4004/sue/Dummy
|
||||
@@ -40,7 +40,7 @@ module.exports = srv => {
|
||||
req.reject(404, 'Media not found for the ID')
|
||||
return
|
||||
}
|
||||
const decodedMedia = Buffer.from(
|
||||
const decodedMedia = new Buffer(
|
||||
mediaObj.media.split(';base64,').pop(),
|
||||
'base64'
|
||||
)
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
using { Currency, User, managed, cuid } from '@sap/cds/common';
|
||||
namespace sap.capire.orders;
|
||||
|
||||
entity Orders : cuid, managed {
|
||||
OrderNo : String(22) @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';
|
||||
@@ -1,5 +0,0 @@
|
||||
using { sap.capire.orders as my } from '../db/schema';
|
||||
|
||||
service OrdersService {
|
||||
entity Orders as projection on my.Orders;
|
||||
}
|
||||
11319
package-lock.json
generated
11319
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
34
package.json
34
package.json
@@ -5,23 +5,18 @@
|
||||
"repository": "https://github.com/sap-samples/cloud-cap-samples.git",
|
||||
"author": "daniel.hutzel@sap.com",
|
||||
"dependencies": {
|
||||
"@capire/bookstore": "./bookstore",
|
||||
"@capire/bookshop": "./bookshop",
|
||||
"@capire/common": "./common",
|
||||
"@capire/data-viewer": "./data-viewer",
|
||||
"@capire/fiori": "./fiori",
|
||||
"@capire/hello": "./hello",
|
||||
"@capire/media": "./media",
|
||||
"@capire/orders": "./orders",
|
||||
"@capire/reviews": "./reviews",
|
||||
"@sap/cds": ">=5.5.3"
|
||||
},
|
||||
"workspaces": [
|
||||
"./bookshop",
|
||||
"./bookstore",
|
||||
"./common",
|
||||
"./data-viewer",
|
||||
"./fiori",
|
||||
"./hello",
|
||||
"./media",
|
||||
"./orders",
|
||||
"./loggers",
|
||||
"./reviews"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@sap/eslint-plugin-cds": "^2.6.1",
|
||||
"axios": "^1",
|
||||
"chai": "^4.3.4",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"chai-subset": "^1.6.0",
|
||||
@@ -30,17 +25,19 @@
|
||||
},
|
||||
"scripts": {
|
||||
"cleanup": "rm -rf node_modules && rm -rf */node_modules && rm -rf */*/node_modules",
|
||||
"registry": "node .registry/server.js",
|
||||
"bookshop": "cds watch bookshop",
|
||||
"fiori": "cds watch fiori",
|
||||
"hello": "cds watch hello",
|
||||
"media": "cds watch media",
|
||||
"mocha": "CDS_TEST_SILENT=y npx mocha",
|
||||
"jest": "npx jest --silent",
|
||||
"mocha": "npx mocha || echo",
|
||||
"jest": "npx jest",
|
||||
"start": "cds watch fiori",
|
||||
"test": "npm run jest -- --silent",
|
||||
"test:hello": "cd hello && npm test"
|
||||
},
|
||||
"jest": {
|
||||
"testEnvironment": "node",
|
||||
"testTimeout": 20000,
|
||||
"testMatch": [
|
||||
"**/*.test.js"
|
||||
@@ -48,9 +45,8 @@
|
||||
},
|
||||
"mocha": {
|
||||
"recursive": true,
|
||||
"parallel": true,
|
||||
"timeout": 6666
|
||||
"parallel": true
|
||||
},
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"license": "SAP SAMPLE CODE LICENSE",
|
||||
"private": true
|
||||
}
|
||||
|
||||
@@ -2,38 +2,37 @@
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Note: this is designed for the OrdersService being co-located with
|
||||
// bookshop. It does not work if OrdersService is run as a separate
|
||||
// Note: this is designed for the PerformanceService being co-located with
|
||||
// bookshop. It does not work if PerformanceService is run as a separate
|
||||
// process, and is not intended to do so.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
using { OrdersService } from '../srv/orders-service';
|
||||
using { PerformanceService } from '../srv/performance-service';
|
||||
|
||||
|
||||
@odata.draft.enabled
|
||||
annotate OrdersService.Orders with @(
|
||||
annotate PerformanceService.Orders with @(
|
||||
UI: {
|
||||
SelectionFields: [ createdBy ],
|
||||
SelectionFields: [ createdAt, createdBy ],
|
||||
LineItem: [
|
||||
{Value: OrderNo, Label:'{i18n>OrderNo}'},
|
||||
{Value: buyer, Label:'{i18n>Customer}'},
|
||||
{Value: currency.symbol, Label:'{i18n>Currency}'},
|
||||
{Value: createdAt, Label:'{i18n>Date}'},
|
||||
{Value: OrderNo, Label:'OrderNo'},
|
||||
{Value: buyer, Label:'Customer'},
|
||||
{Value: createdAt, Label:'Date'}
|
||||
],
|
||||
HeaderInfo: {
|
||||
TypeName: '{i18n>Order}', TypeNamePlural: '{i18n>Orders}',
|
||||
TypeName: 'Order', TypeNamePlural: 'Orders',
|
||||
Title: {
|
||||
Label: '{i18n>OrderNo}', //A label is possible but it is not considered on the ObjectPage yet
|
||||
Label: 'Order number ', //A label is possible but it is not considered on the ObjectPage yet
|
||||
Value: OrderNo
|
||||
},
|
||||
Description: {Value: createdBy}
|
||||
},
|
||||
Identification: [ //Is the main field group
|
||||
{Value: createdBy, Label:'{i18n>Customer}'},
|
||||
{Value: createdAt, Label:'{i18n>Date}'},
|
||||
{Value: createdBy, Label:'Customer'},
|
||||
{Value: createdAt, Label:'Date'},
|
||||
{Value: OrderNo },
|
||||
],
|
||||
HeaderFacets: [
|
||||
@@ -46,7 +45,7 @@ annotate OrdersService.Orders with @(
|
||||
],
|
||||
FieldGroup#Details: {
|
||||
Data: [
|
||||
{Value: currency.code, Label:'{i18n>Currency}'}
|
||||
{Value: currency.code, Label:'Currency'}
|
||||
]
|
||||
},
|
||||
FieldGroup#Created: {
|
||||
@@ -65,23 +64,22 @@ annotate OrdersService.Orders with @(
|
||||
) {
|
||||
createdAt @UI.HiddenFilter:false;
|
||||
createdBy @UI.HiddenFilter:false;
|
||||
ID @UI.Hidden;
|
||||
};
|
||||
|
||||
|
||||
|
||||
annotate OrdersService.Orders.Items with @(
|
||||
annotate PerformanceService.Orders.Items with @(
|
||||
UI: {
|
||||
LineItem: [
|
||||
{Value: product_ID, Label:'{i18n>ProductID}'},
|
||||
{Value: title, Label:'{i18n>ProductTitle}'},
|
||||
{Value: price, Label:'{i18n>UnitPrice}'},
|
||||
{Value: quantity, Label:'{i18n>Quantity}'},
|
||||
{Value: product_ID, Label:'Product ID'},
|
||||
{Value: title, Label:'Product Title'},
|
||||
{Value: price, Label:'Unit Price'},
|
||||
{Value: quantity, Label:'Quantity'},
|
||||
],
|
||||
Identification: [ //Is the main field group
|
||||
{Value: quantity, Label:'{i18n>Quantity}'},
|
||||
{Value: title, Label:'{i18n>Product}'},
|
||||
{Value: price, Label:'{i18n>UnitPrice}'},
|
||||
{Value: quantity, Label:'Quantity'},
|
||||
{Value: title, Label:'Product'},
|
||||
{Value: price, Label:'Unit Price'},
|
||||
],
|
||||
Facets: [
|
||||
{$Type: 'UI.ReferenceFacet', Label: '{i18n>OrderItems}', Target: '@UI.Identification'},
|
||||
@@ -91,7 +89,4 @@ annotate OrdersService.Orders.Items with @(
|
||||
quantity @(
|
||||
Common.FieldControl: #Mandatory
|
||||
);
|
||||
ID @UI.Hidden;
|
||||
up_ @UI.Hidden;
|
||||
|
||||
};
|
||||
@@ -13,7 +13,7 @@
|
||||
applications: {
|
||||
"manage-orders": {
|
||||
title: "Manage Orders",
|
||||
description: "CAP Sample App",
|
||||
description: "... testing FE v42",
|
||||
additionalInformation: "SAPUI5.Component=orders",
|
||||
applicationType : "URL",
|
||||
url: "/orders/webapp",
|
||||
@@ -3,8 +3,8 @@
|
||||
"sap.app": {
|
||||
"id": "orders",
|
||||
"type": "application",
|
||||
"title": "Order Management",
|
||||
"description": "CAP Sample Application",
|
||||
"title": "Order Books",
|
||||
"description": "Sample Application",
|
||||
"i18n": "i18n/i18n.properties",
|
||||
"dataSources": {
|
||||
"OrdersService": {
|
||||
5
performance/db/data/sap.capire.performance-Authors.csv
Normal file
5
performance/db/data/sap.capire.performance-Authors.csv
Normal file
@@ -0,0 +1,5 @@
|
||||
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
|
||||
|
6
performance/db/data/sap.capire.performance-Books.csv
Normal file
6
performance/db/data/sap.capire.performance-Books.csv
Normal file
@@ -0,0 +1,6 @@
|
||||
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
|
||||
|
@@ -0,0 +1,5 @@
|
||||
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,4 +1,4 @@
|
||||
ID;up__ID;quantity;product_ID;title;price
|
||||
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;1;271;Catweazle;15
|
||||
e9641166-e050-4261-bfee-d1e797e6cb7f;64e718c9-ff99-47f1-8ca3-950c850777d4;2;252;Eleonora;28
|
||||
ID;Header_ID;quantity;product_ID;title;price
|
||||
58040e66-1dcd-4ffb-ab10-fdce32028b79;7e2f2640-6866-4dcf-8f4d-3027aa831cad;10;201;Wuthering Heights;11.11
|
||||
64e718c9-ff99-47f1-8ca3-950c850777d4;7e2f2640-6866-4dcf-8f4d-3027aa831cad;501;271;Catweazle;15
|
||||
e9641166-e050-4261-bfee-d1e797e6cb7f;64e718c9-ff99-47f1-8ca3-950c850777d4;499;252;Eleonora;28
|
||||
|
122
performance/db/schema.cds
Normal file
122
performance/db/schema.cds
Normal file
@@ -0,0 +1,122 @@
|
||||
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;
|
||||
}
|
||||
95
performance/srv/performance-service.cds
Normal file
95
performance/srv/performance-service.cds
Normal file
@@ -0,0 +1,95 @@
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5,6 +5,14 @@ class OrdersService extends cds.ApplicationService {
|
||||
init(){
|
||||
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) {
|
||||
const { ID, Items } = req.data
|
||||
if (Items) for (let { product_ID, quantity } of Items) {
|
||||
@@ -1,5 +1,5 @@
|
||||
ID;subject;rating;reviewer;title;text
|
||||
45167af7-8aba-4164-b296-a89461a5fb71;201;5;bob;Intriguing;Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
|
||||
2a4b02ad-5ccc-4354-9388-f8aaebef2636;201;4;bob;Fascinating;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Id diam maecenas ultricies mi eget mauris pharetra et. Risus at ultrices mi tempus imperdiet nulla malesuada pellentesque. Pulvinar mattis nunc sed blandit libero. Facilisis magna etiam tempor orci eu. Nec sagittis aliquam malesuada bibendum arcu. Eu consequat ac felis donec. Ultricies tristique nulla aliquet enim tortor at auctor urna nunc. Tortor posuere ac ut consequat semper viverra nam libero. Amet nisl suscipit adipiscing bibendum est ultricies integer quis auctor. Scelerisque purus semper eget duis at tellus. Elementum tempus egestas sed sed risus pretium. Arcu dictum varius duis at. Amet luctus venenatis lectus magna fringilla urna. Eget velit aliquet sagittis id consectetur purus ut faucibus. Vitae auctor eu augue ut lectus. Fermentum iaculis eu non diam phasellus vestibulum.
|
||||
3882af87-b2e9-48c7-945b-140f15b5e2fa;207;2;bob;What is this?;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Libero justo laoreet sit amet cursus sit amet dictum. Nunc faucibus a pellentesque sit. Dis parturient montes nascetur ridiculus mus mauris vitae ultricies. Enim nunc faucibus a pellentesque. Commodo quis imperdiet massa tincidunt nunc pulvinar sapien. Cras ornare arcu dui vivamus. Facilisi etiam dignissim diam quis enim lobortis. Et molestie ac feugiat sed. Urna neque viverra justo nec ultrices dui. Ullamcorper a lacus vestibulum sed arcu non. Volutpat ac tincidunt vitae semper quis. Dignissim sodales ut eu sem. Feugiat in fermentum posuere urna nec. At augue eget arcu dictum varius.
|
||||
eb4e934f-af77-4f72-9717-17abd3fefad8;251;3;bob;It's dark...;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Suscipit tellus mauris a diam. Velit aliquet sagittis id consectetur purus ut. Viverra adipiscing at in tellus integer. Vitae elementum curabitur vitae nunc. Mattis ullamcorper velit sed ullamcorper morbi. Diam quis enim lobortis scelerisque. Auctor neque vitae tempus quam pellentesque nec nam aliquam. Semper auctor neque vitae tempus. Quis eleifend quam adipiscing vitae proin. Neque convallis a cras semper auctor neque vitae. Imperdiet massa tincidunt nunc pulvinar sapien et ligula. Sit amet consectetur adipiscing elit ut aliquam purus. Pretium quam vulputate dignissim suspendisse.
|
||||
subject;rating;reviewer;title;text
|
||||
201;5;bob;Intriguing;Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
|
||||
201;4;bob;Fascinating;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Id diam maecenas ultricies mi eget mauris pharetra et. Risus at ultrices mi tempus imperdiet nulla malesuada pellentesque. Pulvinar mattis nunc sed blandit libero. Facilisis magna etiam tempor orci eu. Nec sagittis aliquam malesuada bibendum arcu. Eu consequat ac felis donec. Ultricies tristique nulla aliquet enim tortor at auctor urna nunc. Tortor posuere ac ut consequat semper viverra nam libero. Amet nisl suscipit adipiscing bibendum est ultricies integer quis auctor. Scelerisque purus semper eget duis at tellus. Elementum tempus egestas sed sed risus pretium. Arcu dictum varius duis at. Amet luctus venenatis lectus magna fringilla urna. Eget velit aliquet sagittis id consectetur purus ut faucibus. Vitae auctor eu augue ut lectus. Fermentum iaculis eu non diam phasellus vestibulum.
|
||||
207;2;bob;What is this?;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Libero justo laoreet sit amet cursus sit amet dictum. Nunc faucibus a pellentesque sit. Dis parturient montes nascetur ridiculus mus mauris vitae ultricies. Enim nunc faucibus a pellentesque. Commodo quis imperdiet massa tincidunt nunc pulvinar sapien. Cras ornare arcu dui vivamus. Facilisi etiam dignissim diam quis enim lobortis. Et molestie ac feugiat sed. Urna neque viverra justo nec ultrices dui. Ullamcorper a lacus vestibulum sed arcu non. Volutpat ac tincidunt vitae semper quis. Dignissim sodales ut eu sem. Feugiat in fermentum posuere urna nec. At augue eget arcu dictum varius.
|
||||
251;3;bob;It's dark...;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Suscipit tellus mauris a diam. Velit aliquet sagittis id consectetur purus ut. Viverra adipiscing at in tellus integer. Vitae elementum curabitur vitae nunc. Mattis ullamcorper velit sed ullamcorper morbi. Diam quis enim lobortis scelerisque. Auctor neque vitae tempus quam pellentesque nec nam aliquam. Semper auctor neque vitae tempus. Quis eleifend quam adipiscing vitae proin. Neque convallis a cras semper auctor neque vitae. Imperdiet massa tincidunt nunc pulvinar sapien et ligula. Sit amet consectetur adipiscing elit ut aliquam purus. Pretium quam vulputate dignissim suspendisse.
|
||||
|
20
samples.md
20
samples.md
@@ -1,13 +1,13 @@
|
||||
# Overview of Samples
|
||||
|
||||
The following list gives an overview of the samples provided in subdirectories.
|
||||
Each sub directory essentially is an individual npm package arranged in an [all-in-one monorepo](#all-in-one-monorepo) umbrella setup.
|
||||
Each sub directory essentially is an individual npm package arranged in an [all-in-one monorepo](all-in-one-monorepo) umbrella setup.
|
||||
|
||||
|
||||
## [@capire/hello-world](hello)
|
||||
|
||||
- A simplistic [Hello World](https://cap.cloud.sap/docs/get-started/hello-world) service using [CDS](https://cap.cloud.sap/docs/cds/) and [cds.services](https://cap.cloud.sap/docs/node.js/api#services-api).
|
||||
- [Typescript support](https://cap.cloud.sap/docs/node.js/typescript)
|
||||
- [Typescript support](https://cap.cloud.sap/docs/get-started/using-typescript)
|
||||
|
||||
|
||||
## [@capire/bookshop](bookshop)
|
||||
@@ -69,20 +69,14 @@ Each sub directory essentially is an individual npm package arranged in an [all-
|
||||
|
||||
## [@capire/fiori](fiori)
|
||||
|
||||
- Adds an SAP Fiori elements application to bookstore, thereby introducing:
|
||||
- OData Annotations in `.cds` files
|
||||
- Support for Fiori Draft
|
||||
- Support for Value Helps
|
||||
- [Adds an SAP Fiori elements application](https://cap.cloud.sap/docs/guides/fiori/) to bookstore, thereby introducing to:
|
||||
- [OData Annotations](https://cap.cloud.sap/docs/guides/fiori#adding-odata-annotations) in `.cds` files
|
||||
- Support for [Fiori Draft](https://cap.cloud.sap/docs/guides/fiori#draft)
|
||||
- Support for [Value Helps](https://cap.cloud.sap/docs/guides/fiori#value-help)
|
||||
- Serving SAP Fiori apps locally
|
||||
- Fiori Elements V2
|
||||
- OData V2 using CDS OData V2 Adapter Proxy
|
||||
- List Report (type `TreeTable`)
|
||||
- `@sap.hierarchy` annotations
|
||||
|
||||
See the [Serving Fiori UIs](https://cap.cloud.sap/docs/advanced/fiori) documentation for more information.
|
||||
|
||||
<br>
|
||||
|
||||
# All-in-one Monorepo
|
||||
|
||||
Each sample sub directory essentially is a standard npm package, some with standard npm dependencies to other samples. The root folder's [package.json](package.json) has local links to the sub folders, such that an `npm install` populates a local `node_modules` folder and acts like a local npm registry to the individual sample packages.
|
||||
Each sample sub directory essentially is a standard npm package, some with standard npm dependencies to other samples. The root folder's [package.json](package.json) has local links to the sub folders, such that an `npm install` populates a local `node_modules` folder acts like a local npm registry to the individual sample packages.
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
const cds = require('@sap/cds/lib')
|
||||
const { expect } = cds.test
|
||||
const { cdr } = cds.ql
|
||||
const Foo = { name: 'Foo' }
|
||||
const Books = { name: 'capire.bookshop.Books' }
|
||||
|
||||
|
||||
const STAR = cdr ? '*' : { ref: ['*'] }
|
||||
const skip = {to:{eql:()=>skip}}
|
||||
const srv = new cds.Service
|
||||
let cqn
|
||||
|
||||
expect.plain = (cqn) => !cqn.SELECT.one && !cqn.SELECT.distinct ? expect(cqn) : skip
|
||||
expect.one = (cqn) => !cqn.SELECT.distinct ? expect(cqn) : skip
|
||||
|
||||
describe('cds.ql → cqn', () => {
|
||||
|
||||
const cds = require('@sap/cds/lib')
|
||||
const { expect } = cds.test
|
||||
const Foo = { name: 'Foo' }
|
||||
const Books = { name: 'capire.bookshop.Books' }
|
||||
|
||||
const STAR = '*'
|
||||
const skip = {to:{eql:()=>skip}}
|
||||
const srv = new cds.Service
|
||||
let cqn
|
||||
|
||||
expect.plain = (cqn) => !cqn.SELECT.one && !cqn.SELECT.distinct ? expect(cqn) : skip
|
||||
expect.one = (cqn) => !cqn.SELECT.distinct ? expect(cqn) : skip
|
||||
//
|
||||
|
||||
describe.each(['SELECT', 'SELECT one', 'SELECT distinct'])(`%s...`, (each) => {
|
||||
|
||||
@@ -184,7 +187,7 @@ describe('cds.ql → cqn', () => {
|
||||
}},
|
||||
})
|
||||
|
||||
expect.plain (cqn)
|
||||
if (cdr) expect.plain (cqn)
|
||||
.to.eql(SELECT`Foo[ID=${11}]`)
|
||||
.to.eql(srv.read`Foo[ID=${11}]`)
|
||||
|
||||
@@ -241,7 +244,7 @@ describe('cds.ql → cqn', () => {
|
||||
},
|
||||
})
|
||||
|
||||
expect.plain(cqn)
|
||||
cdr && expect.plain(cqn)
|
||||
.to.eql(CQL`SELECT *,a,b as c from Foo`)
|
||||
.to.eql(CQL`SELECT from Foo {*,a,b as c}`)
|
||||
|
||||
@@ -340,7 +343,7 @@ describe('cds.ql → cqn', () => {
|
||||
expect(SELECT.from(Foo).where({ x: 1, and: { y: 2, or: { z: 3 } } })).to.eql({
|
||||
SELECT: {
|
||||
from: { ref: ['Foo'] },
|
||||
where: [
|
||||
where: cdr ? [
|
||||
{ ref: ['x'] },
|
||||
'=',
|
||||
{ val: 1 },
|
||||
@@ -356,12 +359,29 @@ describe('cds.ql → cqn', () => {
|
||||
{ val: 3 },
|
||||
]},
|
||||
// ')',
|
||||
] : [
|
||||
{ ref: ['x'] },
|
||||
'=',
|
||||
{ val: 1 },
|
||||
'and',
|
||||
'(',
|
||||
// {xpr:[
|
||||
{ ref: ['y'] },
|
||||
'=',
|
||||
{ val: 2 },
|
||||
'or',
|
||||
{ ref: ['z'] },
|
||||
'=',
|
||||
{ val: 3 },
|
||||
// ]},
|
||||
')',
|
||||
],
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
test ("where x='*'", ()=>{
|
||||
if (cdr)
|
||||
expect (SELECT.from(Foo).where({x:'*'}))
|
||||
.to.eql(SELECT.from(Foo).where("x='*'"))
|
||||
.to.eql(SELECT.from(Foo).where("x=",'*'))
|
||||
@@ -369,6 +389,7 @@ describe('cds.ql → cqn', () => {
|
||||
.to.eql(
|
||||
CQL`SELECT from Foo where x='*'`
|
||||
)
|
||||
if (cdr)
|
||||
expect (SELECT.from(Foo).where({x:['*',1]}))
|
||||
.to.eql(SELECT.from(Foo).where("x in ('*',1)"))
|
||||
.to.eql(SELECT.from(Foo).where("x in",['*',1]))
|
||||
@@ -392,87 +413,38 @@ describe('cds.ql → cqn', () => {
|
||||
]
|
||||
}})
|
||||
|
||||
const ql_with_groups_fix = !!cds.ql.Query.prototype.flat
|
||||
if (ql_with_groups_fix) {
|
||||
|
||||
expect (
|
||||
SELECT.from(Foo).where({x:1}).or({y:2}).and({z:3})
|
||||
SELECT.from(Foo).where({x:1,or:{y:2}})
|
||||
).to.eql (
|
||||
CQL`SELECT from Foo where x=1 or y=2`
|
||||
).to.eql ({ SELECT: {
|
||||
from: {ref:['Foo']},
|
||||
where: [
|
||||
{ref:['x']}, '=', {val:1},
|
||||
'or',
|
||||
{ref:['y']}, '=', {val:2},
|
||||
'and',
|
||||
{ref:['z']}, '=', {val:3},
|
||||
{ref:['y']}, '=', {val:2}
|
||||
]
|
||||
}})
|
||||
|
||||
expect (
|
||||
SELECT.from(Foo).where({x:1,or:{y:2}}).and({z:3})
|
||||
).to.eql ({ SELECT: {
|
||||
from: {ref:['Foo']},
|
||||
where: [
|
||||
{xpr:[
|
||||
{ref:['x']}, '=', {val:1},
|
||||
'or',
|
||||
{ref:['y']}, '=', {val:2},
|
||||
]},
|
||||
'and',
|
||||
{ref:['z']}, '=', {val:3},
|
||||
]
|
||||
}})
|
||||
|
||||
expect (
|
||||
SELECT.from(Foo).where({a:1}).or({x:1,or:{y:2}}).and({z:3})
|
||||
).to.eql ({ SELECT: {
|
||||
from: {ref:['Foo']},
|
||||
where: [
|
||||
{ref:['a']}, '=', {val:1},
|
||||
'or',
|
||||
{xpr:[
|
||||
{ref:['x']}, '=', {val:1},
|
||||
'or',
|
||||
{ref:['y']}, '=', {val:2},
|
||||
]},
|
||||
'and',
|
||||
{ref:['z']}, '=', {val:3},
|
||||
]
|
||||
}})
|
||||
|
||||
expect (
|
||||
{ SELECT: SELECT.from(Foo).where({x:1,or:{y:2}}).SELECT }
|
||||
).to.eql ({ SELECT: {
|
||||
from: {ref:['Foo']},
|
||||
where: [
|
||||
{ref:['x']}, '=', {val:1},
|
||||
'or',
|
||||
{ref:['y']}, '=', {val:2},
|
||||
]
|
||||
}})
|
||||
|
||||
}
|
||||
|
||||
|
||||
expect (
|
||||
SELECT.from(Foo).where({x:1,and:{y:2}}).or({z:3})
|
||||
).to.eql (
|
||||
CQL`SELECT from Foo where x=1 and y=2 or z=3`
|
||||
)
|
||||
|
||||
expect (
|
||||
if (cdr) expect (
|
||||
SELECT.from(Foo).where({x:1}).and({y:2,or:{z:3}})
|
||||
).to.eql (
|
||||
CQL`SELECT from Foo where x=1 and ( y=2 or z=3 )`
|
||||
)
|
||||
|
||||
expect (
|
||||
if (cdr) expect (
|
||||
SELECT.from(Foo).where({1:1}).and({x:1,or:{x:2}}).and({y:2,or:{z:3}})
|
||||
).to.eql (
|
||||
CQL`SELECT from Foo where 1=1 and ( x=1 or x=2 ) and ( y=2 or z=3 )`
|
||||
)
|
||||
|
||||
expect (
|
||||
if (cdr) expect (
|
||||
SELECT.from(Foo).where({x:1,or:{x:2}}).and({y:2,or:{z:3}})
|
||||
).to.eql (
|
||||
CQL`SELECT from Foo where ( x=1 or x=2 ) and ( y=2 or z=3 )`
|
||||
@@ -480,7 +452,7 @@ describe('cds.ql → cqn', () => {
|
||||
})
|
||||
|
||||
test('where ({x:[undefined]})', () => {
|
||||
expect (
|
||||
if (cdr) expect (
|
||||
SELECT.from(Foo).where({x:[undefined]})
|
||||
).to.eql ({ SELECT: {
|
||||
from: {ref:['Foo']},
|
||||
@@ -507,7 +479,7 @@ describe('cds.ql → cqn', () => {
|
||||
).to.eql({
|
||||
SELECT: {
|
||||
from: { ref: ['Foo'] },
|
||||
where: [
|
||||
where: cdr ? [
|
||||
{ ref: ['ID'] },
|
||||
'=',
|
||||
{ val: ID },
|
||||
@@ -527,6 +499,24 @@ describe('cds.ql → cqn', () => {
|
||||
{ val: 9 },
|
||||
]
|
||||
},
|
||||
] : [
|
||||
{ ref: ['ID'] },
|
||||
'=',
|
||||
{ val: ID },
|
||||
'and',
|
||||
{ ref: ['args'] },
|
||||
'in',
|
||||
{ list: args.map(val => ({ val })) },
|
||||
'and',
|
||||
'(',
|
||||
{ ref: ['x'] },
|
||||
'like',
|
||||
{ val: '%x%' },
|
||||
'or',
|
||||
{ ref: ['y'] },
|
||||
'>=',
|
||||
{ val: 9 },
|
||||
')',
|
||||
],
|
||||
}
|
||||
})
|
||||
@@ -620,6 +610,7 @@ describe('cds.ql → cqn', () => {
|
||||
})
|
||||
|
||||
it('should consistently handle *', () => {
|
||||
if (!cdr) return
|
||||
expect({
|
||||
SELECT: { from: { ref: ['Foo'] }, columns: ['*'] },
|
||||
})
|
||||
@@ -630,6 +621,7 @@ describe('cds.ql → cqn', () => {
|
||||
})
|
||||
|
||||
it('should consistently handle lists', () => {
|
||||
if (!cdr) return
|
||||
const ID = 11, args = [{ref:['foo']}, "bar", 3]
|
||||
const cqn = CQL`SELECT from Foo where ID=11 and x in (foo,'bar',3)`
|
||||
expect(SELECT.from(Foo).where`ID=${ID} and x in ${args}`).to.eql(cqn)
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
const cds = require('@sap/cds/lib')
|
||||
const { expect } = cds.test ('@capire/bookshop')
|
||||
|
||||
describe('cap/samples - Consuming Services locally', () => {
|
||||
|
||||
const { expect } = cds.test ('@capire/bookshop')
|
||||
|
||||
//
|
||||
it('bootstrapped the database successfully', ()=>{
|
||||
const { AdminService } = cds.services
|
||||
const { Authors } = AdminService.entities
|
||||
@@ -15,7 +14,7 @@ describe('cap/samples - Consuming Services locally', () => {
|
||||
const AdminService = await cds.connect.to('AdminService')
|
||||
const { Authors } = AdminService.entities
|
||||
expect (await SELECT.from(Authors))
|
||||
// .to.eql(await SELECT.from('Authors'))
|
||||
.to.eql(await SELECT.from('Authors'))
|
||||
.to.eql(await AdminService.read(Authors))
|
||||
.to.eql(await AdminService.read('Authors'))
|
||||
.to.eql(await AdminService.run(SELECT.from(Authors)))
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
const cds = require('@sap/cds/lib')
|
||||
const { GET, POST, expect } = cds.test(__dirname+'/../bookshop')
|
||||
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 - Custom Handlers', () => {
|
||||
|
||||
const { GET, POST, expect } = cds.test(__dirname+'/../bookshop')
|
||||
beforeAll(()=>{
|
||||
cds.User.default = cds.User.Privileged // hard core monkey patch
|
||||
})
|
||||
|
||||
it('should reject out-of-stock orders', async () => {
|
||||
await POST `/browse/submitOrder ${{ book: 201, quantity: 5 }}`
|
||||
await POST `/browse/submitOrder ${{ book: 201, quantity: 5 }}`
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
const cds = require('@sap/cds/lib')
|
||||
|
||||
describe('cap/samples - Fiori APIs - v2', function() {
|
||||
|
||||
const { GET, expect, axios } = cds.test ('@capire/fiori', '--with-mocks')
|
||||
axios.defaults.auth = { username: 'alice', password: 'admin' }
|
||||
|
||||
// if (this.timeout) this.timeout(1e6)
|
||||
|
||||
it('serves $metadata documents in v2', async () => {
|
||||
const { headers, data } = await GET `/v2/browse/$metadata`
|
||||
expect(headers).to.contain({
|
||||
'content-type': 'application/xml',
|
||||
'dataserviceversion': '2.0',
|
||||
})
|
||||
expect(data).to.contain('<EntitySet Name="GenreHierarchy" EntityType="CatalogService.GenreHierarchy"/>')
|
||||
})
|
||||
|
||||
it('serves Books in v2', async () => {
|
||||
const { data } = await GET `/v2/browse/Books`
|
||||
expect(data).to.containSubset({d:{results:[]}})
|
||||
expect(data.d.results.length).to.be.greaterThanOrEqual(5)
|
||||
})
|
||||
|
||||
})
|
||||
@@ -1,9 +1,8 @@
|
||||
const cds = require('@sap/cds/lib')
|
||||
const { GET, expect } = cds.test (__dirname+'/../hello')
|
||||
|
||||
describe('cap/samples - Hello world!', () => {
|
||||
|
||||
const { GET, expect } = cds.test (__dirname+'/../hello')
|
||||
|
||||
it('should say hello with class impl', async () => {
|
||||
const {data} = await GET `/say/hello(to='world')`
|
||||
expect(data.value).to.eql('Hello world!')
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
const cds = require('@sap/cds/lib')
|
||||
const {expect} = cds.test
|
||||
|
||||
describe('cap/samples - Hierarchical Data', ()=>{
|
||||
|
||||
const csn = CDL`
|
||||
// should become cds.compile(...) when cds5 is released
|
||||
const model = cds.compile.to.csn (`
|
||||
entity Categories {
|
||||
key ID : Integer;
|
||||
name : String;
|
||||
children : Composition of many Categories on children.parent = $self;
|
||||
parent : Association to Categories;
|
||||
}
|
||||
`
|
||||
const model = cds.compile.for.nodejs(csn)
|
||||
const {Categories:Cats} = model.definitions
|
||||
const {expect} = cds.test
|
||||
`)
|
||||
const {Categories:Cats} = model.definitions
|
||||
|
||||
|
||||
describe('cap/samples - Hierarchical Data', ()=>{
|
||||
|
||||
before ('bootstrap sqlite in-memory db...', async()=>{
|
||||
await cds.deploy (csn) .to ('sqlite::memory:') // REVISIT: cds.compile.to.sql should accept cds.compiled.for.nodejs models
|
||||
await cds.deploy (model) .to ('sqlite::memory:')
|
||||
expect (cds.db) .to.exist
|
||||
expect (cds.db.model) .to.exist
|
||||
})
|
||||
|
||||
@@ -1,16 +1,23 @@
|
||||
const cds = require('@sap/cds/lib')
|
||||
const { GET, expect, cds } = require('@sap/cds/lib').test (__dirname)
|
||||
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 - Localized Data', () => {
|
||||
|
||||
const { GET, expect } = cds.test (__dirname)
|
||||
beforeAll(()=>{
|
||||
cds.User.default = cds.User.Privileged // hard core monkey patch
|
||||
it('serves localized $metadata documents', async () => {
|
||||
const { data } = await GET`/browse/$metadata?sap-language=de`
|
||||
expect(data).to.contain('<Annotation Term="Common.Label" String="Währung"/>')
|
||||
})
|
||||
|
||||
|
||||
it('serves localized $metadata documents', async () => {
|
||||
const { data } = await GET(`/browse/$metadata?sap-language=de`, { headers: { 'accept-language': 'de' }})
|
||||
expect(data).to.contain('<Annotation Term="Common.Label" String="Währung"/>')
|
||||
it('supports sap-language param', async () => {
|
||||
const { data } = await GET(`/browse/Books?$select=title,author` + '&sap-language=de')
|
||||
expect(data.value).to.containSubset([
|
||||
{ title: 'Sturmhöhe', author: 'Emily Brontë' },
|
||||
{ title: 'Jane Eyre', author: 'Charlotte Brontë' },
|
||||
{ title: 'The Raven', author: 'Edgar Allen Poe' },
|
||||
{ title: 'Eleonora', author: 'Edgar Allen Poe' },
|
||||
{ title: 'Catweazle', author: 'Richard Carpenter' },
|
||||
])
|
||||
})
|
||||
|
||||
it('supports accept-language header', async () => {
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
const cds = require('@sap/cds/lib')
|
||||
const { expect } = cds.test
|
||||
const _model = '@capire/reviews'
|
||||
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 - Messaging', ()=>{
|
||||
|
||||
const { expect } = cds.test.in(__dirname,'..')
|
||||
const _model = '@capire/reviews'
|
||||
const Reviews = 'sap.capire.reviews.Reviews'
|
||||
beforeAll(()=>{
|
||||
cds.User.default = cds.User.Privileged // hard core monkey patch
|
||||
})
|
||||
|
||||
it ('should bootstrap sqlite in-memory db', async()=>{
|
||||
const db = await cds.deploy (_model) .to ('sqlite::memory:')
|
||||
await db.delete(Reviews)
|
||||
await db.delete('Reviews')
|
||||
expect (db.model) .not.undefined
|
||||
})
|
||||
|
||||
@@ -32,7 +29,6 @@ describe('cap/samples - Messaging', ()=>{
|
||||
|
||||
it ('should add review', async ()=>{
|
||||
const review = { subject: "201", title: "Captivating", rating: ++N }
|
||||
cds._debug = 1
|
||||
const response = await srv.create ('Reviews') .entries (review)
|
||||
expect (response) .to.containSubset (review)
|
||||
})
|
||||
|
||||
@@ -1,8 +1,49 @@
|
||||
const cds = require('@sap/cds/lib')
|
||||
const { GET, expect, axios } = cds.test ('@capire/bookshop')
|
||||
axios.defaults.auth = { username: 'alice', password: 'admin' }
|
||||
|
||||
describe('cap/samples - Bookshop APIs', () => {
|
||||
const { GET, expect, axios } = cds.test ('@capire/bookshop')
|
||||
axios.defaults.auth = { username: 'alice', password: 'admin' }
|
||||
|
||||
// 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 () => {
|
||||
const { headers, status, data } = await GET `/browse/$metadata`
|
||||
@@ -16,15 +57,12 @@ describe('cap/samples - Bookshop APIs', () => {
|
||||
})
|
||||
|
||||
it('serves ListOfBooks?$expand=genre,currency', async () => {
|
||||
const Mystery = { ID: 16, name: 'Mystery', descr: null, parent_ID: 10 }
|
||||
const Romance = { ID: 15, name: 'Romance', descr: null, parent_ID: 10 }
|
||||
const USD = { code: 'USD', name: 'US Dollar', descr: null, symbol: '$' }
|
||||
const { data } = await GET `/browse/ListOfBooks ${{
|
||||
params: { $search: 'Po', $select: `title,author`, $expand:`genre,currency` },
|
||||
}}`
|
||||
expect(data.value).to.containSubset([
|
||||
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:Romance, currency:USD },
|
||||
{ ID: 252, title: 'Eleonora', author: 'Edgar Allen Poe', genre:Mystery, currency:USD },
|
||||
])
|
||||
})
|
||||
|
||||
@@ -32,7 +70,7 @@ describe('cap/samples - Bookshop APIs', () => {
|
||||
const { data } = await GET `/browse/Books ${{
|
||||
params: { $search: 'Po', $select: `title,author` },
|
||||
}}`
|
||||
expect(data.value).to.containSubset([
|
||||
expect(data.value).to.eql([
|
||||
{ ID: 201, title: 'Wuthering Heights', author: 'Emily Brontë' },
|
||||
{ ID: 207, title: 'Jane Eyre', author: 'Charlotte Brontë' },
|
||||
{ ID: 251, title: 'The Raven', author: 'Edgar Allen Poe' },
|
||||
@@ -44,7 +82,7 @@ describe('cap/samples - Bookshop APIs', () => {
|
||||
const { data } = await GET(`/browse/Books`, {
|
||||
params: { $select: `ID,title` },
|
||||
})
|
||||
expect(data.value).to.containSubset([
|
||||
expect(data.value).to.eql([
|
||||
{ ID: 201, title: 'Wuthering Heights' },
|
||||
{ ID: 207, title: 'Jane Eyre' },
|
||||
{ ID: 251, title: 'The Raven' },
|
||||
@@ -75,23 +113,27 @@ describe('cap/samples - Bookshop APIs', () => {
|
||||
|
||||
it('supports $top/$skip paging', async () => {
|
||||
const { data: p1 } = await GET`/browse/Books?$select=title&$top=3`
|
||||
expect(p1.value).to.containSubset([
|
||||
expect(p1.value).to.eql([
|
||||
{ ID: 201, title: 'Wuthering Heights' },
|
||||
{ ID: 207, title: 'Jane Eyre' },
|
||||
{ ID: 251, title: 'The Raven' },
|
||||
])
|
||||
const { data: p2 } = await GET`/browse/Books?$select=title&$skip=3`
|
||||
expect(p2.value).to.containSubset([
|
||||
expect(p2.value).to.eql([
|
||||
{ ID: 252, title: 'Eleonora' },
|
||||
{ ID: 271, title: 'Catweazle' },
|
||||
])
|
||||
})
|
||||
|
||||
it('serves user info', async () => {
|
||||
const { data: alice } = await GET `/user/me`
|
||||
expect(alice).to.containSubset({ id: 'alice', locale:'en' })
|
||||
const { data: joe } = await GET (`/user/me`, {auth: { username: 'joe' }})
|
||||
expect(joe).to.containSubset({ id: 'joe', locale:'en' })
|
||||
{
|
||||
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 })
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
55
test/registry.test.js
Normal file
55
test/registry.test.js
Normal file
@@ -0,0 +1,55 @@
|
||||
|
||||
const cds = require('@sap/cds/lib')
|
||||
const { expect } = cds.test
|
||||
const { fork } = require('child_process')
|
||||
const { resolve } = require('path')
|
||||
const verbose = process.env.CDS_TEST_VERBOSE
|
||||
// ||true
|
||||
|
||||
describe('cap/samples - Local NPM registry', () => {
|
||||
let registry
|
||||
let axios
|
||||
const cwd = resolve(__dirname, '..')
|
||||
|
||||
before(async ()=> {
|
||||
const env = Object.assign(process.env, {PORT:'0'})
|
||||
const res = await exec (resolve(cwd, '.registry/server.js'), {cwd, stdio: 'pipe', env})
|
||||
registry = res.cp
|
||||
axios = require('axios').default.create ({ baseURL: res.url, validateStatus: (status)=>status<500 })
|
||||
})
|
||||
|
||||
after(() => { registry.kill() })
|
||||
|
||||
for (const mod of ['bookshop', 'data-viewer', 'fiori','orders','reviews']) {
|
||||
it(`should serve ${mod}`, async () => {
|
||||
const resp = await axios.get(`/@capire/${mod}`)
|
||||
expect(resp.data).to.containSubset({name: `@capire/${mod}`, versions:{}})
|
||||
const versions = Object.values(resp.data.versions)
|
||||
await axios.get(versions[0].dist.tarball)
|
||||
})
|
||||
}
|
||||
it(`should return 404 for unknown packages`, async () => {
|
||||
let resp = await axios.get(`/@capire/foo`)
|
||||
expect(resp.status).to.equal(404)
|
||||
resp = await axios.get(`/foo`)
|
||||
expect(resp.status).to.equal(404)
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
function exec (script, opts) {
|
||||
return new Promise((resolve, reject)=> {
|
||||
const cp = fork (script, [], opts)
|
||||
.on('error', err => reject(new Error(err)))
|
||||
cp.stdout.on('data', chunk => {
|
||||
if (verbose) console.log(chunk.toString())
|
||||
if (chunk.toString().match(/listening.*(http:.*:\d+)/i)) {
|
||||
resolve({cp, url:RegExp.$1})
|
||||
}
|
||||
})
|
||||
cp.stderr.on('data', chunk => {
|
||||
if (verbose) console.error(chunk.toString())
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user