Compare commits
2 Commits
dependabot
...
typed-samp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d41f8e4ec | ||
|
|
f891be5251 |
2425
.deploy/app-router/package-lock.json
generated
2425
.deploy/app-router/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"name": "approuter",
|
||||
"dependencies": {
|
||||
"@sap/approuter": "^20.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node node_modules/@sap/approuter/approuter.js"
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
../../../bookshop/app/vue
|
||||
@@ -1 +0,0 @@
|
||||
../../../orders/app/orders
|
||||
@@ -1 +0,0 @@
|
||||
../../../reviews/app/vue
|
||||
@@ -1,41 +0,0 @@
|
||||
{
|
||||
"welcomeFile": "app/bookshop/index.html",
|
||||
"routes": [
|
||||
{
|
||||
"source": "^/app/(.*)$",
|
||||
"target": "$1",
|
||||
"localDir": "resources",
|
||||
"cacheControl": "no-cache, no-store, must-revalidate"
|
||||
},
|
||||
{
|
||||
"source": "^/admin/(.*)$",
|
||||
"target": "/admin/$1",
|
||||
"destination": "bookstore-api",
|
||||
"csrfProtection": true
|
||||
},
|
||||
{
|
||||
"source": "^/browse/(.*)$",
|
||||
"target": "/browse/$1",
|
||||
"destination": "bookstore-api",
|
||||
"csrfProtection": true
|
||||
},
|
||||
{
|
||||
"source": "^/user/(.*)$",
|
||||
"target": "/user/$1",
|
||||
"destination": "bookstore-api",
|
||||
"csrfProtection": true
|
||||
},
|
||||
{
|
||||
"source": "^/odata/v4/orders/(.*)$",
|
||||
"target": "/odata/v4/orders/$1",
|
||||
"destination": "orders-api",
|
||||
"csrfProtection": true
|
||||
},
|
||||
{
|
||||
"source": "^/reviews/(.*)$",
|
||||
"target": "/reviews/$1",
|
||||
"destination": "reviews-api",
|
||||
"csrfProtection": true
|
||||
}
|
||||
]
|
||||
}
|
||||
28
.eslintrc
Normal file
28
.eslintrc
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"extends": "eslint:recommended",
|
||||
"env": {
|
||||
"browser": true,
|
||||
"node": true,
|
||||
"es6": true,
|
||||
"jest": true,
|
||||
"mocha": true
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2020
|
||||
},
|
||||
"globals": {
|
||||
"SELECT": true,
|
||||
"INSERT": true,
|
||||
"UPDATE": true,
|
||||
"DELETE": true,
|
||||
"CREATE": true,
|
||||
"DROP": true,
|
||||
"cds": true
|
||||
},
|
||||
"rules": {
|
||||
"no-console": "off",
|
||||
"require-atomic-updates": "off",
|
||||
"require-await":"warn",
|
||||
"no-unused-vars": ["warn", { "argsIgnorePattern": "_" }]
|
||||
}
|
||||
}
|
||||
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
|
||||
17
.github/dependabot.yml
vendored
17
.github/dependabot.yml
vendored
@@ -5,19 +5,4 @@ updates:
|
||||
directory: /
|
||||
versioning-strategy: increase-if-necessary
|
||||
schedule:
|
||||
interval: weekly
|
||||
groups:
|
||||
production-dependencies:
|
||||
dependency-type: "production"
|
||||
development-dependencies:
|
||||
dependency-type: "development"
|
||||
ignore:
|
||||
- dependency-name: "chai"
|
||||
# chai 5 doesn't work atm w/ cds.test, TODO fix that in cds.test
|
||||
versions: ["5.x"]
|
||||
- dependency-name: "chai-as-promised"
|
||||
# chai-as-promised 8 doesn't work atm w/ cds.test, TODO fix that in cds.test
|
||||
versions: ["8.x"]
|
||||
- dependency-name: "express"
|
||||
# express 5 not supported atm
|
||||
versions: ["5.x"]
|
||||
interval: daily
|
||||
|
||||
19
.github/workflows/node.js.yml
vendored
19
.github/workflows/node.js.yml
vendored
@@ -11,28 +11,19 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [22.x, 20.x]
|
||||
node-version: [16.x, 14.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v2
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- run: npm i -g npm@8
|
||||
- run: npm ci
|
||||
- run: npm test
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22.x
|
||||
- run: npm ci
|
||||
- run: npm run lint
|
||||
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -18,8 +18,3 @@ reviews/msg-box
|
||||
reviews/db/test.db
|
||||
|
||||
*.openapi3.json
|
||||
*.sqlite
|
||||
*.db
|
||||
|
||||
@types/
|
||||
@cds-models/
|
||||
|
||||
3
.npmrc
Normal file
3
.npmrc
Normal file
@@ -0,0 +1,3 @@
|
||||
# Ensure we always use public packages, i.e. avoid using local registries from ~/.npmrc
|
||||
@sap:registry=https://registry.npmjs.org/
|
||||
registry=https://registry.npmjs.org/
|
||||
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)
|
||||
@@ -24,6 +24,6 @@ Disclaimer: The code in this project may include calls to APIs (“API Calls”)
|
||||
you any rights to use or access any SAP External Product, or provide any third
|
||||
parties the right to use of access any SAP External Product, through API Calls.
|
||||
|
||||
Files: *.*
|
||||
Copyright: 2019-2025 SAP SE or an SAP affiliate company and cap-cloud-samples
|
||||
Files: *
|
||||
Copyright: 2019-2020 SAP SE or an SAP affiliate company and cap-cloud-samples
|
||||
License: Apache-2.0
|
||||
|
||||
117
.tours/db-native.tour
Normal file
117
.tours/db-native.tour
Normal file
@@ -0,0 +1,117 @@
|
||||
{
|
||||
"$schema": "https://aka.ms/codetour-schema",
|
||||
"title": "Database Functions",
|
||||
"steps": [
|
||||
{
|
||||
"title": "Introduction",
|
||||
"description": "### Database Functions in CDS Models\n\nIn this tour, you'll learn how to add database-specific functions to CDS models in your application."
|
||||
},
|
||||
{
|
||||
"file": "bookshop/db/schema.cds",
|
||||
"description": "#### Basic Schema\n\nWe want to add two fields to the `Authors` entity, one for the author's age and one for the span of years that she or he lived.\n\nThese two fields can be computed out of the existing `dateOfBirth` and `dateOfDeath` fields.",
|
||||
"selection": {
|
||||
"start": {
|
||||
"line": 19,
|
||||
"character": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 21,
|
||||
"character": 1
|
||||
}
|
||||
},
|
||||
"title": "Base fields in Author"
|
||||
},
|
||||
{
|
||||
"file": "bookshop/srv/admin-service.cds",
|
||||
"description": "This is how the `Authors` entity gets exposed in an OData or REST service.\n\nIn the next step, you'll see how we extend this projection.",
|
||||
"selection": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"character": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"character": 1
|
||||
}
|
||||
},
|
||||
"title": "Authors service"
|
||||
},
|
||||
{
|
||||
"file": "fiori/db/sqlite/index.cds",
|
||||
"description": "#### SQLite Implementation\n\nHere's the first implementation for SQLite. It computes the two fields `age` and `lifetime` through SQLite's [strftime](https://sqlite.org/lang_datefunc.html) function.\n\nThrough the [`extend projection`](https://cap.cloud.sap/docs/cds/cdl#extend-view) clause you can add additional fields to projection entities. These are deployed as database views, which is why we can integrate the database functions in the first place.\n",
|
||||
"selection": {
|
||||
"start": {
|
||||
"line": 7,
|
||||
"character": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 11,
|
||||
"character": 1
|
||||
}
|
||||
},
|
||||
"title": "SQLite implementation"
|
||||
},
|
||||
{
|
||||
"file": "fiori/db/hana/index.cds",
|
||||
"description": "#### SAP HANA Implementation\n\nThis is the second implementation for SAP HANA. It computes the same two fields `age` and `lifetime` through the [YEARS_BETWEEN](https://help.sap.com/viewer/7c78579ce9b14a669c1f3295b0d8ca16/Cloud/en-US/7c0d2c161ea34def86de3f5eadd6a0af.html) and [YEAR](https://help.sap.com/viewer/7c78579ce9b14a669c1f3295b0d8ca16/Cloud/en-US/20f5fac6751910148dabd3c6821f907d.html) functions of SAP HANA.\n\n#### File Layout and Code Structure\n\nNote the path of the `.cds` file we are in: it's in a subfolder of `db`, so that it's _not_ automatically picked up when we start the application. The same is true for the SQLite implementation: it's in a separate `db/sqlite/` folder as well. In the next step, you'll see how these files are loaded.\n\nAlso, we choose to implement all of that as an extension of the original bookshop here in the _fiori_ package. See the first [CAP Samples] code tour for more details on the different packages of this repository.",
|
||||
"selection": {
|
||||
"start": {
|
||||
"line": 7,
|
||||
"character": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 11,
|
||||
"character": 1
|
||||
}
|
||||
},
|
||||
"title": "SAP HANA implementation"
|
||||
},
|
||||
{
|
||||
"file": "fiori/package.json",
|
||||
"description": "#### Configuration\n\nThe `cds.requires` section in `package.json` is a place to configure which of the `db/sqlite` and `db/hana` folders are used for which database.\n\nWe use [Node.js profiles](https://cap.cloud.sap/docs/node.js/cds-env#profiles) to separate the configuration.\nIn the `development` profile, you can see that `db/sqlite` is set as the model, while the `db/hana` folder is configured in the `production` profile. `db-ext` is a pseudo datasource, its name doesn't matter.\n\nSee [`cds.resolve`](https://cap.cloud.sap/docs/node.js/cds-compile#cds-resolve) to learn more about how models are found.",
|
||||
"selection": {
|
||||
"start": {
|
||||
"line": 41,
|
||||
"character": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 48,
|
||||
"character": 1
|
||||
}
|
||||
},
|
||||
"title": "Configuration"
|
||||
},
|
||||
{
|
||||
"file": "fiori/package.json",
|
||||
"description": "#### Run with SQLite\n\nTo run with `development` and an in-memory SQLite database, you don't need to do anything special, because it's activated by default. Just run:\n\n>> cds watch fiori\n\nThen open [http://localhost:4004/admin/Authors](http://localhost:4004/admin/Authors) to see the two new fields.\n",
|
||||
"line": 43,
|
||||
"title": "Run with SQLite"
|
||||
},
|
||||
{
|
||||
"file": "fiori/package.json",
|
||||
"description": "#### Deploy the CDS Model to SAP HANA\n\nTo 'activate' SAP HANA through the `production` profile, you can use the global `--production` flag:\n\n>> cd fiori; cds deploy --to hana --production\n\n[Learn more about SAP HANA deployment](https://cap.cloud.sap/docs/guides/databases#get-hana)\n\n#### Run the Application\n\n>> cd fiori; cds watch --production\n\nThe service on [http://localhost:4004/admin/Authors](http://localhost:4004/admin/Authors) is the same as before, but this time the `Authors` entity is backed by a database view with an SAP HANA function.\n\n#### More\n\nIf you don't see data, you can add some in the next step.",
|
||||
"line": 46,
|
||||
"title": "Run with SAP HANA"
|
||||
},
|
||||
{
|
||||
"file": "fiori/test/requests.http",
|
||||
"description": "### Add More Data\n\nOptionally you can add some `Authors` data by clicking on the _Send Request_ link (provided by the [REST client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client) extension).",
|
||||
"line": 72,
|
||||
"selection": {
|
||||
"start": {
|
||||
"line": 67,
|
||||
"character": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 73,
|
||||
"character": 1
|
||||
}
|
||||
},
|
||||
"title": "Add Data"
|
||||
},
|
||||
{
|
||||
"title": "Wrap-up",
|
||||
"description": "### Summary\n\nThat's it! You have seen: \n- How to integrate database-specific functions in a CDS model.\n- How to switch between the two implementations for SQLite and SAP HANA."
|
||||
}
|
||||
]
|
||||
}
|
||||
139
.tours/samples.tour
Normal file
139
.tours/samples.tour
Normal file
@@ -0,0 +1,139 @@
|
||||
{
|
||||
"$schema": "https://aka.ms/codetour-schema",
|
||||
"title": "CAP Samples",
|
||||
"steps": [
|
||||
{
|
||||
"title": "Welcome",
|
||||
"file": "README.md",
|
||||
"description": "### Welcome to CAP Samples!\n\nThis tour leads you through a collection of samples for the [SAP Cloud Application Programming Model (CAP)](https://cap.cloud.sap).\nYou will learn which features of the programming model are demonstrated in which sample.\n\nLet's start!",
|
||||
"line": 2,
|
||||
"selection": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"character": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"character": 108
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"file": "hello/srv/world.cds",
|
||||
"description": "### Hello World!\n\nThis is a simplistic [Hello World](https://cap.cloud.sap/docs/get-started/hello-world) service using [CDS](https://cap.cloud.sap/docs/cds/) and [cds.services](https://cap.cloud.sap/docs/node.js/api#services-api).",
|
||||
"line": 2,
|
||||
"selection": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"character": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"character": 1
|
||||
}
|
||||
},
|
||||
"title": "Hello World!"
|
||||
},
|
||||
{
|
||||
"file": "bookshop/db/schema.cds",
|
||||
"description": "### A Bookshop!\n\nIntroduces:\n- [Project Setup](https://cap.cloud.sap/docs/get-started/) and [Layouts](https://cap.cloud.sap/docs/get-started/projects)\n- [Domain Modeling](https://cap.cloud.sap/docs/guides/domain-models)\n- [Defining Services](https://cap.cloud.sap/docs/guides/providing-services)\n- [Generic Providers](https://cap.cloud.sap/docs/guides/generic-providers)\n- [Adding Custom Logic](https://cap.cloud.sap/docs/guides/service-impl)\n- [Using Databases](https://cap.cloud.sap/docs/guides/databases)\n",
|
||||
"line": 1,
|
||||
"selection": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"character": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 32,
|
||||
"character": 1
|
||||
}
|
||||
},
|
||||
"title": "Bookshop"
|
||||
},
|
||||
{
|
||||
"file": "common/index.cds",
|
||||
"description": "### Extend and Reuse\n\nShowcases how to extend [@sap/cds/common](https://cap.cloud.sap/docs/cds/common) thereby covering:\n- Building [extension packages](https://cap.cloud.sap/docs/guides/domain-models#aspects-extensibility)\n- Providing [reuse packages](https://cap.cloud.sap/docs/get-started/projects#sharing-and-reusing-content)\n- [Verticalization](https://cap.cloud.sap/docs/cds/common#adapting-to-your-needs)\n- Using [Aspects](https://cap.cloud.sap/docs/cds/cdl#aspects)\n- Used in the [fiori app sample](#fiori)\n",
|
||||
"line": 1,
|
||||
"selection": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"character": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 46,
|
||||
"character": 1
|
||||
}
|
||||
},
|
||||
"title": "Common"
|
||||
},
|
||||
{
|
||||
"file": "orders/db/schema.cds",
|
||||
"description": "### Orders - Compositions and Serving Documents\n\nA standalone orders management service, demonstrating:\n- Using [Compositions](https://cap.cloud.sap/docs/cds/cdl#compositions) in [Domain Models](https://cap.cloud.sap/docs/guides/domain-models), along with\n- [Serving deeply nested documents](https://cap.cloud.sap/docs/guides/generic-providers#serving-structured-data)\n",
|
||||
"line": 1,
|
||||
"selection": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"character": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 27,
|
||||
"character": 1
|
||||
}
|
||||
},
|
||||
"title": "Orders"
|
||||
},
|
||||
{
|
||||
"file": "reviews/db/schema.cds",
|
||||
"description": "### Reviews - More Modularity\n\nShows how to implement a modular service to manage product reviews, including:\n- Consuming other services synchronously and asynchronously\n- Serving requests synchronously\n- Emitting events asynchronously\n- Grow as you go, with:\n- Mocking app services\n- Running service meshes\n- Late-cut Micro Services\n- As well as managed data, input validations, and authorization\n",
|
||||
"line": 1,
|
||||
"selection": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"character": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 39,
|
||||
"character": 1
|
||||
}
|
||||
},
|
||||
"title": "Reviews"
|
||||
},
|
||||
{
|
||||
"title": "Bookstore",
|
||||
"description": "### Bookstore - Reuse and UI\n\n- A [composite app, reusing and combining](https://cap.cloud.sap/docs/guides/reuse-and-compose) these packages:\n - [@capire/bookshop](bookshop)\n - [@capire/reviews](reviews)\n - [@capire/orders](orders)\n - [@capire/common](common)\n- [The Vue.js app](bookshop/app/vue) imported from bookshop is served as well\n- [The Vue.js app](reviews/app/vue) imported from reviews is served as well\n- [The Fiori app](orders/app) imported from orders is served as well\n- [OpenAPI export + Swagger UI](https://cap.cloud.sap/docs/advanced/openapi)"
|
||||
},
|
||||
{
|
||||
"file": "fiori/app/services.cds",
|
||||
"description": "### Annotations for SAP Fiori Elements\n\nAdds an SAP Fiori elements application to bookstore, thereby introducing:\n- OData Annotations in `.cds` files\n- Support for Fiori Draft\n- Support for Value Helps\n- Serving SAP Fiori apps locally\n\nSee the [Serving Fiori UIs](https://cap.cloud.sap/docs/advanced/fiori) documentation for more information.",
|
||||
"line": 1,
|
||||
"selection": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"character": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 13,
|
||||
"character": 1
|
||||
}
|
||||
},
|
||||
"title": "Fiori"
|
||||
},
|
||||
{
|
||||
"file": "package.json",
|
||||
"description": "### All-in-one Monorepo\n\nEach sample sub directory essentially is a standard npm package, some with standard npm dependencies to other samples. The root folder's [package.json](package.json) has local links to the sub folders, such that an `npm install` populates a local `node_modules` folder acts like a local npm registry to the individual sample packages.\n",
|
||||
"selection": {
|
||||
"start": {
|
||||
"line": 8,
|
||||
"character": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 16,
|
||||
"character": 1
|
||||
}
|
||||
},
|
||||
"title": "Packages"
|
||||
}
|
||||
],
|
||||
"isPrimary": true,
|
||||
"description": "Overview of CAP Samples for Node.js"
|
||||
}
|
||||
6
.vscode/extensions.json
vendored
6
.vscode/extensions.json
vendored
@@ -4,11 +4,15 @@
|
||||
|
||||
// List of extensions which should be recommended for users of this workspace.
|
||||
"recommendations": [
|
||||
"qwtel.sqlite-viewer",
|
||||
"sapse.vscode-cds",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"esbenp.prettier-vscode",
|
||||
"mechatroner.rainbow-csv",
|
||||
"humao.rest-client",
|
||||
"alexcvzz.vscode-sqlite",
|
||||
"hbenl.vscode-mocha-test-adapter",
|
||||
"sdras.night-owl",
|
||||
"vsls-contrib.codetour"
|
||||
],
|
||||
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
|
||||
"unwantedRecommendations": [
|
||||
|
||||
17
.vscode/launch.json
vendored
17
.vscode/launch.json
vendored
@@ -13,22 +13,31 @@
|
||||
"<node_internals>/**",
|
||||
"**/node_modules/**",
|
||||
"**/cds/lib/lazy.js",
|
||||
"**/cds/lib/req/cds-context.js",
|
||||
"**/cds/lib/req/cls.js",
|
||||
"**/odata-v4/okra/**"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "bookstore",
|
||||
"command": "npx cds watch bookstore",
|
||||
"name": "Fiori App",
|
||||
"command": "npx cds watch fiori",
|
||||
"type": "node-terminal",
|
||||
"request": "launch",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**",
|
||||
"**/node_modules/**",
|
||||
"**/cds/lib/lazy.js",
|
||||
"**/cds/lib/req/cds-context.js",
|
||||
"**/cds/lib/req/cls.js",
|
||||
"**/odata-v4/okra/**"
|
||||
]
|
||||
}
|
||||
],
|
||||
"inputs": [
|
||||
{
|
||||
"type": "pickString",
|
||||
"id": "sample",
|
||||
"description": "Which sample do you want to start?",
|
||||
"options": [ "bookshop", "fiori", "reviews", "reviews" ],
|
||||
"default": "bookshop"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
12
.vscode/settings.json
vendored
12
.vscode/settings.json
vendored
@@ -1,16 +1,18 @@
|
||||
{
|
||||
"files.exclude": {
|
||||
"**/node_modules": true,
|
||||
"LICENSES": true,
|
||||
".reuse": true
|
||||
".reuse/**": true,
|
||||
"**/.gitignore": true,
|
||||
"**/.vscode": true,
|
||||
"LICENSES/**": true
|
||||
},
|
||||
"debug.javascript.terminalOptions": {
|
||||
"skipFiles": [
|
||||
"<node_internals>/**",
|
||||
"**/node_modules/**",
|
||||
"**/cds/lib/lazy.js",
|
||||
"**/cds/lib/req/cds-context.js",
|
||||
"**/cds/lib/req/cls.js",
|
||||
"**/odata-v4/okra/**"
|
||||
]
|
||||
}
|
||||
},
|
||||
"mochaExplorer.parallel": true
|
||||
}
|
||||
|
||||
73
LICENSES/Apache-2.0.txt
Normal file
73
LICENSES/Apache-2.0.txt
Normal file
@@ -0,0 +1,73 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
87
README.md
Normal file
87
README.md
Normal file
@@ -0,0 +1,87 @@
|
||||
# Welcome to cap/samples
|
||||
|
||||
Find here a collection of samples for the [SAP Cloud Application Programming Model](https://cap.cloud.sap) organized in a simplistic [monorepo setup](samples.md#all-in-one-monorepo). → See [**Overview** of contained samples](samples.md)
|
||||
|
||||

|
||||
[](https://api.reuse.software/info/github.com/SAP-samples/cloud-cap-samples)
|
||||
|
||||
### Preliminaries
|
||||
|
||||
1. Ensure you have the latest LTS version of Node.js installed (see [Getting Started](https://cap.cloud.sap/docs/get-started/))
|
||||
2. 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)
|
||||
|
||||
### Download
|
||||
|
||||
If you've [Git](https://git-scm.com/downloads) installed, clone this repo as shown below, otherwise [download as ZIP file](archive/main.zip).
|
||||
|
||||
```sh
|
||||
git clone https://github.com/sap-samples/cloud-cap-samples samples
|
||||
cd samples
|
||||
```
|
||||
|
||||
### Setup
|
||||
|
||||
In the samples folder run:
|
||||
|
||||
```sh
|
||||
npm install
|
||||
```
|
||||
|
||||
### Run
|
||||
|
||||
With that you're ready to run the samples, for example:
|
||||
|
||||
```sh
|
||||
cds watch bookshop
|
||||
```
|
||||
|
||||
After that open this link in your browser: [http://localhost:4004](http://localhost:4004)
|
||||
|
||||
When asked to log in, type `alice` as user and leave the password field blank, which is the [default user](https://cap.cloud.sap/docs/node.js/authentication#mocked).
|
||||
|
||||
### Testing
|
||||
|
||||
Run the provided tests with [_jest_](http://jestjs.io) or [_mocha_](http://mochajs.org), for example:
|
||||
|
||||
```sh
|
||||
npx jest
|
||||
```
|
||||
> While mocha is a bit smaller and faster, jest runs tests in parallel and isolation, which allows to run all tests.
|
||||
|
||||
|
||||
### Serve `npm`
|
||||
|
||||
We've included a simple npm registry mock, which allows you to do an `npm install @capire/<package>` locally. Use it as follows:
|
||||
|
||||
1. Start the @capire registry:
|
||||
```sh
|
||||
npm run registry
|
||||
```
|
||||
> While running this will have `@capire:registry=http://localhost:4444` set with npmrc.
|
||||
|
||||
2. Install one of the @capire packages wherever you like, for example:
|
||||
|
||||
```sh
|
||||
npm add @capire/common @capire/bookshop
|
||||
```
|
||||
|
||||
|
||||
## Code Tours
|
||||
|
||||
Take one of the [guided tours](.tours) in VS Code through our CAP samples and learn which CAP features are showcased by the different parts of the repository. Just install the [CodeTour extension](https://marketplace.visualstudio.com/items?itemName=vsls-contrib.codetour) for VS Code. We'll add more code tours in the future. Stay tuned!
|
||||
|
||||
## Get Support
|
||||
|
||||
Check out the documentation at [https://cap.cloud.sap](https://cap.cloud.sap). <br>
|
||||
In case you've a question, find a bug, or otherwise need support, use our [community](https://answers.sap.com/tags/9f13aee1-834c-4105-8e43-ee442775e5ce) to get more visibility.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) 2022 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, version 2.0 except as noted otherwise in the [LICENSE](LICENSE) file.
|
||||
3
bookshop/@types/_/index.js
Normal file
3
bookshop/@types/_/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
const cds = require('@sap/cds')
|
||||
const cson = cds.entities('_')
|
||||
35
bookshop/@types/_/index.ts
Normal file
35
bookshop/@types/_/index.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
|
||||
|
||||
export namespace Association {
|
||||
export type to <T> = T & ((fn:(a:T)=>any) => T)
|
||||
export namespace to {
|
||||
// type many <T> = T[] & (T extends (infer R)[] ? R[] & ((fn:(a:R)=>any) => R[]) : T[]);
|
||||
export type many <T extends readonly unknown[]> = T & ((fn:(a:T[number])=>any) => T[number]);
|
||||
}
|
||||
}
|
||||
|
||||
export namespace Composition {
|
||||
export type of <T> = T & ((fn:(a:T)=>any) => T)
|
||||
export namespace of {
|
||||
//type many <T> = T[] & (T extends (infer R)[] ? R[] & ((fn:(a:R)=>any) => R[]) : T[]);
|
||||
export type many <T extends readonly unknown[]> = T & ((fn:(a:T[number])=>any) => T[number]);
|
||||
}
|
||||
}
|
||||
|
||||
export class Entity {
|
||||
static data<T extends Entity> (this:T, input:Object) : T {
|
||||
return {} as T // mock
|
||||
}
|
||||
}
|
||||
|
||||
export type EntitySet<T> = T[] & {
|
||||
data (input:object[]) : T[]
|
||||
data (input:object) : T
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
3
bookshop/@types/index.js
Normal file
3
bookshop/@types/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
const cds = require('@sap/cds')
|
||||
const cson = cds.entities('')
|
||||
57
bookshop/@types/index.ts
Normal file
57
bookshop/@types/index.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
import * as _sap_common from './sap/common';
|
||||
import * as __ from './_';
|
||||
|
||||
export type Language = __.Association.to<_sap_common.Language>;
|
||||
export type Currency = __.Association.to<_sap_common.Currency>;
|
||||
export type Country = __.Association.to<_sap_common.Country>;
|
||||
export type User = string;
|
||||
|
||||
|
||||
// the following represents the CDS aspect 'cuid'
|
||||
export function cuid<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class cuidAspect extends Base {
|
||||
ID: string;
|
||||
};
|
||||
}
|
||||
const cuidXtended = cuid(__.Entity)
|
||||
export type cuid = InstanceType<typeof cuidXtended>
|
||||
|
||||
// the following represents the CDS aspect 'managed'
|
||||
export function managed<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class managedAspect extends Base {
|
||||
createdAt: Date;
|
||||
/**
|
||||
* Canonical user ID
|
||||
*/
|
||||
createdBy: User;
|
||||
modifiedAt: Date;
|
||||
/**
|
||||
* Canonical user ID
|
||||
*/
|
||||
modifiedBy: User;
|
||||
};
|
||||
}
|
||||
const managedXtended = managed(__.Entity)
|
||||
export type managed = InstanceType<typeof managedXtended>
|
||||
|
||||
// the following represents the CDS aspect 'temporal'
|
||||
export function temporal<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class temporalAspect extends Base {
|
||||
validFrom: Date;
|
||||
validTo: Date;
|
||||
};
|
||||
}
|
||||
const temporalXtended = temporal(__.Entity)
|
||||
export type temporal = InstanceType<typeof temporalXtended>
|
||||
|
||||
// the following represents the CDS aspect 'extensible'
|
||||
export function extensible<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class extensibleAspect extends Base {
|
||||
extensions__: string;
|
||||
};
|
||||
}
|
||||
const extensibleXtended = extensible(__.Entity)
|
||||
export type extensible = InstanceType<typeof extensibleXtended>
|
||||
|
||||
|
||||
9
bookshop/@types/sap/capire/bookshop/index.js
Normal file
9
bookshop/@types/sap/capire/bookshop/index.js
Normal file
@@ -0,0 +1,9 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
const cds = require('@sap/cds')
|
||||
const cson = cds.entities('sap.capire.bookshop')
|
||||
module.exports.Book = cson.Books
|
||||
module.exports.Books = cson.Books
|
||||
module.exports.Author = cson.Authors
|
||||
module.exports.Authors = cson.Authors
|
||||
module.exports.Genre = cson.Genres
|
||||
module.exports.Genres = cson.Genres
|
||||
66
bookshop/@types/sap/capire/bookshop/index.ts
Normal file
66
bookshop/@types/sap/capire/bookshop/index.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
import * as __ from './../../../_';
|
||||
import * as _ from './../../..';
|
||||
import * as _sap_common from './../../common';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export function Book<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class BookAspect extends Base {
|
||||
ID: number;
|
||||
title: string;
|
||||
descr: string;
|
||||
author: __.Association.to<Author>;
|
||||
genre: __.Association.to<Genre>;
|
||||
stock: number;
|
||||
price: number;
|
||||
/**
|
||||
* Type for an association to Currencies
|
||||
*
|
||||
* See https://cap.cloud.sap/docs/cds/common#type-currency
|
||||
*/
|
||||
currency: __.Association.to<_.Currency>;
|
||||
image: string;
|
||||
};
|
||||
}
|
||||
const BookXtended = _.managed(Book(__.Entity))
|
||||
export type Book = InstanceType<typeof BookXtended>
|
||||
|
||||
export class Books extends Array<Book> {
|
||||
}
|
||||
|
||||
export function Author<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class AuthorAspect extends Base {
|
||||
ID: number;
|
||||
name: string;
|
||||
dateOfBirth: Date;
|
||||
dateOfDeath: Date;
|
||||
placeOfBirth: string;
|
||||
placeOfDeath: string;
|
||||
books: __.Association.to.many<Books>;
|
||||
};
|
||||
}
|
||||
const AuthorXtended = _.managed(Author(__.Entity))
|
||||
export type Author = InstanceType<typeof AuthorXtended>
|
||||
|
||||
export class Authors extends Array<Author> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Hierarchically organized Code List for Genres
|
||||
*/
|
||||
export function Genre<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class GenreAspect extends Base {
|
||||
ID: number;
|
||||
parent: __.Association.to<Genre>;
|
||||
children: __.Composition.of.many<Genres>;
|
||||
};
|
||||
}
|
||||
const GenreXtended = _sap_common.CodeList(Genre(__.Entity))
|
||||
export type Genre = InstanceType<typeof GenreXtended>
|
||||
|
||||
export class Genres extends Array<Genre> {
|
||||
}
|
||||
|
||||
9
bookshop/@types/sap/common/index.js
Normal file
9
bookshop/@types/sap/common/index.js
Normal file
@@ -0,0 +1,9 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
const cds = require('@sap/cds')
|
||||
const cson = cds.entities('sap.common')
|
||||
module.exports.Language = cson.Languages
|
||||
module.exports.Languages = cson.Languages
|
||||
module.exports.Country = cson.Countries
|
||||
module.exports.Countries = cson.Countries
|
||||
module.exports.Currency = cson.Currencies
|
||||
module.exports.Currencies = cson.Currencies
|
||||
68
bookshop/@types/sap/common/index.ts
Normal file
68
bookshop/@types/sap/common/index.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
import * as __ from './../../_';
|
||||
|
||||
export type Locale = string;
|
||||
|
||||
|
||||
// the following represents the CDS aspect 'CodeList'
|
||||
export function CodeList<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class CodeListAspect extends Base {
|
||||
name: string;
|
||||
descr: string;
|
||||
};
|
||||
}
|
||||
const CodeListXtended = CodeList(__.Entity)
|
||||
export type CodeList = InstanceType<typeof CodeListXtended>
|
||||
|
||||
/**
|
||||
* Code list for languages
|
||||
*
|
||||
* See https://cap.cloud.sap/docs/cds/common#entity-sapcommonlanguages
|
||||
*/
|
||||
export function Language<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class LanguageAspect extends Base {
|
||||
/**
|
||||
* Type for a language code
|
||||
*/
|
||||
code: Locale;
|
||||
};
|
||||
}
|
||||
const LanguageXtended = CodeList(Language(__.Entity))
|
||||
export type Language = InstanceType<typeof LanguageXtended>
|
||||
|
||||
export class Languages extends Array<Language> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Code list for countries
|
||||
*
|
||||
* See https://cap.cloud.sap/docs/cds/common#entity-sapcommoncountries
|
||||
*/
|
||||
export function Country<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class CountryAspect extends Base {
|
||||
code: string;
|
||||
};
|
||||
}
|
||||
const CountryXtended = CodeList(Country(__.Entity))
|
||||
export type Country = InstanceType<typeof CountryXtended>
|
||||
|
||||
export class Countries extends Array<Country> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Code list for currencies
|
||||
*
|
||||
* See https://cap.cloud.sap/docs/cds/common#entity-sapcommoncurrencies
|
||||
*/
|
||||
export function Currency<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class CurrencyAspect extends Base {
|
||||
code: string;
|
||||
symbol: string;
|
||||
};
|
||||
}
|
||||
const CurrencyXtended = CodeList(Currency(__.Entity))
|
||||
export type Currency = InstanceType<typeof CurrencyXtended>
|
||||
|
||||
export class Currencies extends Array<Currency> {
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ const books = Vue.createApp ({
|
||||
search: ({target:{value:v}}) => books.fetch(v && '&$search='+v),
|
||||
|
||||
async fetch (etc='') {
|
||||
const {data} = await GET(`/ListOfBooks?$expand=genre($select=name),currency($select=symbol)${etc}`)
|
||||
const {data} = await GET(`/ListOfBooks?$expand=genre,currency${etc}`)
|
||||
books.list = data.value
|
||||
},
|
||||
|
||||
@@ -56,7 +56,7 @@ const books = Vue.createApp ({
|
||||
} catch (err) { books.user = { id: err.message } }
|
||||
},
|
||||
}
|
||||
}).mount('#app')
|
||||
}).mount("#app")
|
||||
|
||||
books.getUserInfo()
|
||||
books.fetch() // initially fill list of books
|
||||
@@ -65,25 +65,3 @@ 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'])
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<head>
|
||||
<title> Capire Books </title>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/primitive-ui/dist/css/main.css">
|
||||
<link rel="stylesheet" href="https://unpkg.com/primitive-ui/dist/css/main.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.prod.js"></script>
|
||||
<style>
|
||||
|
||||
@@ -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,11aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
|
||||
207,Jane Eyre,"Jane Eyre /ɛər/ (originally published as Jane Eyre: An Autobiography) is a novel by English writer Charlotte Brontë, published under the pen name ""Currer Bell"", on 16 October 1847, by Smith, Elder & Co. of London. The first American edition was published the following year by Harper & Brothers of New York. Primarily a bildungsroman, Jane Eyre follows the experiences of its eponymous heroine, including her growth to adulthood and her love for Mr. Rochester, the brooding master of Thornfield Hall. The novel revolutionised prose fiction in that the focus on Jane's moral and spiritual development is told through an intimate, first-person narrative, where actions and events are coloured by a psychological intensity. The book contains elements of social criticism, with a strong sense of Christian morality at its core and is considered by many to be ahead of its time because of Jane's individualistic character and how the novel approaches the topics of class, sexuality, religion and feminism.",107,11,12.34,GBP,11aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
|
||||
251,The Raven,"""The Raven"" is a narrative poem by American writer Edgar Allan Poe. First published in January 1845, the poem is often noted for its musicality, stylized language, and supernatural atmosphere. It tells of a talking raven's mysterious visit to a distraught lover, tracing the man's slow fall into madness. The lover, often identified as being a student, is lamenting the loss of his love, Lenore. Sitting on a bust of Pallas, the raven seems to further distress the protagonist with its constant repetition of the word ""Nevermore"". The poem makes use of folk, mythological, religious, and classical references.",150,333,13.13,USD,16aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
|
||||
252,Eleonora,"""Eleonora"" is a short story by Edgar Allan Poe, first published in 1842 in Philadelphia in the literary annual The Gift. It is often regarded as somewhat autobiographical and has a relatively ""happy"" ending.",150,555,14,USD,15aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
|
||||
271,Catweazle,"Catweazle is a British fantasy television series, starring Geoffrey Bayldon in the title role, and created by Richard Carpenter for London Weekend Television. The first series, produced and directed by Quentin Lawrence, was screened in the UK on ITV in 1970. The second series, directed by David Reid and David Lane, was shown in 1971. Each series had thirteen episodes, most but not all written by Carpenter, who also published two books based on the scripts.",170,22,150,JPY,13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
|
||||
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_texts,ID,locale,title,descr
|
||||
d2a65a27-9f2a-480f-bc38-84ee8ec5c13e,201,de,Sturmhöhe,"Sturmhöhe (Originaltitel: Wuthering Heights) ist der einzige Roman der englischen Schriftstellerin Emily Brontë (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."
|
||||
8c42c706-a979-41cf-9ffe-91e6cf1383a0,201,fr,Les Hauts de Hurlevent,"Les Hauts de Hurlevent (titre original : Wuthering Heights), parfois orthographié Les Hauts de Hurle-Vent, est l'unique roman d'Emily Brontë, publié pour la première fois en 1847 sous le pseudonyme d’Ellis Bell. Loin d'être un récit moralisateur, Emily Brontë achève néanmoins le roman dans une atmosphère sereine, suggérant le triomphe de la paix et du Bien sur la vengeance et le Mal."
|
||||
9e1c4c81-dc90-4600-85b1-e9dd4bf12ce0,207,de,Jane Eyre,"Jane Eyre. Eine Autobiographie (Originaltitel: Jane Eyre. An Autobiography), erstmals erschienen im Jahr 1847 unter dem Pseudonym Currer Bell, ist der erste veröffentlichte Roman der britischen Autorin Charlotte Brontë und ein Klassiker der viktorianischen Romanliteratur des 19. Jahrhunderts. Der Roman erzählt in Form einer Ich-Erzählung die Lebensgeschichte von Jane Eyre (ausgesprochen /ˌdʒeɪn ˈɛə/), die nach einer schweren Kindheit eine Stelle als Gouvernante annimmt und sich in ihren Arbeitgeber verliebt, jedoch immer wieder um ihre Freiheit und Selbstbestimmung kämpfen muss. Als klein, dünn, blass, stets schlicht dunkel gekleidet und mit strengem Mittelscheitel beschrieben, gilt die Heldin des Romans Jane Eyre nicht zuletzt aufgrund der Kino- und Fernsehversionen der melodramatischen Romanvorlage als die bekannteste englische Gouvernante der Literaturgeschichte"
|
||||
9be0524b-4cb9-4fc1-9dc2-d65b1c13cf53,252,de,Eleonora,"“Eleonora” ist eine Erzählung von Edgar Allan Poe. Sie wurde 1841 erstveröffentlicht. In ihr geht es um das Paradox der Treue in der Treulosigkeit."
|
||||
|
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,43 +1,16 @@
|
||||
ID,parent_ID,name
|
||||
10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,,Fiction
|
||||
11aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Drama
|
||||
12aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Poetry
|
||||
13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Fantasy
|
||||
131aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Fairy Tale
|
||||
132aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Epic Fantasy
|
||||
133aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,High Fantasy
|
||||
134aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Gothic
|
||||
14aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Science Fiction
|
||||
141aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,14aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Utopian and Dystopian
|
||||
1411aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,141aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Utopian
|
||||
1412aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,141aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Dystopian
|
||||
14121aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,1412aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Cyberpunk
|
||||
141211aa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,14121aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Steampunk
|
||||
142aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,14aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Space Opera
|
||||
143aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,14aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Time Travel
|
||||
144aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,14aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Tech Noir
|
||||
15aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Romance
|
||||
151aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,15aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Contemporary Romance
|
||||
152aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,15aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Historical Romance
|
||||
153aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,15aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Romantic Suspense
|
||||
16aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Mystery
|
||||
161aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,16aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Crime
|
||||
1611aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,161aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Thriller
|
||||
16111aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,1611aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Police Procedural
|
||||
16112aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,1611aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Legal Thriller
|
||||
16113aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,1611aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Medical Thriller
|
||||
16114aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,1611aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Spy Thriller
|
||||
1612aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,161aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Detective
|
||||
1613aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,161aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Suspense
|
||||
162aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,16aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Noir
|
||||
1621aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,162aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Nordic Noir
|
||||
1622aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,162aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Tart Noir
|
||||
163aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,16aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Cozy Mystery
|
||||
17aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Adventure
|
||||
18aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Short Story
|
||||
19aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Graphic Novel
|
||||
20aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,,Non-Fiction
|
||||
21aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,20aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Biography
|
||||
22aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,21aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Autobiography
|
||||
23aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,20aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Essay
|
||||
24aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,20aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Speech
|
||||
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
|
||||
|
||||
|
@@ -1,21 +1,24 @@
|
||||
const cds = require('@sap/cds')
|
||||
|
||||
/**
|
||||
* In order to keep basic bookshop sample as simple as possible, we don't add
|
||||
* reuse dependencies. This db/init.js ensures we still have a minimum set of
|
||||
* currencies, if not obtained through @capire/common.
|
||||
*/
|
||||
|
||||
// NOTE: We use cds.on('served') to delay the UPSERTs after the db init
|
||||
// to run after all INSERTs from .csv files happened.
|
||||
module.exports = cds.on('served', ()=>
|
||||
UPSERT.into ('sap.common.Currencies') .columns (
|
||||
[ 'code', 'symbol', 'name' ]
|
||||
module.exports = async (db)=>{
|
||||
|
||||
const has_common = db.model.definitions['sap.common.Currencies'].elements.numcode
|
||||
if (has_common) return
|
||||
|
||||
const already_filled = await db.exists('sap.common.Currencies',{code:'EUR'})
|
||||
if (already_filled) return
|
||||
|
||||
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,37 +2,30 @@ using { Currency, managed, sap } from '@sap/cds/common';
|
||||
namespace sap.capire.bookshop;
|
||||
|
||||
entity Books : managed {
|
||||
key ID : Integer;
|
||||
title : localized String(111) @mandatory;
|
||||
descr : localized String(1111);
|
||||
author : Association to Authors @mandatory;
|
||||
genre : Association to Genres;
|
||||
stock : Integer;
|
||||
price : Price;
|
||||
key ID : Integer;
|
||||
title : localized String(111);
|
||||
descr : localized String(1111);
|
||||
author : Association to Authors;
|
||||
genre : Association to Genres;
|
||||
stock : Integer;
|
||||
price : Decimal;
|
||||
currency : Currency;
|
||||
image : LargeBinary @Core.MediaType: 'image/png';
|
||||
image : LargeBinary @Core.MediaType : 'image/png';
|
||||
}
|
||||
|
||||
entity Authors : managed {
|
||||
key ID : Integer;
|
||||
name : String(111) @mandatory;
|
||||
key ID : Integer;
|
||||
name : String(111);
|
||||
dateOfBirth : Date;
|
||||
dateOfDeath : Date;
|
||||
placeOfBirth : String;
|
||||
placeOfDeath : String;
|
||||
books : Association to many Books on books.author = $self;
|
||||
books : Association to many Books on books.author = $self;
|
||||
}
|
||||
|
||||
/** Hierarchically organized Code List for Genres */
|
||||
entity Genres : sap.common.CodeList {
|
||||
key ID : UUID;
|
||||
key ID : Integer;
|
||||
parent : Association to Genres;
|
||||
children : Composition of many Genres on children.parent = $self;
|
||||
}
|
||||
|
||||
type Price : Decimal(9,2);
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// temporary workaround for reuse in fiori sample and hana deployment
|
||||
annotate Books with @fiori.draft.enabled;
|
||||
|
||||
@@ -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';
|
||||
|
||||
2
bookshop/index.js
Normal file
2
bookshop/index.js
Normal file
@@ -0,0 +1,2 @@
|
||||
const { CatalogService } = require('./srv/cat-service')
|
||||
module.exports = { CatalogService }
|
||||
5
bookshop/jsconfig.json
Normal file
5
bookshop/jsconfig.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"checkJs": true
|
||||
}
|
||||
}
|
||||
@@ -6,18 +6,24 @@
|
||||
"app",
|
||||
"srv",
|
||||
"db",
|
||||
"index.cds"
|
||||
"index.cds",
|
||||
"index.js"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@cap-js/sqlite": ">=1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@sap/cds": ">=7",
|
||||
"express": "^4.17.1"
|
||||
"@sap/cds": ">=5.9",
|
||||
"express": "^4.17.1",
|
||||
"passport": ">=0.4.1"
|
||||
},
|
||||
"scripts": {
|
||||
"genres": "cds serve test/genres.cds",
|
||||
"start": "cds-serve",
|
||||
"start": "cds run",
|
||||
"watch": "cds watch"
|
||||
},
|
||||
"cds": {
|
||||
"requires": {
|
||||
"db": {
|
||||
"kind": "sql"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,12 @@ npm run watch
|
||||
|
||||
| Links to capire | Sample files / folders |
|
||||
| --------------------------------------------------------------------------------------------------------- | ------------------------------------ |
|
||||
| [Project Setup & Layouts](https://cap.cloud.sap/docs/get-started/jumpstart#project-structure) | [`./`](./) |
|
||||
| [Domain Modeling with CDS](https://cap.cloud.sap/docs/guides/domain-modeling) | [`./db/schema.cds`](./db/schema.cds) |
|
||||
| [Defining Services](https://cap.cloud.sap/docs/guides/providing-services#modeling-services) | [`./srv/*.cds`](./srv) |
|
||||
| [Single-purposed Services](https://cap.cloud.sap/docs/guides/providing-services#single-purposed-services) | [`./srv/*.cds`](./srv) |
|
||||
| [Project Setup & Layouts](https://cap.cloud.sap/docs/get-started/projects#sharing-and-reusing-content) | [`./`](./) |
|
||||
| [Domain Modeling with CDS](https://cap.cloud.sap/docs/guides/domain-models) | [`./db/schema.cds`](./db/schema.cds) |
|
||||
| [Defining Services](https://cap.cloud.sap/docs/guides/services#defining-services) | [`./srv/*.cds`](./srv) |
|
||||
| [Single-purposed Services](https://cap.cloud.sap/docs/guides/services#single-purposed-services) | [`./srv/*.cds`](./srv) |
|
||||
| [Providing & Consuming Providers](https://cap.cloud.sap/docs/guides/providing-services) | http://localhost:4004 |
|
||||
| [Using Databases](https://cap.cloud.sap/docs/guides/databases) | [`./db/data/*.csv`](./db/data) |
|
||||
| [Adding Custom Logic](https://cap.cloud.sap/docs/guides/providing-services#adding-custom-logic) | [`./srv/*.js`](./srv) |
|
||||
| [Adding Custom Logic](https://cap.cloud.sap/docs/guides/service-impl) | [`./srv/*.js`](./srv) |
|
||||
| Adding Tests | [`./test`](./test) |
|
||||
| [Sharing for Reuse](https://cap.cloud.sap/docs/guides/extensibility/composition) | [`./index.cds`](./index.cds) |
|
||||
| [Sharing for Reuse](https://cap.cloud.sap/docs/guides/reuse-and-compose) | [`./index.cds`](./index.cds) |
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
using { AdminService } from './admin-service';
|
||||
annotate AdminService with @requires:'admin';
|
||||
@@ -1,6 +1,5 @@
|
||||
using { sap.capire.bookshop as my } from '../db/schema';
|
||||
service AdminService @(path:'/admin') {
|
||||
entity Authors as projection on my.Authors;
|
||||
service AdminService @(requires:'admin') {
|
||||
entity Books as projection on my.Books;
|
||||
entity Genres as projection on my.Genres;
|
||||
entity Authors as projection on my.Authors;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
const cds = require('@sap/cds')
|
||||
|
||||
module.exports = class AdminService extends cds.ApplicationService { init(){
|
||||
this.before (['NEW','CREATE'],'Authors', genid)
|
||||
this.before (['NEW','CREATE'],'Books', genid)
|
||||
return super.init()
|
||||
}}
|
||||
module.exports = cds.service.impl (function(){
|
||||
this.before ('NEW','Authors', genid)
|
||||
this.before ('NEW','Books', genid)
|
||||
})
|
||||
|
||||
/** Generate primary keys for target entity in request */
|
||||
async function genid (req) {
|
||||
if (req.data.ID) return
|
||||
const {id} = await SELECT.one.from(req.target).columns('max(ID) as id')
|
||||
req.data.ID = id + 4 // Note: that is not safe! ok for this sample only.
|
||||
const {ID} = await cds.tx(req).run (SELECT.one.from(req.target).columns('max(ID) as ID'))
|
||||
req.data.ID = ID - ID % 100 + 100 + 1
|
||||
}
|
||||
|
||||
@@ -1,38 +1,29 @@
|
||||
const cds = require('@sap/cds')
|
||||
|
||||
class CatalogService extends cds.ApplicationService { init() {
|
||||
class CatalogService extends cds.ApplicationService { init(){
|
||||
|
||||
const { Books } = cds.entities('sap.capire.bookshop')
|
||||
const { ListOfBooks } = this.entities
|
||||
|
||||
// Add some discount for overstocked books
|
||||
this.after('each', ListOfBooks, book => {
|
||||
if (book.stock > 111) book.title += ` -- 11% discount!`
|
||||
})
|
||||
//const { Books } = this.entities ('sap.capire.bookshop')
|
||||
const { Books, Book } = require('../@types/sap/capire/bookshop')
|
||||
|
||||
// Reduce stock of ordered books if available stock suffices
|
||||
this.on('submitOrder', async req => {
|
||||
let { book:id, quantity } = req.data
|
||||
let book = await SELECT.from (Books, id, b => b.stock)
|
||||
|
||||
// Validate input data
|
||||
if (!book) return req.error (404, `Book #${id} doesn't exist`)
|
||||
if (quantity < 1) return req.error (400, `quantity has to be 1 or more`)
|
||||
if (quantity > book.stock) return req.error (409, `${quantity} exceeds stock for book #${id}`)
|
||||
|
||||
// Reduce stock in database and return updated stock value
|
||||
await UPDATE (Books, id) .with ({ stock: book.stock -= quantity })
|
||||
return book
|
||||
this.on ('submitOrder', async req => {
|
||||
const {book,quantity} = req.data
|
||||
if (quantity < 1) return req.reject (400,`quantity has to be 1 or more`)
|
||||
let b = await SELECT `stock` .from (Books,book)
|
||||
if (!b) return req.error (404,`Book #${book} doesn't exist`)
|
||||
let {stock} = b
|
||||
if (quantity > stock) return req.reject (409,`${quantity} exceeds stock for book #${book}`)
|
||||
await UPDATE (Books,book) .with ({ stock: stock -= quantity })
|
||||
await this.emit ('OrderedBook', { book, quantity, buyer:req.user.id })
|
||||
return { stock }
|
||||
})
|
||||
|
||||
// Emit event when an order has been submitted
|
||||
this.after('submitOrder', async (_,req) => {
|
||||
let { book, quantity } = req.data
|
||||
await this.emit('OrderedBook', { book, quantity, buyer: req.user.id })
|
||||
// Add some discount for overstocked books
|
||||
this.after ('READ','ListOfBooks', each => {
|
||||
if (each.stock > 111) each.title += ` -- 11% discount!`
|
||||
})
|
||||
|
||||
// Delegate requests to the underlying generic service
|
||||
return super.init()
|
||||
}}
|
||||
|
||||
module.exports = CatalogService
|
||||
module.exports = { CatalogService }
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/**
|
||||
* Exposes user information
|
||||
*/
|
||||
service UserService @(path: '/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;
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
const cds = require("@sap/cds");
|
||||
const { expect } = cds.test(
|
||||
"serve",
|
||||
"CatalogService",
|
||||
"--from",
|
||||
"@capire/bookshop,@capire/common",
|
||||
"--in-memory"
|
||||
);
|
||||
|
||||
describe("Consuming actions locally", () => {
|
||||
let cats, CatalogService, Books, stockBefore;
|
||||
const BOOK_ID = 251;
|
||||
const QUANTITY = 1;
|
||||
|
||||
before("bootstrap the database", async () => {
|
||||
CatalogService = cds.services.CatalogService;
|
||||
expect(CatalogService).not.to.be.undefined;
|
||||
|
||||
Books = CatalogService.entities.Books;
|
||||
expect(Books).not.to.be.undefined;
|
||||
|
||||
cats = await cds.connect.to("CatalogService");
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
// Read the stock before the action is called
|
||||
stockBefore = (await cats.get(Books, BOOK_ID)).stock;
|
||||
});
|
||||
|
||||
it("calls unbound actions - basic variant using srv.send", async () => {
|
||||
// Use a managed transaction to create a continuation with an authenticated user
|
||||
const res1 = await cats.tx({ user: "alice" }, () => {
|
||||
return cats.send("submitOrder", { book: BOOK_ID, quantity: QUANTITY });
|
||||
});
|
||||
expect(res1.stock).to.eql(stockBefore - QUANTITY);
|
||||
});
|
||||
|
||||
it("calls unbound actions - named args variant", async () => {
|
||||
// Use a managed transaction to create a continuation with an authenticated user
|
||||
const res2 = await cats.tx({ user: "alice" }, () => {
|
||||
return cats.submitOrder({ book: BOOK_ID, quantity: QUANTITY });
|
||||
});
|
||||
expect(res2.stock).to.eql(stockBefore - QUANTITY);
|
||||
});
|
||||
|
||||
it("calls unbound actions - positional args variant", async () => {
|
||||
// Use a managed transaction to create a continuation with an authenticated user
|
||||
const res3 = await cats.tx({ user: "alice" }, () => {
|
||||
return cats.submitOrder(BOOK_ID, QUANTITY);
|
||||
});
|
||||
expect(res3.stock).to.eql(stockBefore - QUANTITY);
|
||||
});
|
||||
});
|
||||
@@ -1,15 +0,0 @@
|
||||
const cds = require('@sap/cds')
|
||||
const { GET, POST, expect } = cds.test(__dirname+'/..')
|
||||
cds.User.default = cds.User.Privileged // hard core monkey patch
|
||||
|
||||
describe('cap/samples - Custom Handlers', () => {
|
||||
|
||||
it('should reject out-of-stock orders', async () => {
|
||||
await expect(POST `/browse/submitOrder ${{ book: 201, quantity: 5 }}`).to.be.fulfilled
|
||||
await expect(POST `/browse/submitOrder ${{ book: 201, quantity: 5 }}`).to.be.fulfilled
|
||||
await expect(POST `/browse/submitOrder ${{ book: 201, quantity: 5 }}`).to.be.rejectedWith(
|
||||
/409 - 5 exceeds stock for book #201/)
|
||||
const { data } = await GET`/admin/Books/201/stock/$value`
|
||||
expect(data).to.equal(2)
|
||||
})
|
||||
})
|
||||
@@ -1,4 +1,4 @@
|
||||
using { sap.capire.bookshop as my } from '../../db/schema';
|
||||
using { sap.capire.bookshop as my } from '../db/schema';
|
||||
service TestService {
|
||||
entity Genres as projection on my.Genres;
|
||||
}
|
||||
38
bookshop/test/genres.http
Normal file
38
bookshop/test/genres.http
Normal file
@@ -0,0 +1,38 @@
|
||||
#################################################
|
||||
#
|
||||
# Genres
|
||||
#
|
||||
|
||||
GET http://localhost:4004/test/Genres?
|
||||
###
|
||||
|
||||
GET http://localhost:4004/test/Genres?
|
||||
&$filter=parent_ID eq null&$select=name
|
||||
&$expand=children($select=name)
|
||||
###
|
||||
|
||||
POST http://localhost:4004/test/Genres?
|
||||
Content-Type: application/json
|
||||
|
||||
{ "ID":100, "name":"Some Sample Genres...", "children":[
|
||||
{ "ID":101, "name":"Cat", "children":[
|
||||
{ "ID":102, "name":"Kitty", "children":[
|
||||
{ "ID":103, "name":"Kitty Cat", "children":[
|
||||
{ "ID":104, "name":"Aristocat" } ]},
|
||||
{ "ID":105, "name":"Kitty Bat" } ]},
|
||||
{ "ID":106, "name":"Catwoman", "children":[
|
||||
{ "ID":107, "name":"Catalina" } ]} ]},
|
||||
{ "ID":108, "name":"Catweazle" }
|
||||
]}
|
||||
###
|
||||
|
||||
GET http://localhost:4004/test/Genres(100)?
|
||||
# &$expand=children
|
||||
# &$expand=children($expand=children($expand=children($expand=children)))
|
||||
###
|
||||
|
||||
DELETE http://localhost:4004/test/Genres(103)
|
||||
###
|
||||
|
||||
DELETE http://localhost:4004/test/Genres(100)
|
||||
###
|
||||
@@ -1,123 +0,0 @@
|
||||
const cds = require('@sap/cds')
|
||||
const { expect } = cds.test.in(__dirname,'..','..')
|
||||
|
||||
describe('cap/samples - Hierarchical Data', ()=>{
|
||||
|
||||
const csn = CDL`
|
||||
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
|
||||
|
||||
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
|
||||
expect (cds.db) .to.exist
|
||||
expect (cds.db.model) .to.exist
|
||||
})
|
||||
|
||||
it ('supports deeply nested inserts', ()=> INSERT.into (Cats,
|
||||
{ ID:100, name:'Some Cats...', children:[
|
||||
{ ID:101, name:'Cat', children:[
|
||||
{ ID:102, name:'Kitty', children:[
|
||||
{ ID:103, name:'Kitty Cat', children:[
|
||||
{ ID:104, name:'Aristocat' } ]},
|
||||
{ ID:105, name:'Kitty Bat' } ]},
|
||||
{ ID:106, name:'Catwoman', children:[
|
||||
{ ID:107, name:'Catalina' } ]} ]},
|
||||
{ ID:108, name:'Catweazle' }
|
||||
]}
|
||||
))
|
||||
|
||||
it ('should generate correct queries for expands', ()=>{
|
||||
let q = SELECT.from (Cats, c => { c.ID, c.name, c.children (c => c.name) })
|
||||
expect (q) .to.eql ({
|
||||
SELECT: {
|
||||
from: { ref:[ "Categories" ] },
|
||||
columns: [
|
||||
{ ref: [ "ID" ] },
|
||||
{ ref: [ "name" ] },
|
||||
{ ref: [ "children" ], expand: [ {ref:['name']} ] },
|
||||
]
|
||||
}
|
||||
})
|
||||
/* temp skip for release
|
||||
if (q.forSQL) expect (q.forSQL()) .to.eql ({
|
||||
SELECT: {
|
||||
from: { ref:[ "Categories" ], as: "Categories" },
|
||||
columns: [
|
||||
{ ref: [ "Categories", "ID" ] },
|
||||
{ ref: [ "Categories", "name" ] },
|
||||
{ as: "children", SELECT: { expand: true,
|
||||
one: false,
|
||||
columns: [{ ref: [ "children", "name" ]}],
|
||||
from: { ref:["Categories"], as: "children" },
|
||||
where: [
|
||||
{ref:[ "Categories", "ID" ]}, "=", {ref:[ "children", "parent_ID" ]}
|
||||
],
|
||||
}},
|
||||
],
|
||||
}
|
||||
})
|
||||
if (q.toSql) expect (q.toSql()) .to.eql (
|
||||
`SELECT json_insert('{}',` +
|
||||
`'$."ID"',ID,` +
|
||||
`'$."name"',name,` +
|
||||
`'$."children"',children->'$'` +
|
||||
`) as _json_ FROM (` +
|
||||
`SELECT Categories.ID,Categories.name,(` +
|
||||
`SELECT jsonb_group_array(jsonb_insert('{}','$."name"',name)) as _json_ FROM (` +
|
||||
`SELECT children.name FROM Categories as children WHERE Categories.ID = children.parent_ID` +
|
||||
`)` +
|
||||
`) as children FROM Categories as Categories` +
|
||||
`)`
|
||||
)
|
||||
*/
|
||||
})
|
||||
|
||||
it ('supports nested reads', ()=> expect (
|
||||
SELECT.one.from (Cats, c=>{
|
||||
c.ID, c.name.as('parent'), c.children (c=>{
|
||||
c.name.as('child')
|
||||
})
|
||||
}) .where ({name:'Cat'})
|
||||
) .to.eventually.eql (
|
||||
{ ID:101, parent:'Cat', children:[
|
||||
{ child:'Kitty' },
|
||||
{ child:'Catwoman' },
|
||||
]}
|
||||
))
|
||||
|
||||
it ('supports deeply nested reads', ()=> expect (
|
||||
SELECT.one.from (Cats, c=>{
|
||||
c.ID, c.name, c.children (
|
||||
c => { c.name },
|
||||
{levels:3}
|
||||
)
|
||||
}) .where ({name:'Cat'})
|
||||
) .to.eventually.eql (
|
||||
{ ID:101, name:'Cat', children:[
|
||||
{ name:'Kitty', children:[
|
||||
{ name:'Kitty Cat', children:[
|
||||
{ name:'Aristocat' }, ]}, // level 3
|
||||
{ name:'Kitty Bat', children:[] }, ]},
|
||||
{ name:'Catwoman', children:[
|
||||
{ name:'Catalina', children:[] } ]},
|
||||
]}
|
||||
))
|
||||
|
||||
it ('supports cascaded deletes', async()=>{
|
||||
const affectedRows = await DELETE.from (Cats) .where ({ID:[102,106]})
|
||||
expect (affectedRows) .to.be.greaterThan (0)
|
||||
await expect (SELECT`ID,name`.from(Cats) ).to.eventually.eql ([
|
||||
{ ID:100, name:'Some Cats...' },
|
||||
{ ID:101, name:'Cat' },
|
||||
{ ID:108, name:'Catweazle' }
|
||||
])
|
||||
})
|
||||
|
||||
})
|
||||
@@ -1,37 +0,0 @@
|
||||
#################################################
|
||||
#
|
||||
# Genres
|
||||
#
|
||||
|
||||
GET http://localhost:4004/odata/v4/test/Genres?
|
||||
###
|
||||
|
||||
GET http://localhost:4004/odata/v4/test/Genres?
|
||||
&$filter=parent_ID eq null&$select=name
|
||||
&$expand=children($select=name)
|
||||
###
|
||||
|
||||
POST http://localhost:4004/odata/v4/test/Genres?
|
||||
Content-Type: application/json
|
||||
|
||||
{ "ID":"100aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "name":"Some Sample Genres...", "children":[
|
||||
{ "ID":"101aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "name":"Cat", "children":[
|
||||
{ "ID":"102aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "name":"Kitty", "children":[
|
||||
{ "ID":"103aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "name":"Aristocat" },
|
||||
{ "ID":"104aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "name":"Kitty Bat" } ]},
|
||||
{ "ID":"105aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "name":"Catwoman", "children":[
|
||||
{ "ID":"106aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "name":"Catalina" } ]} ]},
|
||||
{ "ID":"107aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "name":"Catweazle" }
|
||||
]}
|
||||
###
|
||||
|
||||
GET http://localhost:4004/odata/v4/test/Genres(100aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa)?
|
||||
&$expand=children
|
||||
&$expand=children($expand=children($expand=children($expand=children)))
|
||||
###
|
||||
|
||||
DELETE http://localhost:4004/odata/v4/test/Genres(103aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa)
|
||||
###
|
||||
|
||||
DELETE http://localhost:4004/odata/v4/test/Genres(100aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa)
|
||||
###
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"devDependencies": {
|
||||
"@cap-js/sqlite": "*"
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
const cds = require('@sap/cds')
|
||||
const { GET, expect, axios } = cds.test ('@capire/bookshop')
|
||||
axios.defaults.auth = { username: 'alice', password: 'admin' }
|
||||
|
||||
describe('cap/samples - Bookshop APIs', () => {
|
||||
|
||||
it('serves $metadata documents in v4', async () => {
|
||||
const { headers, status, data } = await GET `/browse/$metadata`
|
||||
expect(status).to.equal(200)
|
||||
expect(headers).to.contain({
|
||||
// 'content-type': 'application/xml', //> fails with 'application/xml;charset=utf-8', which is set by express
|
||||
'odata-version': '4.0',
|
||||
})
|
||||
expect(headers['content-type']).to.match(/application\/xml/)
|
||||
expect(data).to.contain('<EntitySet Name="Books" EntityType="CatalogService.Books">')
|
||||
expect(data).to.contain('<Annotation Term="Common.Label" String="Currency"/>')
|
||||
})
|
||||
|
||||
it('serves ListOfBooks?$expand=genre,currency', async () => {
|
||||
const Mystery = { name: 'Mystery' }
|
||||
const Romance = { name: 'Romance' }
|
||||
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([
|
||||
{ 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 },
|
||||
])
|
||||
})
|
||||
|
||||
describe('query options...', () => {
|
||||
|
||||
it('supports $search in multiple fields', async () => {
|
||||
const { data } = await GET `/browse/Books ${{
|
||||
params: { $search: 'Po', $select: `title,author` },
|
||||
}}`
|
||||
expect(data.value).to.containSubset([
|
||||
{ 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' },
|
||||
{ ID: 252, title: 'Eleonora', author: 'Edgar Allen Poe' },
|
||||
])
|
||||
})
|
||||
|
||||
it('supports $select', async () => {
|
||||
const { data } = await GET(`/browse/Books`, {
|
||||
params: { $select: `ID,title` },
|
||||
})
|
||||
expect(data.value).to.containSubset([
|
||||
{ ID: 201, title: 'Wuthering Heights' },
|
||||
{ ID: 207, title: 'Jane Eyre' },
|
||||
{ ID: 251, title: 'The Raven' },
|
||||
{ ID: 252, title: 'Eleonora' },
|
||||
{ ID: 271, title: 'Catweazle' },
|
||||
])
|
||||
})
|
||||
|
||||
it('supports $expand', async () => {
|
||||
const { data } = await GET(`/admin/Authors`, {
|
||||
params: {
|
||||
$select: `name`,
|
||||
$expand: `books($select=title)`,
|
||||
},
|
||||
})
|
||||
expect(data.value).to.containSubset([
|
||||
{ name: 'Emily Brontë', books: [{ title: 'Wuthering Heights' }] },
|
||||
{ name: 'Charlotte Brontë', books: [{ title: 'Jane Eyre' }] },
|
||||
{ name: 'Edgar Allen Poe', books: [{ title: 'The Raven' }, { title: 'Eleonora' }] },
|
||||
{ name: 'Richard Carpenter', books: [{ title: 'Catweazle' }] },
|
||||
])
|
||||
})
|
||||
|
||||
it('supports $value requests', async () => {
|
||||
const { data } = await GET`/admin/Books/201/stock/$value`
|
||||
expect(data).to.equal(12)
|
||||
})
|
||||
|
||||
it('supports $top/$skip paging', async () => {
|
||||
const { data: p1 } = await GET`/browse/Books?$select=title&$top=3`
|
||||
expect(p1.value).to.containSubset([
|
||||
{ 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([
|
||||
{ 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' })
|
||||
const { data: joe } = await GET (`/user/me`, {auth: { username: 'joe' }})
|
||||
expect(joe).to.containSubset({ id: 'joe' })
|
||||
})
|
||||
|
||||
})
|
||||
@@ -1,126 +0,0 @@
|
||||
const cds = require('@sap/cds/lib')
|
||||
const { GET, expect, axios } = cds.test(__dirname)
|
||||
|
||||
// Fetch API disallows GET|HEAD requests with body
|
||||
if (axios.constructor.name === 'Naxios') it = it.skip
|
||||
|
||||
describe ('GET w/ query in body', () => {
|
||||
|
||||
it ('serves CQN query objects in body', async () => {
|
||||
const {data:books} = await GET ('/hcql/admin', {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
data: cds.ql `SELECT from Books`
|
||||
})
|
||||
expect(books).to.be.an('array').of.length(5)
|
||||
})
|
||||
|
||||
it ('serves plain CQL strings in body', async () => {
|
||||
const {data:books} = await GET ('/hcql/admin', {
|
||||
headers: { 'Content-Type': 'text/plain' },
|
||||
data: `SELECT from Books`
|
||||
})
|
||||
expect(books).to.be.an('array').of.length(5)
|
||||
})
|
||||
|
||||
it ('serves complex and deep queries', async () => {
|
||||
const {data:books} = await GET ('/hcql/admin', {
|
||||
headers: { 'Content-Type': 'text/plain' },
|
||||
data: `SELECT from Authors {
|
||||
name,
|
||||
books [order by title] {
|
||||
title,
|
||||
genre.name as genre
|
||||
}
|
||||
}`
|
||||
})
|
||||
expect(books).to.deep.equal([
|
||||
{
|
||||
name: "Emily Brontë",
|
||||
books: [
|
||||
{ title: "Wuthering Heights", genre: 'Drama' }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Charlotte Brontë",
|
||||
books: [
|
||||
{ title: "Jane Eyre", genre: 'Drama' }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Edgar Allen Poe",
|
||||
books: [
|
||||
{ title: "Eleonora", genre: 'Romance' },
|
||||
{ title: "The Raven", genre: 'Mystery' },
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Richard Carpenter",
|
||||
books: [
|
||||
{ title: "Catweazle", genre: 'Fantasy' }
|
||||
]
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
|
||||
describe ('Sluggified variants', () => {
|
||||
|
||||
test ('GET /Books', async () => {
|
||||
const {data:books} = await GET ('/hcql/admin/Books')
|
||||
expect(books).to.be.an('array').of.length(5)
|
||||
expect(books.length).to.eql(5) //.of.length(5)
|
||||
})
|
||||
|
||||
|
||||
test ('GET /Books/201', async () => {
|
||||
const {data:book} = await GET ('/hcql/admin/Books/201')
|
||||
expect(book).to.be.an('object')
|
||||
expect(book).to.have.property ('title', "Wuthering Heights")
|
||||
})
|
||||
|
||||
test ('GET /Books { title, author.name as author }' , async () => {
|
||||
const {data:books} = await GET ('/hcql/admin/Books { title, author.name as author } order by ID')
|
||||
expect(books).to.deep.equal ([
|
||||
{ title: "Wuthering Heights", 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" }
|
||||
])
|
||||
})
|
||||
|
||||
test ('GET /Books/201 w/ CQL tail in URL' , async () => {
|
||||
const {data:book} = await GET ('/hcql/admin/Books/201 { title, author.name as author } order by ID')
|
||||
expect(book).to.deep.equal ({ title: "Wuthering Heights", author: "Emily Brontë" })
|
||||
})
|
||||
|
||||
it ('GET /Books/201 w/ CQL fragment in body' , async () => {
|
||||
const {data:book} = await GET ('/hcql/admin/Books/201', {
|
||||
headers: { 'Content-Type': 'text/plain' },
|
||||
data: `{ title, author.name as author }`
|
||||
})
|
||||
expect(book).to.deep.equal ({ title: "Wuthering Heights", author: "Emily Brontë" })
|
||||
})
|
||||
|
||||
it ('GET /Books/201 w/ CQN fragment in body' , async () => {
|
||||
const {data:book} = await GET ('/hcql/admin/Books/201', {
|
||||
data: cds.ql `SELECT title, author.name as author` .SELECT
|
||||
})
|
||||
expect(book).to.deep.equal ({ title: "Wuthering Heights", author: "Emily Brontë" })
|
||||
})
|
||||
|
||||
it ('GET /Books/201 w/ tail in URL plus CQL/CQN fragments in body' , async () => {
|
||||
const {data:[b1]} = await GET ('/hcql/admin/Books where ID=201', {
|
||||
data: cds.ql `SELECT title, author.name as author` .SELECT
|
||||
})
|
||||
expect(b1).to.deep.equal ({ title: "Wuthering Heights", author: "Emily Brontë" })
|
||||
const {data:[b2]} = await GET ('/hcql/admin/Books where ID=201', {
|
||||
headers: { 'Content-Type': 'text/plain' },
|
||||
data: `{ title, author.name as author }`
|
||||
})
|
||||
expect(b2).to.deep.equal ({ title: "Wuthering Heights", author: "Emily Brontë" })
|
||||
})
|
||||
|
||||
})
|
||||
@@ -1,225 +0,0 @@
|
||||
@server = http://localhost:4004
|
||||
|
||||
GET {{server}}/odata/v4/admin/Authors?
|
||||
&$select=ID,name
|
||||
&$expand=books($select=ID,title)
|
||||
&$count=true
|
||||
###
|
||||
|
||||
#
|
||||
# The basic variant expects a CQN object passed as an application/json body
|
||||
# to a POST request. This is also the fastest one, as it doesn't need CQL parsing.
|
||||
# Note: $count is returned in X-Total-Count response header
|
||||
#
|
||||
GET {{server}}/hcql/admin
|
||||
Content-Type: application/json
|
||||
# Accept-Language: de
|
||||
|
||||
{ "SELECT": {
|
||||
"from": { "ref": [ "Authors" ] },
|
||||
"columns": [
|
||||
{ "ref": [ "name" ] },
|
||||
{ "ref": [ "books" ], "expand": [
|
||||
{ "ref": [ "ID" ] },
|
||||
{ "ref": [ "title" ] }
|
||||
]}
|
||||
],
|
||||
"count": true
|
||||
}}
|
||||
###
|
||||
|
||||
POST {{server}}/hcql/browse/submitOrder?book=201&quantity=2
|
||||
Authorization: Basic alice:
|
||||
###
|
||||
|
||||
POST {{server}}/hcql/browse/submitOrder
|
||||
Authorization: Basic alice:
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"book": 201,
|
||||
"quantity": 2
|
||||
}
|
||||
###
|
||||
|
||||
GET {{server}}/hcql/browse/submitOrder?book=201&quantity=2
|
||||
Authorization: Basic alice:
|
||||
###
|
||||
|
||||
#
|
||||
# Alternatively you can pass a CQL string as plain/text body
|
||||
#
|
||||
GET {{server}}/hcql/admin
|
||||
Content-Type: text/plain
|
||||
# X-Total-Count: true
|
||||
|
||||
SELECT from Authors { name, books { title }}
|
||||
# SELECT from Books { title, currency }
|
||||
###
|
||||
|
||||
#
|
||||
# In addition we offer convenience slug routes...
|
||||
# .e.g. /srv/entity routes
|
||||
#
|
||||
|
||||
|
||||
GET {{server}}/hcql/admin/Books
|
||||
###
|
||||
|
||||
GET {{server}}/hcql/admin/Books/201
|
||||
###
|
||||
|
||||
GET {{server}}/hcql/admin/Books { ID, title, author.name as author }
|
||||
###
|
||||
|
||||
GET {{server}}/hcql/admin/Books order by stock desc
|
||||
Content-Type: text/plain
|
||||
|
||||
{ title, stock }
|
||||
###
|
||||
|
||||
GET {{server}}/hcql/admin/Books/201 { ID, title, author.name }
|
||||
###
|
||||
|
||||
GET {{server}}/hcql/admin/Books/201 { ID, title, author{name} }
|
||||
###
|
||||
|
||||
|
||||
POST {{server}}/hcql/admin/Books?title=The Black Cat&author_ID=101
|
||||
###
|
||||
|
||||
|
||||
POST {{server}}/hcql/admin/Books?title=The Black Cat
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"author_ID": 101
|
||||
}
|
||||
###
|
||||
|
||||
POST {{server}}/hcql/admin/Books
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"title": "The Black Cat",
|
||||
"author": { "ID": 101 }
|
||||
}
|
||||
###
|
||||
|
||||
PUT {{server}}/hcql/admin/Books/275?title=Catastrophe
|
||||
###
|
||||
|
||||
PATCH {{server}}/hcql/admin/Books/275
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"title": "Catastrophe"
|
||||
}
|
||||
###
|
||||
|
||||
GET {{server}}/hcql/admin/Authors { name, books { ID, title }}
|
||||
###
|
||||
|
||||
GET {{server}}/hcql/admin/Books { ID, title, author.name as author } order by ID desc
|
||||
###
|
||||
|
||||
|
||||
|
||||
// ------------------------------------
|
||||
|
||||
POST {{server}}/hcql/admin
|
||||
Content-Type: application/json
|
||||
|
||||
{"SELECT": { "from": { "ref": ["Books"] }}}
|
||||
###
|
||||
|
||||
POST {{server}}/hcql/admin
|
||||
Content-Type: text/plain
|
||||
|
||||
SELECT from Authors {
|
||||
name as author,
|
||||
books {
|
||||
title,
|
||||
stock,
|
||||
price,
|
||||
currency { * }
|
||||
}
|
||||
}
|
||||
where name like '%Bro%'
|
||||
order by name asc
|
||||
###
|
||||
|
||||
|
||||
#
|
||||
# Simple REST-style URLs as supported as well
|
||||
#
|
||||
|
||||
GET {{server}}/hcql/admin/Books
|
||||
###
|
||||
|
||||
GET {{server}}/hcql/admin/Books/201
|
||||
###
|
||||
|
||||
|
||||
#
|
||||
# REST-style URLs can be combined with trailing CQL in the path, in plain
|
||||
# text body, or with projections sent as application/json array
|
||||
#
|
||||
|
||||
GET {{server}}/hcql/admin/Books order by stock desc
|
||||
###
|
||||
|
||||
GET {{server}}/hcql/admin/Books { title as book, stock } order by stock desc
|
||||
###
|
||||
|
||||
GET {{server}}/hcql/admin/Authors
|
||||
Content-Type: text/plain
|
||||
Accept-Language: fr
|
||||
|
||||
{
|
||||
ID, name as author,
|
||||
books {
|
||||
title,
|
||||
stock,
|
||||
currency { * }
|
||||
}
|
||||
}
|
||||
where name like '%Bro%'
|
||||
order by name asc
|
||||
###
|
||||
|
||||
|
||||
GET {{server}}/hcql/admin/Books/201 { title, stock }
|
||||
###
|
||||
|
||||
GET {{server}}/hcql/admin/Books order by stock desc
|
||||
Content-Type: text/plain
|
||||
|
||||
{ title, stock }
|
||||
###
|
||||
|
||||
|
||||
#
|
||||
# CQL adaptor also provides access to the underlying CSN schema
|
||||
#
|
||||
|
||||
GET {{server}}/hcql/admin/$csn
|
||||
###
|
||||
|
||||
|
||||
|
||||
#
|
||||
# CQL adaptor also supports INSERTs, UPDATEs, DELETEs ...
|
||||
#
|
||||
|
||||
POST {{server}}/hcql/admin
|
||||
Content-Type: application/jsonin wonderland
|
||||
|
||||
{ "INSERT": {
|
||||
"into": "Books",
|
||||
"entries": [{
|
||||
"title": "The Black Cat",
|
||||
"author": { "ID": 150 }
|
||||
}]
|
||||
}}
|
||||
###
|
||||
@@ -1,26 +0,0 @@
|
||||
@server = http://localhost:4004
|
||||
|
||||
GET {{server}}/odata/v2/admin/Authors
|
||||
Authorization: Basic alice:
|
||||
###
|
||||
|
||||
GET {{server}}/odata/v2/admin/Authors?$select=ID,name&$expand=books($select=ID,title)
|
||||
Authorization: Basic alice:
|
||||
###
|
||||
|
||||
GET {{server}}/odata/v4/admin/Authors
|
||||
Authorization: Basic alice:
|
||||
###
|
||||
|
||||
GET {{server}}/odata/v4/admin/Authors?$select=ID,name&$expand=books($select=ID,title)
|
||||
Authorization: Basic alice:
|
||||
###
|
||||
|
||||
|
||||
GET {{server}}/rest/admin/Authors
|
||||
Authorization: Basic alice:
|
||||
###
|
||||
|
||||
GET {{server}}/rest/admin/Authors?$select=ID,name&$expand=books($select=ID,title)
|
||||
Authorization: Basic alice:
|
||||
###
|
||||
@@ -1,9 +0,0 @@
|
||||
@server = http://localhost:4004
|
||||
|
||||
GET {{server}}/rest/admin/Authors
|
||||
Authorization: Basic alice:
|
||||
###
|
||||
|
||||
GET {{server}}/rest/admin/Authors?$select=ID,name&$expand=books($select=ID,title)
|
||||
Authorization: Basic alice:
|
||||
###
|
||||
@@ -1,4 +0,0 @@
|
||||
|
||||
using { CatalogService, AdminService } from '@capire/bookstore';
|
||||
annotate CatalogService with @hcql @odata @path:'browse' @requires:[];
|
||||
annotate AdminService with @hcql @odata @path:'admin';
|
||||
@@ -40,7 +40,8 @@ Authorization: Basic alice:
|
||||
|
||||
{
|
||||
"ID": 112,
|
||||
"name": "Shakespeeeeere"
|
||||
"name": "Shakespeeeeere",
|
||||
"age": 22
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +56,7 @@ Authorization: Basic alice:
|
||||
"title": "Poems : Pocket Poets",
|
||||
"descr": "The Everyman's Library Pocket Poets hardcover series is popular for its compact size and reasonable price which does not compromise content. Poems: Bronte contains poems that demonstrate a sensibility elemental in its force with an imaginative discipline and flexibility of the highest order. Also included are an Editor's Note and an index of first lines.",
|
||||
"author": { "ID": 101 },
|
||||
"genre": { "ID": "12aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" },
|
||||
"genre": { "ID": 12 },
|
||||
"stock": 5,
|
||||
"price": "12.05",
|
||||
"currency": { "code": "USD" }
|
||||
7
bookstore/@types/AdminService/index.js
Normal file
7
bookstore/@types/AdminService/index.js
Normal file
@@ -0,0 +1,7 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
const cds = require('@sap/cds')
|
||||
const cson = cds.entities('AdminService')
|
||||
module.exports.Book = cson.Books
|
||||
module.exports.Books = cson.Books
|
||||
module.exports.Author = cson.Authors
|
||||
module.exports.Authors = cson.Authors
|
||||
54
bookstore/@types/AdminService/index.ts
Normal file
54
bookstore/@types/AdminService/index.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
import * as _sap_capire_bookshop from './../sap/capire/bookshop';
|
||||
import * as __ from './../_';
|
||||
import * as _ from './..';
|
||||
import * as _ReviewsService from './../ReviewsService';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export function Book<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class BookAspect extends Base {
|
||||
ID: number;
|
||||
title: string;
|
||||
descr: string;
|
||||
author: __.Association.to<_sap_capire_bookshop.Author>;
|
||||
genre: __.Association.to<_sap_capire_bookshop.Genre>;
|
||||
stock: number;
|
||||
price: number;
|
||||
/**
|
||||
* Type for an association to Currencies
|
||||
*
|
||||
* See https://cap.cloud.sap/docs/cds/common#type-currency
|
||||
*/
|
||||
currency: __.Association.to<_.Currency>;
|
||||
image: string;
|
||||
reviews: __.Composition.of.many<_ReviewsService.Reviews>;
|
||||
rating: number;
|
||||
numberOfReviews: number;
|
||||
};
|
||||
}
|
||||
const BookXtended = _.managed(Book(__.Entity))
|
||||
export type Book = InstanceType<typeof BookXtended>
|
||||
|
||||
export class Books extends Array<Book> {
|
||||
}
|
||||
|
||||
export function Author<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class AuthorAspect extends Base {
|
||||
ID: number;
|
||||
name: string;
|
||||
dateOfBirth: Date;
|
||||
dateOfDeath: Date;
|
||||
placeOfBirth: string;
|
||||
placeOfDeath: string;
|
||||
books: __.Association.to.many<_sap_capire_bookshop.Books>;
|
||||
};
|
||||
}
|
||||
const AuthorXtended = _.managed(Author(__.Entity))
|
||||
export type Author = InstanceType<typeof AuthorXtended>
|
||||
|
||||
export class Authors extends Array<Author> {
|
||||
}
|
||||
|
||||
7
bookstore/@types/CatalogService/index.js
Normal file
7
bookstore/@types/CatalogService/index.js
Normal file
@@ -0,0 +1,7 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
const cds = require('@sap/cds')
|
||||
const cson = cds.entities('CatalogService')
|
||||
module.exports.ListOfBook = cson.ListOfBooks
|
||||
module.exports.ListOfBooks = cson.ListOfBooks
|
||||
module.exports.Book = cson.Books
|
||||
module.exports.Books = cson.Books
|
||||
72
bookstore/@types/CatalogService/index.ts
Normal file
72
bookstore/@types/CatalogService/index.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
import * as _sap_capire_bookshop from './../sap/capire/bookshop';
|
||||
import * as __ from './../_';
|
||||
import * as _ from './..';
|
||||
import * as _ReviewsService from './../ReviewsService';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* For displaying lists of Books
|
||||
*/
|
||||
export function ListOfBook<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class ListOfBookAspect extends Base {
|
||||
ID: number;
|
||||
title: string;
|
||||
descr: string;
|
||||
author: __.Association.to<_sap_capire_bookshop.Author>;
|
||||
genre: __.Association.to<_sap_capire_bookshop.Genre>;
|
||||
stock: number;
|
||||
price: number;
|
||||
/**
|
||||
* Type for an association to Currencies
|
||||
*
|
||||
* See https://cap.cloud.sap/docs/cds/common#type-currency
|
||||
*/
|
||||
currency: __.Association.to<_.Currency>;
|
||||
image: string;
|
||||
reviews: __.Composition.of.many<_ReviewsService.Reviews>;
|
||||
rating: number;
|
||||
numberOfReviews: number;
|
||||
};
|
||||
}
|
||||
const ListOfBookXtended = _.managed(ListOfBook(__.Entity))
|
||||
export type ListOfBook = InstanceType<typeof ListOfBookXtended>
|
||||
|
||||
export class ListOfBooks extends Array<ListOfBook> {
|
||||
}
|
||||
|
||||
/**
|
||||
* For display in details pages
|
||||
*/
|
||||
export function Book<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class BookAspect extends Base {
|
||||
ID: number;
|
||||
title: string;
|
||||
descr: string;
|
||||
author: __.Association.to<_sap_capire_bookshop.Author>;
|
||||
genre: __.Association.to<_sap_capire_bookshop.Genre>;
|
||||
stock: number;
|
||||
price: number;
|
||||
/**
|
||||
* Type for an association to Currencies
|
||||
*
|
||||
* See https://cap.cloud.sap/docs/cds/common#type-currency
|
||||
*/
|
||||
currency: __.Association.to<_.Currency>;
|
||||
image: string;
|
||||
reviews: __.Composition.of.many<_ReviewsService.Reviews>;
|
||||
rating: number;
|
||||
numberOfReviews: number;
|
||||
};
|
||||
}
|
||||
const BookXtended = _.managed(Book(__.Entity))
|
||||
export type Book = InstanceType<typeof BookXtended>
|
||||
|
||||
export class Books extends Array<Book> {
|
||||
}
|
||||
|
||||
// action
|
||||
export declare const submitOrder: (book: Books, quantity: number) => {};
|
||||
7
bookstore/@types/DataService/index.js
Normal file
7
bookstore/@types/DataService/index.js
Normal file
@@ -0,0 +1,7 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
const cds = require('@sap/cds')
|
||||
const cson = cds.entities('DataService')
|
||||
module.exports.Entity = cson.Entities
|
||||
module.exports.Entities = cson.Entities
|
||||
module.exports.Data = cson.Data
|
||||
module.exports.Data_ = cson.Data
|
||||
40
bookstore/@types/DataService/index.ts
Normal file
40
bookstore/@types/DataService/index.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
import * as __ from './../_';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Metadata like name and columns/elements
|
||||
*/
|
||||
export function Entity<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class EntityAspect extends Base {
|
||||
name: string;
|
||||
columns: {
|
||||
name: string;
|
||||
type: string;
|
||||
isKey: boolean;
|
||||
};
|
||||
};
|
||||
}
|
||||
const EntityXtended = Entity(__.Entity)
|
||||
export type Entity = InstanceType<typeof EntityXtended>
|
||||
|
||||
export class Entities extends Array<Entity> {
|
||||
}
|
||||
|
||||
/**
|
||||
* The actual data, organized by column name
|
||||
*/
|
||||
export function Data<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class DataAspect extends Base {
|
||||
record: {};
|
||||
};
|
||||
}
|
||||
const DataXtended = Data(__.Entity)
|
||||
export type Data = InstanceType<typeof DataXtended>
|
||||
|
||||
export class Data_ extends Array<Data> {
|
||||
}
|
||||
|
||||
5
bookstore/@types/OrdersService/index.js
Normal file
5
bookstore/@types/OrdersService/index.js
Normal file
@@ -0,0 +1,5 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
const cds = require('@sap/cds')
|
||||
const cson = cds.entities('OrdersService')
|
||||
module.exports.Order = cson.Orders
|
||||
module.exports.Orders = cson.Orders
|
||||
39
bookstore/@types/OrdersService/index.ts
Normal file
39
bookstore/@types/OrdersService/index.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
import * as _sap_capire_orders from './../sap/capire/orders';
|
||||
import * as __ from './../_';
|
||||
import * as _sap_capire_bookshop from './../sap/capire/bookshop';
|
||||
import * as _ from './..';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export function Order<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class OrderAspect extends Base {
|
||||
OrderNo: string;
|
||||
Items: {
|
||||
ID: string;
|
||||
product: __.Association.to<_sap_capire_orders.Product>;
|
||||
quantity: number;
|
||||
title: string;
|
||||
price: number;
|
||||
book: __.Association.to<_sap_capire_bookshop.Book>;
|
||||
};
|
||||
/**
|
||||
* Canonical user ID
|
||||
*/
|
||||
buyer: _.User;
|
||||
/**
|
||||
* Type for an association to Currencies
|
||||
*
|
||||
* See https://cap.cloud.sap/docs/cds/common#type-currency
|
||||
*/
|
||||
currency: __.Association.to<_.Currency>;
|
||||
};
|
||||
}
|
||||
const OrderXtended = _.cuid(_.managed(Order(__.Entity)))
|
||||
export type Order = InstanceType<typeof OrderXtended>
|
||||
|
||||
export class Orders extends Array<Order> {
|
||||
}
|
||||
|
||||
5
bookstore/@types/ReviewsService/index.js
Normal file
5
bookstore/@types/ReviewsService/index.js
Normal file
@@ -0,0 +1,5 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
const cds = require('@sap/cds')
|
||||
const cson = cds.entities('ReviewsService')
|
||||
module.exports.Review = cson.Reviews
|
||||
module.exports.Reviews = cson.Reviews
|
||||
35
bookstore/@types/ReviewsService/index.ts
Normal file
35
bookstore/@types/ReviewsService/index.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
import * as _sap_capire_reviews from './../sap/capire/reviews';
|
||||
import * as _ from './..';
|
||||
import * as __ from './../_';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export function Review<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class ReviewAspect extends Base {
|
||||
ID: string;
|
||||
subject: _sap_capire_reviews.ReviewedSubject;
|
||||
/**
|
||||
* Canonical user ID
|
||||
*/
|
||||
reviewer: _.User;
|
||||
rating: _sap_capire_reviews.Rating;
|
||||
title: string;
|
||||
text: string;
|
||||
date: Date;
|
||||
likes: __.Composition.of.many<_sap_capire_reviews.Likes>;
|
||||
liked: number;
|
||||
};
|
||||
}
|
||||
const ReviewXtended = Review(__.Entity)
|
||||
export type Review = InstanceType<typeof ReviewXtended>
|
||||
|
||||
export class Reviews extends Array<Review> {
|
||||
}
|
||||
|
||||
// action
|
||||
export declare const like: (review: Reviews) => {};
|
||||
// action
|
||||
export declare const unlike: (review: Reviews) => {};
|
||||
3
bookstore/@types/_/index.js
Normal file
3
bookstore/@types/_/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
const cds = require('@sap/cds')
|
||||
const cson = cds.entities('_')
|
||||
35
bookstore/@types/_/index.ts
Normal file
35
bookstore/@types/_/index.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
|
||||
|
||||
export namespace Association {
|
||||
export type to <T> = T & ((fn:(a:T)=>any) => T)
|
||||
export namespace to {
|
||||
// type many <T> = T[] & (T extends (infer R)[] ? R[] & ((fn:(a:R)=>any) => R[]) : T[]);
|
||||
export type many <T extends readonly unknown[]> = T & ((fn:(a:T[number])=>any) => T[number]);
|
||||
}
|
||||
}
|
||||
|
||||
export namespace Composition {
|
||||
export type of <T> = T & ((fn:(a:T)=>any) => T)
|
||||
export namespace of {
|
||||
//type many <T> = T[] & (T extends (infer R)[] ? R[] & ((fn:(a:R)=>any) => R[]) : T[]);
|
||||
export type many <T extends readonly unknown[]> = T & ((fn:(a:T[number])=>any) => T[number]);
|
||||
}
|
||||
}
|
||||
|
||||
export class Entity {
|
||||
static data<T extends Entity> (this:T, input:Object) : T {
|
||||
return {} as T // mock
|
||||
}
|
||||
}
|
||||
|
||||
export type EntitySet<T> = T[] & {
|
||||
data (input:object[]) : T[]
|
||||
data (input:object) : T
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
3
bookstore/@types/index.js
Normal file
3
bookstore/@types/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
const cds = require('@sap/cds')
|
||||
const cson = cds.entities('')
|
||||
57
bookstore/@types/index.ts
Normal file
57
bookstore/@types/index.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
import * as _sap_common from './sap/common';
|
||||
import * as __ from './_';
|
||||
|
||||
export type Language = __.Association.to<_sap_common.Language>;
|
||||
export type Currency = __.Association.to<_sap_common.Currency>;
|
||||
export type Country = __.Association.to<_sap_common.Country>;
|
||||
export type User = string;
|
||||
|
||||
|
||||
// the following represents the CDS aspect 'cuid'
|
||||
export function cuid<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class cuidAspect extends Base {
|
||||
ID: string;
|
||||
};
|
||||
}
|
||||
const cuidXtended = cuid(__.Entity)
|
||||
export type cuid = InstanceType<typeof cuidXtended>
|
||||
|
||||
// the following represents the CDS aspect 'managed'
|
||||
export function managed<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class managedAspect extends Base {
|
||||
createdAt: Date;
|
||||
/**
|
||||
* Canonical user ID
|
||||
*/
|
||||
createdBy: User;
|
||||
modifiedAt: Date;
|
||||
/**
|
||||
* Canonical user ID
|
||||
*/
|
||||
modifiedBy: User;
|
||||
};
|
||||
}
|
||||
const managedXtended = managed(__.Entity)
|
||||
export type managed = InstanceType<typeof managedXtended>
|
||||
|
||||
// the following represents the CDS aspect 'temporal'
|
||||
export function temporal<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class temporalAspect extends Base {
|
||||
validFrom: Date;
|
||||
validTo: Date;
|
||||
};
|
||||
}
|
||||
const temporalXtended = temporal(__.Entity)
|
||||
export type temporal = InstanceType<typeof temporalXtended>
|
||||
|
||||
// the following represents the CDS aspect 'extensible'
|
||||
export function extensible<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class extensibleAspect extends Base {
|
||||
extensions__: string;
|
||||
};
|
||||
}
|
||||
const extensibleXtended = extensible(__.Entity)
|
||||
export type extensible = InstanceType<typeof extensibleXtended>
|
||||
|
||||
|
||||
9
bookstore/@types/sap/capire/bookshop/index.js
Normal file
9
bookstore/@types/sap/capire/bookshop/index.js
Normal file
@@ -0,0 +1,9 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
const cds = require('@sap/cds')
|
||||
const cson = cds.entities('sap.capire.bookshop')
|
||||
module.exports.Book = cson.Books
|
||||
module.exports.Books = cson.Books
|
||||
module.exports.Author = cson.Authors
|
||||
module.exports.Authors = cson.Authors
|
||||
module.exports.Genre = cson.Genres
|
||||
module.exports.Genres = cson.Genres
|
||||
70
bookstore/@types/sap/capire/bookshop/index.ts
Normal file
70
bookstore/@types/sap/capire/bookshop/index.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
import * as __ from './../../../_';
|
||||
import * as _ from './../../..';
|
||||
import * as _ReviewsService from './../../../ReviewsService';
|
||||
import * as _sap_common from './../../common';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export function Book<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class BookAspect extends Base {
|
||||
ID: number;
|
||||
title: string;
|
||||
descr: string;
|
||||
author: __.Association.to<Author>;
|
||||
genre: __.Association.to<Genre>;
|
||||
stock: number;
|
||||
price: number;
|
||||
/**
|
||||
* Type for an association to Currencies
|
||||
*
|
||||
* See https://cap.cloud.sap/docs/cds/common#type-currency
|
||||
*/
|
||||
currency: __.Association.to<_.Currency>;
|
||||
image: string;
|
||||
reviews: __.Composition.of.many<_ReviewsService.Reviews>;
|
||||
rating: number;
|
||||
numberOfReviews: number;
|
||||
};
|
||||
}
|
||||
const BookXtended = _.managed(Book(__.Entity))
|
||||
export type Book = InstanceType<typeof BookXtended>
|
||||
|
||||
export class Books extends Array<Book> {
|
||||
}
|
||||
|
||||
export function Author<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class AuthorAspect extends Base {
|
||||
ID: number;
|
||||
name: string;
|
||||
dateOfBirth: Date;
|
||||
dateOfDeath: Date;
|
||||
placeOfBirth: string;
|
||||
placeOfDeath: string;
|
||||
books: __.Association.to.many<Books>;
|
||||
};
|
||||
}
|
||||
const AuthorXtended = _.managed(Author(__.Entity))
|
||||
export type Author = InstanceType<typeof AuthorXtended>
|
||||
|
||||
export class Authors extends Array<Author> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Hierarchically organized Code List for Genres
|
||||
*/
|
||||
export function Genre<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class GenreAspect extends Base {
|
||||
ID: number;
|
||||
parent: __.Association.to<Genre>;
|
||||
children: __.Composition.of.many<Genres>;
|
||||
};
|
||||
}
|
||||
const GenreXtended = _sap_common.CodeList(Genre(__.Entity))
|
||||
export type Genre = InstanceType<typeof GenreXtended>
|
||||
|
||||
export class Genres extends Array<Genre> {
|
||||
}
|
||||
|
||||
7
bookstore/@types/sap/capire/orders/index.js
Normal file
7
bookstore/@types/sap/capire/orders/index.js
Normal file
@@ -0,0 +1,7 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
const cds = require('@sap/cds')
|
||||
const cson = cds.entities('sap.capire.orders')
|
||||
module.exports.Order = cson.Orders
|
||||
module.exports.Orders = cson.Orders
|
||||
module.exports.Product = cson.Products
|
||||
module.exports.Products = cson.Products
|
||||
52
bookstore/@types/sap/capire/orders/index.ts
Normal file
52
bookstore/@types/sap/capire/orders/index.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
import * as __ from './../../../_';
|
||||
import * as _sap_capire_bookshop from './../bookshop';
|
||||
import * as _ from './../../..';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export function Order<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class OrderAspect extends Base {
|
||||
OrderNo: string;
|
||||
Items: {
|
||||
ID: string;
|
||||
product: __.Association.to<Product>;
|
||||
quantity: number;
|
||||
title: string;
|
||||
price: number;
|
||||
book: __.Association.to<_sap_capire_bookshop.Book>;
|
||||
};
|
||||
/**
|
||||
* Canonical user ID
|
||||
*/
|
||||
buyer: _.User;
|
||||
/**
|
||||
* Type for an association to Currencies
|
||||
*
|
||||
* See https://cap.cloud.sap/docs/cds/common#type-currency
|
||||
*/
|
||||
currency: __.Association.to<_.Currency>;
|
||||
};
|
||||
}
|
||||
const OrderXtended = _.cuid(_.managed(Order(__.Entity)))
|
||||
export type Order = InstanceType<typeof OrderXtended>
|
||||
|
||||
export class Orders extends Array<Order> {
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a stand-in for arbitrary ordered Products
|
||||
*/
|
||||
export function Product<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class ProductAspect extends Base {
|
||||
ID: string;
|
||||
};
|
||||
}
|
||||
const ProductXtended = Product(__.Entity)
|
||||
export type Product = InstanceType<typeof ProductXtended>
|
||||
|
||||
export class Products extends Array<Product> {
|
||||
}
|
||||
|
||||
7
bookstore/@types/sap/capire/reviews/index.js
Normal file
7
bookstore/@types/sap/capire/reviews/index.js
Normal file
@@ -0,0 +1,7 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
const cds = require('@sap/cds')
|
||||
const cson = cds.entities('sap.capire.reviews')
|
||||
module.exports.Review = cson.Reviews
|
||||
module.exports.Reviews = cson.Reviews
|
||||
module.exports.Like = cson.Likes
|
||||
module.exports.Likes = cson.Likes
|
||||
51
bookstore/@types/sap/capire/reviews/index.ts
Normal file
51
bookstore/@types/sap/capire/reviews/index.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
import * as _ from './../../..';
|
||||
import * as __ from './../../../_';
|
||||
|
||||
export type ReviewedSubject = string;
|
||||
export enum Rating {
|
||||
Best = 5,
|
||||
Good = 4,
|
||||
Avg = 3,
|
||||
Poor = 2,
|
||||
Worst = 1,
|
||||
}
|
||||
|
||||
|
||||
export function Review<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class ReviewAspect extends Base {
|
||||
ID: string;
|
||||
subject: ReviewedSubject;
|
||||
/**
|
||||
* Canonical user ID
|
||||
*/
|
||||
reviewer: _.User;
|
||||
rating: Rating;
|
||||
title: string;
|
||||
text: string;
|
||||
date: Date;
|
||||
likes: __.Composition.of.many<Likes>;
|
||||
liked: number;
|
||||
};
|
||||
}
|
||||
const ReviewXtended = Review(__.Entity)
|
||||
export type Review = InstanceType<typeof ReviewXtended>
|
||||
|
||||
export class Reviews extends Array<Review> {
|
||||
}
|
||||
|
||||
export function Like<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class LikeAspect extends Base {
|
||||
review: __.Association.to<Review>;
|
||||
/**
|
||||
* Canonical user ID
|
||||
*/
|
||||
user: _.User;
|
||||
};
|
||||
}
|
||||
const LikeXtended = Like(__.Entity)
|
||||
export type Like = InstanceType<typeof LikeXtended>
|
||||
|
||||
export class Likes extends Array<Like> {
|
||||
}
|
||||
|
||||
9
bookstore/@types/sap/common/countries/index.js
Normal file
9
bookstore/@types/sap/common/countries/index.js
Normal file
@@ -0,0 +1,9 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
const cds = require('@sap/cds')
|
||||
const cson = cds.entities('sap.common.countries')
|
||||
module.exports.Region = cson.Regions
|
||||
module.exports.Regions = cson.Regions
|
||||
module.exports.City = cson.Cities
|
||||
module.exports.Cities = cson.Cities
|
||||
module.exports.District = cson.Districts
|
||||
module.exports.Districts = cson.Districts
|
||||
47
bookstore/@types/sap/common/countries/index.ts
Normal file
47
bookstore/@types/sap/common/countries/index.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
import * as __ from './../../../_';
|
||||
import * as _sap_common from './..';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export function Region<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class RegionAspect extends Base {
|
||||
code: string;
|
||||
children: __.Composition.of.many<Regions>;
|
||||
cities: __.Composition.of.many<Cities>;
|
||||
_parent: string;
|
||||
};
|
||||
}
|
||||
const RegionXtended = _sap_common.CodeList(Region(__.Entity))
|
||||
export type Region = InstanceType<typeof RegionXtended>
|
||||
|
||||
export class Regions extends Array<Region> {
|
||||
}
|
||||
|
||||
export function City<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class CityAspect extends Base {
|
||||
code: string;
|
||||
region: __.Association.to<Region>;
|
||||
districts: __.Composition.of.many<Districts>;
|
||||
};
|
||||
}
|
||||
const CityXtended = _sap_common.CodeList(City(__.Entity))
|
||||
export type City = InstanceType<typeof CityXtended>
|
||||
|
||||
export class Cities extends Array<City> {
|
||||
}
|
||||
|
||||
export function District<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class DistrictAspect extends Base {
|
||||
code: string;
|
||||
city: __.Association.to<City>;
|
||||
};
|
||||
}
|
||||
const DistrictXtended = _sap_common.CodeList(District(__.Entity))
|
||||
export type District = InstanceType<typeof DistrictXtended>
|
||||
|
||||
export class Districts extends Array<District> {
|
||||
}
|
||||
|
||||
9
bookstore/@types/sap/common/index.js
Normal file
9
bookstore/@types/sap/common/index.js
Normal file
@@ -0,0 +1,9 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
const cds = require('@sap/cds')
|
||||
const cson = cds.entities('sap.common')
|
||||
module.exports.Language = cson.Languages
|
||||
module.exports.Languages = cson.Languages
|
||||
module.exports.Country = cson.Countries
|
||||
module.exports.Countries = cson.Countries
|
||||
module.exports.Currency = cson.Currencies
|
||||
module.exports.Currencies = cson.Currencies
|
||||
73
bookstore/@types/sap/common/index.ts
Normal file
73
bookstore/@types/sap/common/index.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
// This is an automatically generated file. Please do not change its contents manually!
|
||||
import * as __ from './../../_';
|
||||
import * as _sap_common_countries from './countries';
|
||||
|
||||
export type Locale = string;
|
||||
|
||||
|
||||
// the following represents the CDS aspect 'CodeList'
|
||||
export function CodeList<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class CodeListAspect extends Base {
|
||||
name: string;
|
||||
descr: string;
|
||||
};
|
||||
}
|
||||
const CodeListXtended = CodeList(__.Entity)
|
||||
export type CodeList = InstanceType<typeof CodeListXtended>
|
||||
|
||||
/**
|
||||
* Code list for languages
|
||||
*
|
||||
* See https://cap.cloud.sap/docs/cds/common#entity-sapcommonlanguages
|
||||
*/
|
||||
export function Language<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class LanguageAspect extends Base {
|
||||
/**
|
||||
* Type for a language code
|
||||
*/
|
||||
code: Locale;
|
||||
};
|
||||
}
|
||||
const LanguageXtended = CodeList(Language(__.Entity))
|
||||
export type Language = InstanceType<typeof LanguageXtended>
|
||||
|
||||
export class Languages extends Array<Language> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Code list for countries
|
||||
*
|
||||
* See https://cap.cloud.sap/docs/cds/common#entity-sapcommoncountries
|
||||
*/
|
||||
export function Country<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class CountryAspect extends Base {
|
||||
code: string;
|
||||
regions: __.Composition.of.many<_sap_common_countries.Regions>;
|
||||
};
|
||||
}
|
||||
const CountryXtended = CodeList(Country(__.Entity))
|
||||
export type Country = InstanceType<typeof CountryXtended>
|
||||
|
||||
export class Countries extends Array<Country> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Code list for currencies
|
||||
*
|
||||
* See https://cap.cloud.sap/docs/cds/common#entity-sapcommoncurrencies
|
||||
*/
|
||||
export function Currency<TBase extends new (...args: any[]) => {}>(Base: TBase) {
|
||||
return class CurrencyAspect extends Base {
|
||||
code: string;
|
||||
symbol: string;
|
||||
numcode: number;
|
||||
exponent: number;
|
||||
minor: string;
|
||||
};
|
||||
}
|
||||
const CurrencyXtended = CodeList(Currency(__.Entity))
|
||||
export type Currency = InstanceType<typeof CurrencyXtended>
|
||||
|
||||
export class Currencies extends Array<Currency> {
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
Books = Livres
|
||||
Book = Livre
|
||||
Title = Titre
|
||||
Description = Description
|
||||
Stock = Action
|
||||
Image = Image
|
||||
Price = Prix
|
||||
Currency = Devise
|
||||
|
||||
Authors = Auteurs
|
||||
Author = Auteur
|
||||
AuthorID = ID de l''auteur
|
||||
Name = Nom
|
||||
DateOfBirth = Date de naissance
|
||||
DateOfDeath = Date de décès
|
||||
PlaceOfBirth = Lieu de naissance
|
||||
PlaceOfDeath = Lieu de décès
|
||||
|
||||
Genres = Genre
|
||||
Genre = Genre
|
||||
@@ -1,34 +0,0 @@
|
||||
400 = Ungültige Anfrage
|
||||
401 = Nicht autorisiert
|
||||
403 = Verboten
|
||||
404 = Nicht gefunden
|
||||
405 = Methode nicht zulässig
|
||||
406 = Nicht akzeptabel
|
||||
407 = Proxy-Authentifizierung erforderlich
|
||||
408 = Anfrage-Timeout
|
||||
409 = Konflikt
|
||||
410 = Weg
|
||||
411 = Erforderliche Länge
|
||||
412 = Vorbedingung fehlgeschlagen
|
||||
413 = Nutzlast zu groß
|
||||
414 = URI zu lang
|
||||
415 = Nicht unterstützter Medientyp
|
||||
416 = Bereich nicht erfüllbar
|
||||
417 = Erwartung fehlgeschlagen
|
||||
422 = Nicht verarbeitbarer Inhalt
|
||||
424 = Fehlgeschlagene Abhängigkeit
|
||||
428 = Vorbedingung erforderlich
|
||||
429 = Zu viele Anfragen
|
||||
431 = Anfrage-Headerfelder zu groß
|
||||
451 = Aus rechtlichen Gründen nicht verfügbar
|
||||
500 = Interner Serverfehler
|
||||
501 = Der Server unterstützt die zur Erfüllung der Anfrage erforderliche Funktionalität nicht
|
||||
502 = Ungültiges Gateway
|
||||
503 = Dienst nicht verfügbar
|
||||
504 = Gateway-Timeout
|
||||
|
||||
ASSERT_RANGE = Wert {0} liegt nicht im angegebenen Bereich [{1}, {2}]
|
||||
ASSERT_FORMAT = Wert "{0}" liegt nicht im angegebenen Format "{1}"
|
||||
ASSERT_ARRAY = Wert muss ein Array sein
|
||||
ASSERT_ENUM = Wert {0} ist gemäß Enumerationsdeklaration {{1}} ungültig
|
||||
ASSERT_NOT_NULL = Wert ist erforderlich
|
||||
@@ -1,34 +0,0 @@
|
||||
400 = Bad Request
|
||||
401 = Unauthorized
|
||||
403 = Forbidden
|
||||
404 = Not Found
|
||||
405 = Method Not Allowed
|
||||
406 = Not Acceptable
|
||||
407 = Proxy Authentication Required
|
||||
408 = Request Timeout
|
||||
409 = Conflict
|
||||
410 = Gone
|
||||
411 = Length Required
|
||||
412 = Precondition Failed
|
||||
413 = Payload Too Large
|
||||
414 = URI Too Long
|
||||
415 = Unsupported Media Type
|
||||
416 = Range Not Satisfiable
|
||||
417 = Expectation Failed
|
||||
422 = Unprocessable Content
|
||||
424 = Failed Dependency
|
||||
428 = Precondition Required
|
||||
429 = Too Many Requests
|
||||
431 = Request Header Fields Too Large
|
||||
451 = Unavailable For Legal Reasons
|
||||
500 = Internal Server Error
|
||||
501 = The server does not support the functionality required to fulfill the request
|
||||
502 = Bad Gateway
|
||||
503 = Service Unavailable
|
||||
504 = Gateway Timeout
|
||||
|
||||
ASSERT_RANGE = Value {0} is not in specified range [{1}, {2}]
|
||||
ASSERT_FORMAT = Value "{0}" is not in specified format "{1}"
|
||||
ASSERT_ARRAY = Value must be an array
|
||||
ASSERT_ENUM = Value {0} is invalid according to enum declaration {{1}}
|
||||
ASSERT_NOT_NULL = Value is required
|
||||
@@ -1,34 +0,0 @@
|
||||
400 = Requête incorrecte
|
||||
401 = Non autorisée
|
||||
403 = Interdite
|
||||
404 = Introuvable
|
||||
405 = Méthode non autorisée
|
||||
406 = Non acceptable
|
||||
407 = Authentification proxy requise
|
||||
408 = Délai d''expiration de la requête
|
||||
409 = Conflit
|
||||
410 = Disparu
|
||||
411 = Longueur requise
|
||||
412 = Échec de la condition préalable
|
||||
413 = Charge utile trop importante
|
||||
414 = URI trop longue
|
||||
415 = Type de média non pris en charge
|
||||
416 = Plage non satisfaisante
|
||||
417 = Échec de l''attente
|
||||
422 = Contenu non traitable
|
||||
424 = Dépendance échouée
|
||||
428 = Condition préalable requise
|
||||
429 = Trop de requêtes
|
||||
431 = Champs d''en-tête de requête trop importants
|
||||
451 = Indisponible pour des raisons juridiques
|
||||
500 = Erreur interne du serveur
|
||||
501 = Le serveur ne prend pas en charge la fonctionnalité requise pour répondre à la requête
|
||||
502 = Passerelle incorrecte
|
||||
503 = Service indisponible
|
||||
504 = Délai d''attente de la passerelle
|
||||
|
||||
ASSERT_RANGE = La valeur {0} n''est pas dans la plage spécifiée [{1}, {2}]
|
||||
ASSERT_FORMAT = La valeur "{0}" n''est pas au format spécifié "{1}"
|
||||
ASSERT_ARRAY = La valeur doit être un tableau
|
||||
ASSERT_ENUM = La valeur {0} n''est pas valide selon la déclaration d''énumération {{1}}
|
||||
ASSERT_NOT_NULL = La valeur est obligatoire
|
||||
@@ -1,5 +0,0 @@
|
||||
AuthorName = Name des Autors
|
||||
Age = Alter
|
||||
rder = Bestellung
|
||||
Orders = Bestellungen
|
||||
Price = Preis
|
||||
@@ -1,8 +0,0 @@
|
||||
Age = Age
|
||||
Lifetime = Lifetime
|
||||
|
||||
SubGenres = Subgenre
|
||||
|
||||
NumCode = Numeric Code
|
||||
MinorUnit = Minor Unit
|
||||
Exponent = Exponent
|
||||
@@ -1,233 +0,0 @@
|
||||
/*
|
||||
Common Annotations shared by all apps
|
||||
*/
|
||||
|
||||
using { sap.capire.bookshop as my } from '@capire/bookstore';
|
||||
using { sap.common } from '@capire/common';
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Books Lists
|
||||
//
|
||||
annotate my.Books with @(
|
||||
Common.SemanticKey : [ID],
|
||||
UI : {
|
||||
Identification : [{ Value: title }],
|
||||
SelectionFields : [
|
||||
ID,
|
||||
author_ID,
|
||||
price,
|
||||
currency_code
|
||||
],
|
||||
LineItem : [
|
||||
{ Value: ID, Label: '{i18n>Title}' },
|
||||
{ Value: author.ID, Label: '{i18n>Author}' },
|
||||
{ Value: genre.name },
|
||||
{ Value: stock },
|
||||
{ Value: price },
|
||||
{ Value: currency.symbol },
|
||||
]
|
||||
}
|
||||
) {
|
||||
ID @Common: {
|
||||
SemanticObject : 'Books',
|
||||
Text: title,
|
||||
TextArrangement : #TextOnly
|
||||
};
|
||||
author @ValueList.entity : 'Authors';
|
||||
};
|
||||
|
||||
annotate common.Currencies with {
|
||||
symbol @Common.Label : '{i18n>Currency}';
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Books Details
|
||||
//
|
||||
annotate my.Books with @(UI : {HeaderInfo : {
|
||||
TypeName : '{i18n>Book}',
|
||||
TypeNamePlural : '{i18n>Books}',
|
||||
Title : { Value: title },
|
||||
Description : { Value: author.name }
|
||||
}, });
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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}';
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Authors List
|
||||
//
|
||||
annotate my.Authors with @(
|
||||
Common.SemanticKey : [ID],
|
||||
UI : {
|
||||
Identification : [{ Value: name}],
|
||||
SelectionFields : [name],
|
||||
LineItem : [
|
||||
{ Value: ID },
|
||||
{ Value: dateOfBirth },
|
||||
{ Value: dateOfDeath },
|
||||
{ Value: placeOfBirth },
|
||||
{ Value: placeOfDeath },
|
||||
],
|
||||
}
|
||||
) {
|
||||
ID @Common: {
|
||||
SemanticObject : 'Authors',
|
||||
Text: name,
|
||||
TextArrangement : #TextOnly,
|
||||
};
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Author Details
|
||||
//
|
||||
annotate my.Authors with @(UI : {
|
||||
HeaderInfo : {
|
||||
TypeName : '{i18n>Author}',
|
||||
TypeNamePlural : '{i18n>Authors}',
|
||||
Title : { Value: name },
|
||||
Description : { Value: dateOfBirth }
|
||||
},
|
||||
Facets : [{
|
||||
$Type : 'UI.ReferenceFacet',
|
||||
Target : 'books/@UI.LineItem'
|
||||
}, ],
|
||||
});
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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}';
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Languages List
|
||||
//
|
||||
annotate common.Languages with @(
|
||||
Common.SemanticKey : [code],
|
||||
Identification : [{ Value: code}],
|
||||
UI : {
|
||||
SelectionFields : [
|
||||
name,
|
||||
descr
|
||||
],
|
||||
LineItem : [
|
||||
{ Value: code },
|
||||
{ Value: name },
|
||||
],
|
||||
}
|
||||
);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Language Details
|
||||
//
|
||||
annotate common.Languages with @(UI : {
|
||||
HeaderInfo : {
|
||||
TypeName : '{i18n>Language}',
|
||||
TypeNamePlural : '{i18n>Languages}',
|
||||
Title : { Value: name },
|
||||
Description : { Value: descr }
|
||||
},
|
||||
Facets : [{
|
||||
$Type : 'UI.ReferenceFacet',
|
||||
Label : '{i18n>Details}',
|
||||
Target : '@UI.FieldGroup#Details'
|
||||
}, ],
|
||||
FieldGroup #Details : {Data : [
|
||||
{ Value: code },
|
||||
{ Value: name },
|
||||
{ Value: descr }
|
||||
]},
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Currencies List
|
||||
//
|
||||
annotate common.Currencies with @(
|
||||
Common.SemanticKey : [code],
|
||||
Identification : [{ Value: code}],
|
||||
UI : {
|
||||
SelectionFields : [
|
||||
name,
|
||||
descr
|
||||
],
|
||||
LineItem : [
|
||||
{ Value: descr },
|
||||
{ Value: symbol },
|
||||
{ Value: code },
|
||||
],
|
||||
}
|
||||
);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Currency Details
|
||||
//
|
||||
annotate common.Currencies with @(UI : {
|
||||
HeaderInfo : {
|
||||
TypeName : '{i18n>Currency}',
|
||||
TypeNamePlural : '{i18n>Currencies}',
|
||||
Title : { Value: descr },
|
||||
Description : { Value: code }
|
||||
},
|
||||
Facets : [
|
||||
{
|
||||
$Type : 'UI.ReferenceFacet',
|
||||
Label : '{i18n>Details}',
|
||||
Target : '@UI.FieldGroup#Details'
|
||||
},
|
||||
{
|
||||
$Type : 'UI.ReferenceFacet',
|
||||
Label : '{i18n>Extended}',
|
||||
Target : '@UI.FieldGroup#Extended'
|
||||
},
|
||||
],
|
||||
FieldGroup #Details : {Data : [
|
||||
{ Value: name },
|
||||
{ Value: symbol },
|
||||
{ Value: code },
|
||||
{ Value: descr }
|
||||
]},
|
||||
FieldGroup #Extended : {Data : [
|
||||
{ Value: numcode },
|
||||
{ Value: minor },
|
||||
{ Value: exponent }
|
||||
]},
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Currencies Elements
|
||||
//
|
||||
annotate common.Currencies with {
|
||||
numcode @title: '{i18n>NumCode}';
|
||||
minor @title: '{i18n>MinorUnit}';
|
||||
exponent @title: '{i18n>Exponent}';
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Bookshop</title>
|
||||
|
||||
<script>
|
||||
window["sap-ushell-config"] = {
|
||||
defaultRenderer: "fiori2",
|
||||
applications: {},
|
||||
};
|
||||
</script>
|
||||
|
||||
<script id="sap-ushell-bootstrap" src="https://ui5.sap.com/test-resources/sap/ushell/bootstrap/sandbox.js"></script>
|
||||
<script id="sap-ui-bootstrap" src="https://ui5.sap.com/resources/sap-ui-core.js"
|
||||
data-sap-ui-libs="sap.m, sap.ushell, sap.collaboration, sap.ui.layout" data-sap-ui-compatVersion="edge"
|
||||
data-sap-ui-theme="sap_horizon"></script>
|
||||
<script>
|
||||
sap.ui.getCore().attachInit(() =>
|
||||
sap.ushell.Container.createRenderer().placeAt("content")
|
||||
);
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body class="sapUiBody" id="content">
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,33 +0,0 @@
|
||||
using { sap.capire.bookshop.Genres } from '@capire/bookstore';
|
||||
|
||||
annotate Genres with @cds.search: {name};
|
||||
annotate Genres with @readonly;
|
||||
annotate Genres with {
|
||||
name @title: '{i18n>Genre}';
|
||||
}
|
||||
|
||||
// Lists
|
||||
annotate Genres with @(
|
||||
Common.SemanticKey : [name],
|
||||
UI.SelectionFields : [name],
|
||||
UI.LineItem : [
|
||||
{ Value: name, Label: '{i18n>Name}' },
|
||||
],
|
||||
);
|
||||
|
||||
// Details
|
||||
annotate Genres with @(UI : {
|
||||
Identification : [{ Value: name }],
|
||||
HeaderInfo : {
|
||||
TypeName : '{i18n>Genre}',
|
||||
TypeNamePlural : '{i18n>Genres}',
|
||||
Title : { Value: name },
|
||||
Description : { Value: ID }
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Tree Views
|
||||
// annotate AdminService.Genres with @hierarchy; // upcomming simplification
|
||||
using from './tree-view';
|
||||
using from './value-help';
|
||||
@@ -1,42 +0,0 @@
|
||||
using { AdminService } from '@capire/bookstore';
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Genres Tree View
|
||||
//
|
||||
|
||||
// Tell Fiori about the structure of the hierarchy
|
||||
annotate AdminService.Genres with @Aggregation.RecursiveHierarchy #GenresHierarchy : {
|
||||
ParentNavigationProperty : parent, // navigates to a node's parent
|
||||
NodeProperty : ID, // identifies a node, usually the key
|
||||
};
|
||||
|
||||
// Fiori expects the following to be defined explicitly, even though they're always the same
|
||||
extend AdminService.Genres with @(
|
||||
// The columns expected by Fiori to be present in hierarchy entities
|
||||
Hierarchy.RecursiveHierarchy #GenresHierarchy : {
|
||||
LimitedDescendantCount : LimitedDescendantCount,
|
||||
DistanceFromRoot : DistanceFromRoot,
|
||||
DrillState : DrillState,
|
||||
LimitedRank : LimitedRank
|
||||
},
|
||||
// Disallow filtering on these properties from Fiori UIs
|
||||
Capabilities.FilterRestrictions.NonFilterableProperties: [
|
||||
'LimitedDescendantCount',
|
||||
'DistanceFromRoot',
|
||||
'DrillState',
|
||||
'LimitedRank'
|
||||
],
|
||||
// Disallow sorting on these properties from Fiori UIs
|
||||
Capabilities.SortRestrictions.NonSortableProperties : [
|
||||
'LimitedDescendantCount',
|
||||
'DistanceFromRoot',
|
||||
'DrillState',
|
||||
'LimitedRank'
|
||||
],
|
||||
) columns { // Ensure we can query these fields from database
|
||||
null as LimitedDescendantCount : Int16,
|
||||
null as DistanceFromRoot : Int16,
|
||||
null as DrillState : String,
|
||||
null as LimitedRank : Int16,
|
||||
};
|
||||
@@ -1,6 +0,0 @@
|
||||
// Value help with Tree View
|
||||
using from '../admin-books/fiori-service';
|
||||
annotate AdminService.Books:genre with @Common.ValueList.PresentationVariantQualifier: 'VH';
|
||||
annotate AdminService.Genres with @UI.PresentationVariant #VH: {
|
||||
RecursiveHierarchyQualifier : 'GenresHierarchy',
|
||||
};
|
||||
@@ -1,3 +0,0 @@
|
||||
sap.ui.define(["sap/fe/core/AppComponent"], ac => ac.extend("genres.Component", {
|
||||
metadata:{ manifest:'json' }
|
||||
}))
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user