Compare commits
71 Commits
audit-log-
...
typed-samp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d41f8e4ec | ||
|
|
f891be5251 | ||
|
|
a704f12b40 | ||
|
|
b981f8fb02 | ||
|
|
f45f0a05b3 | ||
|
|
a3adca1919 | ||
|
|
ac5e631a92 | ||
|
|
dc72a7dc9e | ||
|
|
d915bd7b54 | ||
|
|
ec4d7a4b92 | ||
|
|
07a686264d | ||
|
|
88c9f31a24 | ||
|
|
bcb6ffa20f | ||
|
|
f29f66c41e | ||
|
|
96375aa221 | ||
|
|
c1329a6f20 | ||
|
|
babb5780b0 | ||
|
|
cae45fcd87 | ||
|
|
bf2b12e4e8 | ||
|
|
e44d62ac49 | ||
|
|
0e053f98f3 | ||
|
|
662bfc35d3 | ||
|
|
af605bf685 | ||
|
|
04411e35a7 | ||
|
|
8f5c33f4f5 | ||
|
|
a893184736 | ||
|
|
ee4dcf116c | ||
|
|
58cef5558d | ||
|
|
7753cda65d | ||
|
|
df57a9d8d0 | ||
|
|
2d92b851f1 | ||
|
|
e157fc8a92 | ||
|
|
3b69a80975 | ||
|
|
b80ba7445d | ||
|
|
b733643f2a | ||
|
|
bf317bc2c9 | ||
|
|
bbebff4066 | ||
|
|
eb75394044 | ||
|
|
b8f65b687f | ||
|
|
c49c9691bd | ||
|
|
7e4bc0985e | ||
|
|
912271338d | ||
|
|
bbf1194a09 | ||
|
|
529c431518 | ||
|
|
3f85676edd | ||
|
|
959c07cee3 | ||
|
|
8cc09fde38 | ||
|
|
bb55c432c9 | ||
|
|
5fc86d45ad | ||
|
|
e86d0dc3a2 | ||
|
|
a661fb2d45 | ||
|
|
bfe0c831d6 | ||
|
|
cad615a662 | ||
|
|
7101c58920 | ||
|
|
07dc1e88b3 | ||
|
|
6f8d74dc9a | ||
|
|
ec57c5ea48 | ||
|
|
c040a47279 | ||
|
|
30bfd70c49 | ||
|
|
6fb9581cf1 | ||
|
|
e87d6cdfc5 | ||
|
|
29ea2bc2da | ||
|
|
12574271ac | ||
|
|
17b5cc1ad2 | ||
|
|
26ca7f54ad | ||
|
|
573e78253d | ||
|
|
a7511ed677 | ||
|
|
f1289b436b | ||
|
|
984ea2133b | ||
|
|
179d301acb | ||
|
|
bbf20b1ca3 |
8
.github/dependabot.yml
vendored
Normal file
8
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
version: 2
|
||||
|
||||
updates:
|
||||
- package-ecosystem: npm
|
||||
directory: /
|
||||
versioning-strategy: increase-if-necessary
|
||||
schedule:
|
||||
interval: daily
|
||||
3
.github/workflows/node.js.yml
vendored
3
.github/workflows/node.js.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [16.x, 14.x, 12.x]
|
||||
node-version: [16.x, 14.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@@ -24,5 +24,6 @@ jobs:
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- run: npm i -g npm@8
|
||||
- run: npm ci
|
||||
- run: npm test
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -12,6 +12,7 @@ target/
|
||||
*.mtar
|
||||
connection.properties
|
||||
default-env.json
|
||||
.cdsrc-private.json
|
||||
packages/messageBox
|
||||
reviews/msg-box
|
||||
reviews/db/test.db
|
||||
|
||||
@@ -16,7 +16,8 @@ app.use('/-/:tarball', (req,res,next) => {
|
||||
console.debug ('GET', req.params)
|
||||
try {
|
||||
const { tarball } = req.params
|
||||
const [, pkg ] = /^\w+-(\w+)/.exec(tarball)
|
||||
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)
|
||||
@@ -31,7 +32,7 @@ app.use('/-/:tarball', (req,res,next) => {
|
||||
app.use('/-', express.static(__dirname))
|
||||
|
||||
app.get('/*', (req,res)=>{
|
||||
const urlRegex = /^\/(@\w+)\/(\w+)/
|
||||
const urlRegex = /^\/(@[\w-]+)\/(.+)/
|
||||
const url = decodeURIComponent(req.url)
|
||||
console.debug ('GET',url)
|
||||
try {
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
},
|
||||
{
|
||||
"file": "fiori/app/services.cds",
|
||||
"description": "### Annotations for SAP Fiori Elements\n\n- [Adds an SAP Fiori elements application](https://cap.cloud.sap/docs/guides/fiori/) to bookstore, thereby introducing to:\n- [OData Annotations](https://cap.cloud.sap/docs/guides/fiori#adding-odata-annotations) in `.cds` files\n- Support for [Fiori Draft](https://cap.cloud.sap/docs/guides/fiori#draft)\n- Support for [Value Helps](https://cap.cloud.sap/docs/guides/fiori#value-help)\n- Serving SAP Fiori apps locally\n",
|
||||
"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": {
|
||||
@@ -136,4 +136,4 @@
|
||||
],
|
||||
"isPrimary": true,
|
||||
"description": "Overview of CAP Samples for Node.js"
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
@@ -7,13 +7,14 @@ Find here a collection of samples for the [SAP Cloud Application Programming Mod
|
||||
|
||||
### Preliminaries
|
||||
|
||||
1. Install [**@sap/cds-dk**](https://cap.cloud.sap/docs/get-started/) globally:
|
||||
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
|
||||
```
|
||||
|
||||
2. _Optional:_ [Use Visual Studio Code](https://cap.cloud.sap/docs/get-started/tools#vscode)
|
||||
3. _Optional:_ [Use Visual Studio Code](https://cap.cloud.sap/docs/get-started/tools#vscode)
|
||||
|
||||
### Download
|
||||
|
||||
|
||||
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> {
|
||||
}
|
||||
|
||||
@@ -3,14 +3,15 @@ const $ = sel => document.querySelector(sel)
|
||||
const GET = (url) => axios.get('/browse'+url)
|
||||
const POST = (cmd,data) => axios.post('/browse'+cmd,data)
|
||||
|
||||
const books = new Vue ({
|
||||
const books = Vue.createApp ({
|
||||
|
||||
el:'#app',
|
||||
|
||||
data: {
|
||||
data() {
|
||||
return {
|
||||
list: [],
|
||||
book: undefined,
|
||||
order: { quantity:1, succeeded:'', failed:'' }
|
||||
order: { quantity:1, succeeded:'', failed:'' },
|
||||
user: undefined
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
@@ -37,12 +38,30 @@ const books = new Vue ({
|
||||
book.stock = res.data.stock
|
||||
books.order = { quantity, succeeded: `Successfully ordered ${quantity} item(s).` }
|
||||
} catch (e) {
|
||||
books.order = { quantity, failed: e.response.data.error.message }
|
||||
books.order = { quantity, failed: e.response.data.error ? e.response.data.error.message : e.response.data }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
async login() {
|
||||
try {
|
||||
const { data:user } = await axios.post('/user/login',{})
|
||||
if (user.id !== 'anonymous') books.user = user
|
||||
} catch (err) { books.user = { id: err.message } }
|
||||
},
|
||||
|
||||
async getUserInfo() {
|
||||
try {
|
||||
const { data:user } = await axios.get('/user/me')
|
||||
if (user.id !== 'anonymous') books.user = user
|
||||
} catch (err) { books.user = { id: err.message } }
|
||||
},
|
||||
}
|
||||
})
|
||||
}).mount("#app")
|
||||
|
||||
// initially fill list of books
|
||||
books.fetch()
|
||||
books.getUserInfo()
|
||||
books.fetch() // initially fill list of books
|
||||
|
||||
document.addEventListener('keydown', (event) => {
|
||||
// hide user info on request
|
||||
if (event.key === 'u') books.user = undefined
|
||||
})
|
||||
|
||||
@@ -5,19 +5,32 @@
|
||||
<title> Capire Books </title>
|
||||
<link rel="stylesheet" href="https://unpkg.com/primitive-ui/dist/css/main.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.prod.js"></script>
|
||||
<style>
|
||||
.hovering tr:hover td { color:cyan; background: #123; cursor: pointer; }
|
||||
.rating-stars { color:teal }
|
||||
.succeeded { color:teal }
|
||||
.failed { color:red }
|
||||
.user {text-align: end; color: grey;}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body class="small-container", style="margin-top: 70px;">
|
||||
<div id='app'>
|
||||
|
||||
<h1> {{ document.title }} </h1>
|
||||
<form class="user" @submit.prevent="login">
|
||||
<div v-if="user">
|
||||
<div v-if="user.tenant">Tenant: {{ user.tenant }}</div>
|
||||
<div> User: {{ user.id }}</div>
|
||||
<div>Locale: {{ user.locale }}</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<input type="submit" value="Login" class="muted-button">
|
||||
<!-- <a href="/user/login()">Login</a> -->
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<h1> Capire Books </h1>
|
||||
|
||||
<input type="text" placeholder="Search..." @input="search">
|
||||
|
||||
|
||||
5
bookshop/jsconfig.json
Normal file
5
bookshop/jsconfig.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"checkJs": true
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,17 @@
|
||||
"name": "@capire/bookshop",
|
||||
"version": "1.0.0",
|
||||
"description": "A simple self-contained bookshop service.",
|
||||
"files": [
|
||||
"app",
|
||||
"srv",
|
||||
"db",
|
||||
"index.cds",
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"@sap/cds": "^5.0.4",
|
||||
"@sap/cds": ">=5.9",
|
||||
"express": "^4.17.1",
|
||||
"passport": "0.4.1"
|
||||
"passport": ">=0.4.1"
|
||||
},
|
||||
"scripts": {
|
||||
"genres": "cds serve test/genres.cds",
|
||||
|
||||
@@ -2,7 +2,8 @@ const cds = require('@sap/cds')
|
||||
|
||||
class CatalogService extends cds.ApplicationService { init(){
|
||||
|
||||
const { Books } = cds.entities ('sap.capire.bookshop')
|
||||
//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 => {
|
||||
|
||||
15
bookshop/srv/user-service.cds
Normal file
15
bookshop/srv/user-service.cds
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Exposes user information
|
||||
*/
|
||||
service UserService {
|
||||
/**
|
||||
* The current user
|
||||
*/
|
||||
@odata.singleton entity me {
|
||||
id : String; // user id
|
||||
locale : String;
|
||||
tenant : String;
|
||||
}
|
||||
|
||||
action login() returns me;
|
||||
}
|
||||
9
bookshop/srv/user-service.js
Normal file
9
bookshop/srv/user-service.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const cds = require('@sap/cds')
|
||||
module.exports = class UserService extends cds.Service { init(){
|
||||
this.on('READ', 'me', ({ tenant, user, locale }) => ({ id: user.id, locale, tenant }))
|
||||
this.on('login', (req) => {
|
||||
if (req.user._is_anonymous)
|
||||
req._.res.set('WWW-Authenticate','Basic realm="Users"').sendStatus(401)
|
||||
else return this.read('me')
|
||||
})
|
||||
}}
|
||||
@@ -16,9 +16,9 @@ GET {{server}}/browse/$metadata
|
||||
|
||||
### ------------------------------------------------------------------------
|
||||
# Browse Books as any user
|
||||
GET {{server}}/browse/Books?
|
||||
GET {{server}}/browse/ListOfBooks?
|
||||
# &$select=title,stock
|
||||
# &$expand=currency
|
||||
&$expand=genre
|
||||
# &sap-language=de
|
||||
{{me}}
|
||||
|
||||
|
||||
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> {
|
||||
}
|
||||
|
||||
5
bookstore/jsconfig.json
Normal file
5
bookstore/jsconfig.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"checkJs": true
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
"@capire/orders": "*",
|
||||
"@capire/common": "*",
|
||||
"@capire/data-viewer": "*",
|
||||
"@sap/cds": "^5",
|
||||
"@sap/cds": ">=5",
|
||||
"express": "^4.17.1"
|
||||
},
|
||||
"cds": {
|
||||
|
||||
@@ -11,7 +11,8 @@ module.exports = async()=>{ // called by server.js
|
||||
const db = await cds.connect.to ('db')
|
||||
|
||||
// reflect entity definitions used below...
|
||||
const { Books } = db.entities ('sap.capire.bookshop')
|
||||
//const { Books } = db.entities ('sap.capire.bookshop')
|
||||
const { Books, Book } = require('../@types/sap/capire/bookshop')
|
||||
|
||||
//
|
||||
// Delegate requests to read reviews to the ReviewsService
|
||||
@@ -19,8 +20,8 @@ module.exports = async()=>{ // called by server.js
|
||||
//
|
||||
CatalogService.prepend (srv => srv.on ('READ', 'Books/reviews', (req) => {
|
||||
console.debug ('> delegating request to ReviewsService')
|
||||
const [id] = req.params, { columns, limit } = req.query.SELECT
|
||||
return ReviewsService.read ('Reviews',columns).limit(limit).where({subject:String(id)})
|
||||
const [id] = req.params, { columns, limit } = 'SELECT' in req.query ? req.query.SELECT : {columns: [], limit: { rows: 0 }}
|
||||
return ReviewsService.read ('Reviews',columns).limit(limit.rows).where({subject:String(id)})
|
||||
}))
|
||||
|
||||
//
|
||||
@@ -28,7 +29,7 @@ module.exports = async()=>{ // called by server.js
|
||||
//
|
||||
CatalogService.on ('OrderedBook', async (msg) => {
|
||||
const { book, quantity, buyer } = msg.data
|
||||
const { title, price } = await db.tx(msg).read (Books, book, b => { b.title, b.price })
|
||||
const { title, price } = await db.tx(msg).read ('Books').where('ID = ' + book.ID).columns((/** @type {Book} */ b) => { b.title, b.price })
|
||||
return OrdersService.tx(msg).create ('Orders').entries({
|
||||
OrderNo: 'Order at '+ (new Date).toLocaleString(),
|
||||
Items: [{ product:{ID:`${book}`}, title, price, quantity }],
|
||||
|
||||
3
common/@types/_/index.js
Normal file
3
common/@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
common/@types/_/index.ts
Normal file
35
common/@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
common/@types/index.js
Normal file
3
common/@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
common/@types/index.ts
Normal file
57
common/@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
common/@types/sap/common/countries/index.js
Normal file
9
common/@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
common/@types/sap/common/countries/index.ts
Normal file
47
common/@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
common/@types/sap/common/index.js
Normal file
9
common/@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
common/@types/sap/common/index.ts
Normal file
73
common/@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> {
|
||||
}
|
||||
|
||||
5
common/jsconfig.json
Normal file
5
common/jsconfig.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"checkJs": true
|
||||
}
|
||||
}
|
||||
7
data-viewer/@types/DataService/index.js
Normal file
7
data-viewer/@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
data-viewer/@types/DataService/index.ts
Normal file
40
data-viewer/@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> {
|
||||
}
|
||||
|
||||
3
data-viewer/@types/_/index.js
Normal file
3
data-viewer/@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
data-viewer/@types/_/index.ts
Normal file
35
data-viewer/@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
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
5
data-viewer/jsconfig.json
Normal file
5
data-viewer/jsconfig.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"checkJs": true
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
"version": "0.1.0",
|
||||
"description": "A generic browser for data",
|
||||
"dependencies": {
|
||||
"@sap/cds": "^5.0.4"
|
||||
"@sap/cds": ">=5.0.4"
|
||||
},
|
||||
"files": [
|
||||
"app",
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
},
|
||||
"dataSources": {
|
||||
"AdminService": {
|
||||
"uri": "/admin/",
|
||||
"uri": "admin/",
|
||||
"type": "OData",
|
||||
"settings": {
|
||||
"odataVersion": "4.0"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"i18n": "i18n/i18n.properties",
|
||||
"dataSources": {
|
||||
"AdminService": {
|
||||
"uri": "/admin/",
|
||||
"uri": "admin/",
|
||||
"type": "OData",
|
||||
"settings": {
|
||||
"odataVersion": "4.0"
|
||||
|
||||
@@ -19,6 +19,14 @@
|
||||
"title": "Browse Books",
|
||||
"targetURL": "#Books-display"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "BrowseGenres",
|
||||
"tileType": "sap.ushell.ui.tile.StaticTile",
|
||||
"properties": {
|
||||
"title": "Browse Genres (OData v2)",
|
||||
"targetURL": "#Genres-display"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -107,6 +115,24 @@
|
||||
"url": "/admin-authors/webapp"
|
||||
}
|
||||
},
|
||||
"BrowseGenres": {
|
||||
"semanticObject": "Genres",
|
||||
"action": "display",
|
||||
"title": "Browse Genres",
|
||||
"signature": {
|
||||
"parameters": {
|
||||
"Genre.ID": {
|
||||
"renameTo": "ID"
|
||||
}
|
||||
},
|
||||
"additionalParameters": "ignored"
|
||||
},
|
||||
"resolutionResult": {
|
||||
"applicationType": "SAPUI5",
|
||||
"additionalInformation": "SAPUI5.Component=genres",
|
||||
"url": "/genres/webapp"
|
||||
}
|
||||
},
|
||||
"ManageBooks": {
|
||||
"semanticObject": "Books",
|
||||
"action": "manage",
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
},
|
||||
"dataSources": {
|
||||
"CatalogService": {
|
||||
"uri": "/browse/",
|
||||
"uri": "browse/",
|
||||
"type": "OData",
|
||||
"settings": {
|
||||
"odataVersion": "4.0"
|
||||
@@ -32,7 +32,7 @@
|
||||
"renameTo": "ID"
|
||||
},
|
||||
"Authors.books.ID": {
|
||||
"renameTo": "ID"
|
||||
"renameTo": "ID"
|
||||
}
|
||||
},
|
||||
"additionalParameters": "ignored"
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
<script id="sap-ushell-bootstrap" src="https://sapui5.hana.ondemand.com/test-resources/sap/ushell/bootstrap/sandbox.js"></script>
|
||||
<script id="sap-ui-bootstrap" src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
|
||||
data-sap-ui-libs="sap.m, sap.ushell, sap.collaboration, sap.ui.layout"
|
||||
data-sap-ui-compatVersion="edge"
|
||||
data-sap-ui-theme="sap_fiori_3"
|
||||
data-sap-ui-frameOptions="allow"
|
||||
data-sap-ui-libs="sap.m, sap.ushell, sap.collaboration, sap.ui.layout"
|
||||
data-sap-ui-compatVersion="edge"
|
||||
data-sap-ui-theme="sap_horizon"
|
||||
data-sap-ui-frameOptions="allow"
|
||||
></script>
|
||||
<script>
|
||||
sap.ui.getCore().attachInit(()=> sap.ushell.Container.createRenderer().placeAt("content"))
|
||||
|
||||
8
fiori/app/genres/fiori-service.cds
Normal file
8
fiori/app/genres/fiori-service.cds
Normal file
@@ -0,0 +1,8 @@
|
||||
using { sap.capire.bookshop } from '../../db/common';
|
||||
|
||||
annotate bookshop.GenreHierarchy {
|
||||
ID @sap.hierarchy.node.for;
|
||||
parent @sap.hierarchy.parent.node.for;
|
||||
hierarchyLevel @sap.hierarchy.level.for;
|
||||
drillState @sap.hierarchy.drill.state.for;
|
||||
}
|
||||
7
fiori/app/genres/webapp/Component.js
Normal file
7
fiori/app/genres/webapp/Component.js
Normal file
@@ -0,0 +1,7 @@
|
||||
sap.ui.define(["sap/suite/ui/generic/template/lib/AppComponent"], (AppComponent) =>
|
||||
AppComponent.extend("genres.Component", {
|
||||
metadata: {
|
||||
manifest: "json",
|
||||
},
|
||||
})
|
||||
);
|
||||
4
fiori/app/genres/webapp/i18n/i18n.properties
Normal file
4
fiori/app/genres/webapp/i18n/i18n.properties
Normal file
@@ -0,0 +1,4 @@
|
||||
#XTIT
|
||||
appTitle=Genres
|
||||
#XTXT
|
||||
appDescription=Browse Genres
|
||||
155
fiori/app/genres/webapp/manifest.json
Normal file
155
fiori/app/genres/webapp/manifest.json
Normal file
@@ -0,0 +1,155 @@
|
||||
{
|
||||
"_version": "1.8.0",
|
||||
"sap.app": {
|
||||
"id": "genres",
|
||||
"type": "application",
|
||||
"i18n": "i18n/i18n.properties",
|
||||
"applicationVersion": {
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"title": "Browse Genres Hierarchy (OData v2)",
|
||||
"description": "{{appDescription}}",
|
||||
"tags": {
|
||||
"keywords": []
|
||||
},
|
||||
"crossNavigation": {
|
||||
"inbounds": {
|
||||
"appShow": {
|
||||
"title": "{{appTitle}}",
|
||||
"semanticObject": "GenreHierarchy",
|
||||
"action": "display",
|
||||
"deviceTypes": {
|
||||
"desktop": true,
|
||||
"tablet": true,
|
||||
"phone": true
|
||||
},
|
||||
"icon": "sap-icon://settings",
|
||||
"size": "1x1"
|
||||
}
|
||||
},
|
||||
"outbounds": {}
|
||||
},
|
||||
"ach": "",
|
||||
"resources": "resources.json",
|
||||
"dataSources": {
|
||||
"main": {
|
||||
"uri": "/v2/browse",
|
||||
"type": "OData",
|
||||
"settings": {
|
||||
"annotations": ["localAnnotations"],
|
||||
"localUri": "localService/metadata.xml"
|
||||
}
|
||||
},
|
||||
"localAnnotations": {
|
||||
"type": "ODataAnnotation",
|
||||
"uri": "annotations/localAnnotations.xml",
|
||||
"settings": {
|
||||
"localUri": "annotations/localAnnotations.xml"
|
||||
}
|
||||
}
|
||||
},
|
||||
"offline": false,
|
||||
"sourceTemplate": {
|
||||
"id": "ui5template.smartTemplate",
|
||||
"version": "1.40.12"
|
||||
}
|
||||
},
|
||||
"sap.ui": {
|
||||
"technology": "UI5",
|
||||
"icons": {
|
||||
"icon": "",
|
||||
"favIcon": "",
|
||||
"phone": "",
|
||||
"phone@2": "",
|
||||
"tablet": "",
|
||||
"tablet@2": ""
|
||||
},
|
||||
"deviceTypes": {
|
||||
"desktop": true,
|
||||
"tablet": true,
|
||||
"phone": true
|
||||
},
|
||||
"supportedThemes": ["sap_hcb", "sap_belize", "sap_belize_deep", "sap_fiori_3"]
|
||||
},
|
||||
"sap.ui5": {
|
||||
"resources": {
|
||||
"js": [],
|
||||
"css": []
|
||||
},
|
||||
"dependencies": {
|
||||
"minUI5Version": "1.65.6",
|
||||
"libs": {},
|
||||
"components": {}
|
||||
},
|
||||
"models": {
|
||||
"i18n": {
|
||||
"type": "sap.ui.model.resource.ResourceModel",
|
||||
"uri": "i18n/i18n.properties"
|
||||
},
|
||||
"@i18n": {
|
||||
"type": "sap.ui.model.resource.ResourceModel",
|
||||
"uri": "i18n/i18n.properties"
|
||||
},
|
||||
"json": {
|
||||
"type": "sap.ui.model.json.JSONModel"
|
||||
},
|
||||
"i18n|sap.suite.ui.generic.template.ListReport|Genres": {
|
||||
"type": "sap.ui.model.resource.ResourceModel",
|
||||
"uri": "i18n/ListReport/Genres/i18n.properties"
|
||||
},
|
||||
"": {
|
||||
"dataSource": "main",
|
||||
"preload": true,
|
||||
"settings": {
|
||||
"useBatch": true,
|
||||
"defaultBindingMode": "TwoWay",
|
||||
"defaultCountMode": "Inline",
|
||||
"refreshAfterChange": true,
|
||||
"metadataUrlParams": {
|
||||
"sap-value-list": "none"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"contentDensities": {
|
||||
"compact": true,
|
||||
"cozy": true
|
||||
}
|
||||
},
|
||||
"sap.ui.generic.app": {
|
||||
"_version": "1.3.0",
|
||||
"settings": {
|
||||
"forceGlobalRefresh": false,
|
||||
"useColumnLayoutForSmartForm": false,
|
||||
"showBasicSearch": false
|
||||
},
|
||||
"pages": {
|
||||
"ListReport|Genres": {
|
||||
"entitySet": "GenreHierarchy",
|
||||
"component": {
|
||||
"name": "sap.suite.ui.generic.template.ListReport",
|
||||
"list": true,
|
||||
"settings": {
|
||||
"condensedTableLayout": true,
|
||||
"smartVariantManagement": true,
|
||||
"tableType": "TreeTable",
|
||||
"enableTableFilterInPageVariant": true,
|
||||
"dataLoadSettings": {
|
||||
"loadDataOnAppLaunch": "always"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"sap.fiori": {
|
||||
"registrationIds": [],
|
||||
"archeType": "transactional"
|
||||
},
|
||||
"sap.platform.hcp": {
|
||||
"uri": ""
|
||||
},
|
||||
"sap.platform.cf": {
|
||||
"oAuthScopes": []
|
||||
}
|
||||
}
|
||||
@@ -5,5 +5,6 @@
|
||||
using from './admin-authors/fiori-service';
|
||||
using from './admin-books/fiori-service';
|
||||
using from './browse/fiori-service';
|
||||
using from './genres/fiori-service';
|
||||
using from './common';
|
||||
using from '@capire/bookstore/srv/mashup';
|
||||
|
||||
14
fiori/db/common.cds
Normal file
14
fiori/db/common.cds
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace sap.capire.bookshop;
|
||||
|
||||
using { sap.capire.bookshop } from '@capire/bookstore/srv/mashup';
|
||||
|
||||
entity GenreHierarchy : bookshop.Genres {
|
||||
hierarchyLevel : Integer default 0;
|
||||
drillState : String default 'leaf';
|
||||
parent : Association to GenreHierarchy;
|
||||
children : Composition of many GenreHierarchy on children.parent = $self;
|
||||
}
|
||||
|
||||
extend service CatalogService with {
|
||||
@readonly entity GenreHierarchy as projection on bookshop.GenreHierarchy;
|
||||
}
|
||||
16
fiori/db/data/sap.capire.bookshop-GenreHierarchy.csv
Normal file
16
fiori/db/data/sap.capire.bookshop-GenreHierarchy.csv
Normal file
@@ -0,0 +1,16 @@
|
||||
ID;parent_ID;name;hierarchyLevel;drillState
|
||||
10;;Fiction;0;expanded
|
||||
11;10;Drama;1;leaf
|
||||
12;10;Poetry;1;leaf
|
||||
13;10;Fantasy;1;leaf
|
||||
14;10;Science Fiction;1;leaf
|
||||
15;10;Romance;1;leaf
|
||||
16;10;Mystery;1;leaf
|
||||
17;10;Thriller;1;leaf
|
||||
18;10;Dystopia;1;leaf
|
||||
20;;Non-Fiction;0;expanded
|
||||
19;10;Fairy Tale;1;leaf
|
||||
21;20;Biography;1;expanded
|
||||
22;21;Autobiography;2;leaf
|
||||
23;20;Essay;1;leaf
|
||||
24;20;Speech;1;leaf
|
||||
|
@@ -3,9 +3,10 @@
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@capire/bookstore": "*",
|
||||
"@sap/cds": "^5",
|
||||
"@sap/cds": ">=5",
|
||||
"@sap/cds-odata-v2-adapter-proxy": "^1.9.0",
|
||||
"express": "^4.17.1",
|
||||
"passport": "^0.4.1"
|
||||
"passport": ">=0.4.1"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "cds run --in-memory?",
|
||||
@@ -14,7 +15,7 @@
|
||||
"cds": {
|
||||
"requires": {
|
||||
"auth": {
|
||||
"strategy": "dummy"
|
||||
"kind": "dummy-auth"
|
||||
},
|
||||
"ReviewsService": {
|
||||
"kind": "odata",
|
||||
@@ -51,4 +52,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1,8 @@
|
||||
module.exports = require('@capire/bookstore/server.js')
|
||||
const cds = require("@sap/cds")
|
||||
|
||||
// install OData v2 adapter
|
||||
const proxy = require('@sap/cds-odata-v2-adapter-proxy')
|
||||
const proxyOpts = global.it ? { target:'auto' } : {} // for tests, set 'auto' to detect port dynamically
|
||||
cds.on('bootstrap', app => app.use(proxy(proxyOpts)))
|
||||
|
||||
module.exports = require('@capire/bookstore/server.js')
|
||||
@@ -1,28 +0,0 @@
|
||||
{
|
||||
"build": {
|
||||
"target": "gen",
|
||||
"tasks": [{
|
||||
"for": "hana",
|
||||
"src": "db",
|
||||
"options": {
|
||||
"model": [
|
||||
"db",
|
||||
"srv",
|
||||
"app"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"for": "node-cf",
|
||||
"src": "srv",
|
||||
"options": {
|
||||
"model": [
|
||||
"db",
|
||||
"srv",
|
||||
"app"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
npm run build
|
||||
cf create-service-push
|
||||
cf bind-service gdpr-srv gdpr-pdm -c .pdm/pdm-binding-config.json
|
||||
cf restage gdpr-srv
|
||||
@@ -1,7 +0,0 @@
|
||||
cf delete gdpr-srv -f
|
||||
cf delete gdpr-db-deployer -f
|
||||
cf delete-service gdpr-pdm -f
|
||||
cf delete-service gdpr-auditlog -f
|
||||
cf delete-service gdpr-uaa -f
|
||||
cf delete-service gdpr-hdi -f
|
||||
cf delete-service gdpr-logs -f
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"fullyQualifiedApplicationName": "capire-gdpr",
|
||||
"fullyQualifiedModuleName": "gdpr-srv",
|
||||
"applicationTitle": "Capire GDPR Sample App",
|
||||
"applicationTitleKey": "Capire GDPR Sample App",
|
||||
"applicationURL": "https://capire-gdpr-srv.cfapps.eu10.hana.ondemand.com",
|
||||
"endPoints": [{
|
||||
"type": "odatav4",
|
||||
"serviceName": "PDMService",
|
||||
"serviceURI": "/pdm",
|
||||
"serviceTitle": "Capire GDPR Sample App PDM Service",
|
||||
"serviceTitleKey": "Capire GDPR Sample App PDM Service",
|
||||
"hasGdprV4Annotations": true,
|
||||
"cacheControl": "no-cache"
|
||||
}]
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"xs-security": {
|
||||
"xsappname": "capire-gdpr",
|
||||
"authorities": ["$ACCEPT_GRANTED_AUTHORITIES"]
|
||||
},
|
||||
"fullyQualifiedApplicationName": "capire-gdpr",
|
||||
"appConsentServiceEnabled": true
|
||||
}
|
||||
@@ -1,317 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Note: this is designed for the GDPRService being co-located with
|
||||
// orders. It does not work if GDPRService is run as a separate
|
||||
// process, and is not intended to do so.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
using {GDPRService} from '../srv/gdpr-service';
|
||||
|
||||
annotate cds.UUID with @Core.Computed;
|
||||
|
||||
/*
|
||||
* Orders
|
||||
*/
|
||||
@odata.draft.enabled
|
||||
annotate GDPRService.Orders with @(UI : {
|
||||
SelectionFields : [
|
||||
createdAt,
|
||||
createdBy
|
||||
],
|
||||
LineItem : [
|
||||
{
|
||||
Value : OrderNo,
|
||||
Label : 'Order number'
|
||||
},
|
||||
{
|
||||
Value : customer.firstName,
|
||||
Label : 'First Name'
|
||||
},
|
||||
{
|
||||
Value : customer.lastName,
|
||||
Label : 'Last Name'
|
||||
}
|
||||
],
|
||||
HeaderInfo : {
|
||||
TypeName : 'Order',
|
||||
TypeNamePlural : 'Orders',
|
||||
Title : {
|
||||
Value : OrderNo,
|
||||
Label : 'Order number'
|
||||
}
|
||||
},
|
||||
Identification : [
|
||||
{
|
||||
Value : createdBy,
|
||||
Label : 'Created by'
|
||||
},
|
||||
{
|
||||
Value : createdAt,
|
||||
Label : 'Created at'
|
||||
}
|
||||
],
|
||||
HeaderFacets : [
|
||||
{
|
||||
$Type : 'UI.ReferenceFacet',
|
||||
Label : '{i18n>Created}',
|
||||
Target : '@UI.FieldGroup#Created'
|
||||
},
|
||||
{
|
||||
$Type : 'UI.ReferenceFacet',
|
||||
Label : '{i18n>Modified}',
|
||||
Target : '@UI.FieldGroup#Modified'
|
||||
},
|
||||
],
|
||||
Facets : [
|
||||
{
|
||||
$Type : 'UI.ReferenceFacet',
|
||||
Label : '{i18n>Details}',
|
||||
Target : '@UI.FieldGroup#Details'
|
||||
},
|
||||
{
|
||||
$Type : 'UI.ReferenceFacet',
|
||||
Label : '{i18n>OrderItems}',
|
||||
Target : 'Items/@UI.LineItem'
|
||||
},
|
||||
],
|
||||
FieldGroup #Details : {Data : [
|
||||
{
|
||||
Value : customer_ID,
|
||||
Label : 'Customer'
|
||||
},
|
||||
{
|
||||
Value : customer.firstName,
|
||||
Label : 'First Name'
|
||||
},
|
||||
{
|
||||
Value : customer.lastName,
|
||||
Label : 'Last Name'
|
||||
},
|
||||
{
|
||||
Value : currency_code,
|
||||
Label : 'Currency'
|
||||
}
|
||||
]},
|
||||
FieldGroup #Created : {Data : [
|
||||
{
|
||||
Value : createdBy,
|
||||
Label : 'Created by'
|
||||
},
|
||||
{
|
||||
Value : createdAt,
|
||||
Label : 'Created at'
|
||||
}
|
||||
]},
|
||||
FieldGroup #Modified : {Data : [
|
||||
{
|
||||
Value : modifiedBy,
|
||||
Label : 'Modified by'
|
||||
},
|
||||
{
|
||||
Value : modifiedAt,
|
||||
Label : 'Modified at'
|
||||
}
|
||||
]},
|
||||
}, ) {
|
||||
createdAt @UI.HiddenFilter : false;
|
||||
createdBy @UI.HiddenFilter : false;
|
||||
customer @ValueList.entity : 'Customers';
|
||||
};
|
||||
|
||||
/*
|
||||
* TODO: Order Items are not really maintainable in Fiori preview app
|
||||
*/
|
||||
annotate GDPRService.Orders.Items with @(UI : {
|
||||
LineItem : [
|
||||
{
|
||||
Value : product_ID,
|
||||
Label : 'Product ID'
|
||||
},
|
||||
{
|
||||
Value : title,
|
||||
Label : 'Product Name'
|
||||
},
|
||||
{
|
||||
Value : price,
|
||||
Label : 'Price'
|
||||
},
|
||||
{
|
||||
Value : quantity,
|
||||
Label : 'Quantity'
|
||||
},
|
||||
],
|
||||
Identification : [
|
||||
{
|
||||
Value : product_ID,
|
||||
Label : 'Product ID'
|
||||
},
|
||||
{
|
||||
Value : title,
|
||||
Label : 'Product Name'
|
||||
},
|
||||
{
|
||||
Value : quantity,
|
||||
Label : 'Quantity'
|
||||
},
|
||||
{
|
||||
Value : price,
|
||||
Label : 'Price'
|
||||
},
|
||||
],
|
||||
Facets : [{
|
||||
$Type : 'UI.ReferenceFacet',
|
||||
Label : 'Order Items',
|
||||
Target : '@UI.Identification'
|
||||
}, ],
|
||||
}, ) {
|
||||
ID @Core.Computed @UI.Hidden : true;
|
||||
title @Core.Computed;
|
||||
price @Core.Computed;
|
||||
quantity @(Common.FieldControl : #Mandatory);
|
||||
};
|
||||
|
||||
/*
|
||||
* Customers
|
||||
*/
|
||||
@odata.draft.enabled
|
||||
annotate GDPRService.Customers with @(UI : {
|
||||
SelectionFields : [
|
||||
firstName,
|
||||
lastName
|
||||
],
|
||||
LineItem : [
|
||||
{
|
||||
Value : firstName,
|
||||
Label : 'First Name'
|
||||
},
|
||||
{
|
||||
Value : lastName,
|
||||
Label : 'Last Name'
|
||||
},
|
||||
{
|
||||
Value : dateOfBirth,
|
||||
Label : 'Date of Birth'
|
||||
}
|
||||
],
|
||||
HeaderInfo : {
|
||||
TypeName : 'Customer',
|
||||
TypeNamePlural : 'Customers',
|
||||
Title : {
|
||||
Value : lastName,
|
||||
Label : 'Last Name'
|
||||
},
|
||||
Description : {
|
||||
Value : firstName,
|
||||
Label : 'First Name'
|
||||
}
|
||||
},
|
||||
Identification : [
|
||||
{
|
||||
Value : createdBy,
|
||||
Label : 'Created by'
|
||||
},
|
||||
{
|
||||
Value : createdAt,
|
||||
Label : 'Created at'
|
||||
}
|
||||
],
|
||||
HeaderFacets : [
|
||||
{
|
||||
$Type : 'UI.ReferenceFacet',
|
||||
Label : '{i18n>Created}',
|
||||
Target : '@UI.FieldGroup#Created'
|
||||
},
|
||||
{
|
||||
$Type : 'UI.ReferenceFacet',
|
||||
Label : '{i18n>Modified}',
|
||||
Target : '@UI.FieldGroup#Modified'
|
||||
},
|
||||
],
|
||||
Facets : [
|
||||
{
|
||||
$Type : 'UI.ReferenceFacet',
|
||||
Label : '{i18n>Details}',
|
||||
Target : '@UI.FieldGroup#Details'
|
||||
},
|
||||
{
|
||||
$Type : 'UI.ReferenceFacet',
|
||||
Label : '{i18n>Addresses}',
|
||||
Target : 'addresses/@UI.LineItem'
|
||||
},
|
||||
],
|
||||
FieldGroup #Details : {Data : [
|
||||
{
|
||||
Value : dateOfBirth,
|
||||
Label : 'Date of Birth'
|
||||
},
|
||||
{
|
||||
Value : email,
|
||||
Label : 'E-Mail'
|
||||
},
|
||||
{
|
||||
Value : creditCardNo,
|
||||
Label : 'Credit Card Number'
|
||||
}
|
||||
]},
|
||||
FieldGroup #Created : {Data : [
|
||||
{
|
||||
Value : createdBy,
|
||||
Label : 'Created by'
|
||||
},
|
||||
{
|
||||
Value : createdAt,
|
||||
Label : 'Created at'
|
||||
}
|
||||
]},
|
||||
FieldGroup #Modified : {Data : [
|
||||
{
|
||||
Value : modifiedBy,
|
||||
Label : 'Modified by'
|
||||
},
|
||||
{
|
||||
Value : modifiedAt,
|
||||
Label : 'Modified at'
|
||||
}
|
||||
]},
|
||||
}, ) {
|
||||
createdAt @UI.HiddenFilter : false;
|
||||
createdBy @UI.HiddenFilter : false;
|
||||
};
|
||||
|
||||
annotate GDPRService.CustomerPostalAddresses with @(UI : {
|
||||
LineItem : [
|
||||
{
|
||||
Value : town,
|
||||
Label : 'Town'
|
||||
},
|
||||
{
|
||||
Value : street,
|
||||
Label : 'Street'
|
||||
},
|
||||
{
|
||||
Value : country.name,
|
||||
Label : 'Country'
|
||||
}
|
||||
],
|
||||
Identification : [
|
||||
{
|
||||
Value : town,
|
||||
Label : 'Town'
|
||||
},
|
||||
{
|
||||
Value : street,
|
||||
Label : 'Street'
|
||||
},
|
||||
{
|
||||
Value : country_code,
|
||||
Label : 'Country Code'
|
||||
}
|
||||
],
|
||||
Facets : [{
|
||||
$Type : 'UI.ReferenceFacet',
|
||||
Label : 'Customer Postal Address',
|
||||
Target : '@UI.Identification'
|
||||
}, ],
|
||||
}, );
|
||||
@@ -1,56 +0,0 @@
|
||||
using {sap.capire.orders} from '@capire/orders';
|
||||
using {sap.capire.gdpr} from './schema';
|
||||
|
||||
/*
|
||||
* annotations for Data Privacy (Personal Data Manager and Audit Logging)
|
||||
*/
|
||||
annotate gdpr.Customers with @PersonalData : {
|
||||
DataSubjectRole : 'Customer',
|
||||
EntitySemantics : 'DataSubject'
|
||||
}{
|
||||
ID @PersonalData.FieldSemantics : 'DataSubjectID';
|
||||
email @PersonalData.IsPotentiallyPersonal;
|
||||
firstName @PersonalData.IsPotentiallyPersonal;
|
||||
lastName @PersonalData.IsPotentiallyPersonal;
|
||||
creditCardNo @PersonalData.IsPotentiallySensitive;
|
||||
dateOfBirth @PersonalData.IsPotentiallyPersonal;
|
||||
}
|
||||
|
||||
annotate gdpr.CustomerPostalAddresses with @PersonalData : {
|
||||
DataSubjectRole : 'Customer',
|
||||
EntitySemantics : 'DataSubjectDetails'
|
||||
}{
|
||||
customer @PersonalData.FieldSemantics : 'DataSubjectID';
|
||||
street @PersonalData.IsPotentiallyPersonal;
|
||||
town @PersonalData.IsPotentiallyPersonal;
|
||||
country @PersonalData.IsPotentiallyPersonal;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: Personal Data Manager doesn't know EntitySemantics: 'Other' and FieldSemantics: 'ContractRelatedID'
|
||||
* see: https://help.sap.com/viewer/620a3ea6aaf64610accdd05cca9e3de2/Cloud/en-US/5a55fae1eb7c496c92c56071186d76b3.html
|
||||
*/
|
||||
annotate orders.Orders with @PersonalData : {
|
||||
DataSubjectRole : 'Customer',
|
||||
EntitySemantics : 'LegalGround'
|
||||
}{
|
||||
ID @PersonalData.FieldSemantics : 'LegalGroundID';
|
||||
customer @PersonalData.FieldSemantics : 'DataSubjectID';
|
||||
}
|
||||
|
||||
/*
|
||||
* additional annotations for Audit Logging
|
||||
*/
|
||||
annotate gdpr.Customers with @AuditLog.Operation : {
|
||||
Read : true,
|
||||
Insert : true,
|
||||
Update : true,
|
||||
Delete : true
|
||||
};
|
||||
|
||||
annotate gdpr.CustomerPostalAddresses with @AuditLog.Operation : {
|
||||
Read : true,
|
||||
Insert : true,
|
||||
Update : true,
|
||||
Delete : true
|
||||
};
|
||||
@@ -1,3 +0,0 @@
|
||||
ID;modifiedAt;createdAt;createdBy;modifiedBy;customer_ID;street;town;country_code
|
||||
1e2f2640-6866-4dcf-8f4d-3027aa831cad;2019-04-04;2019-01-31;admin@business.com;admin@business.com;8e2f2640-6866-4dcf-8f4d-3027aa831cad;Hauptstrasse 11;Berlin;DE
|
||||
24e718c9-ff99-47f1-8ca3-950c850777d4;2019-04-04;2019-01-30;admin@business.com;admin@business.com;74e718c9-ff99-47f1-8ca3-950c850777d4;Main Street 22;London;GB
|
||||
|
@@ -1,3 +0,0 @@
|
||||
ID;modifiedAt;createdAt;createdBy;modifiedBy;email;firstName;lastName;creditCardNo;dateOfBirth
|
||||
8e2f2640-6866-4dcf-8f4d-3027aa831cad;2019-04-04;2019-01-31;admin@business.com;admin@business.com;john.doe@test.com;John;Doe;9977-6655-4433-2211;1970-01-01
|
||||
74e718c9-ff99-47f1-8ca3-950c850777d4;2019-04-04;2019-01-30;admin@business.com;admin@business.com;jane.doe@sap.com;Jane;Doe;2211-3344-5566-7788;1980-11-11
|
||||
|
@@ -1,4 +0,0 @@
|
||||
ID;up__ID;quantity;product_ID;title;price
|
||||
4bd2c9df-c19f-47b8-a921-3cde0d863b52;29f15ef6-4a13-47d4-aef4-329a403b49eb;1;201;Wuthering Heights;11.11
|
||||
6c42a40d-5f7c-4c2f-816b-a73c7c28d722;29f15ef6-4a13-47d4-aef4-329a403b49eb;1;271;Catweazle;15
|
||||
748555fc-2cb0-42b5-a361-dd19a50bd682;31c2bd15-5146-4418-b574-866a08911de7;2;252;Eleonora;28
|
||||
|
@@ -1,3 +0,0 @@
|
||||
ID;createdAt;createdBy;customer_ID;OrderNo;currency_code
|
||||
29f15ef6-4a13-47d4-aef4-329a403b49eb;2019-01-31;john.doe@test.com;8e2f2640-6866-4dcf-8f4d-3027aa831cad;1;EUR
|
||||
31c2bd15-5146-4418-b574-866a08911de7;2019-01-30;jane.doe@test.com;74e718c9-ff99-47f1-8ca3-950c850777d4;2;EUR
|
||||
|
@@ -1,30 +0,0 @@
|
||||
using {
|
||||
Country,
|
||||
managed,
|
||||
cuid
|
||||
} from '@sap/cds/common';
|
||||
using {sap.capire.orders} from '@capire/orders';
|
||||
|
||||
namespace sap.capire.gdpr;
|
||||
|
||||
extend orders.Orders with {
|
||||
customer : Association to Customers;
|
||||
}
|
||||
|
||||
entity Customers : cuid, managed {
|
||||
email : String;
|
||||
firstName : String;
|
||||
lastName : String;
|
||||
creditCardNo : String;
|
||||
dateOfBirth : Date;
|
||||
addresses : Composition of many CustomerPostalAddresses
|
||||
on addresses.customer = $self;
|
||||
}
|
||||
|
||||
entity CustomerPostalAddresses : cuid, managed {
|
||||
customer : Association to Customers;
|
||||
street : String(128);
|
||||
town : String(128);
|
||||
@assert.integrity : false
|
||||
country : Country;
|
||||
};
|
||||
@@ -1,136 +0,0 @@
|
||||
{
|
||||
"file_suffixes": {
|
||||
"csv": {
|
||||
"plugin_name": "com.sap.hana.di.tabledata.source"
|
||||
},
|
||||
"hdbafllangprocedure": {
|
||||
"plugin_name": "com.sap.hana.di.afllangprocedure"
|
||||
},
|
||||
"hdbanalyticprivilege": {
|
||||
"plugin_name": "com.sap.hana.di.analyticprivilege"
|
||||
},
|
||||
"hdbcalculationview": {
|
||||
"plugin_name": "com.sap.hana.di.calculationview"
|
||||
},
|
||||
"hdbcollection": {
|
||||
"plugin_name": "com.sap.hana.di.collection"
|
||||
},
|
||||
"hdbconstraint": {
|
||||
"plugin_name": "com.sap.hana.di.constraint"
|
||||
},
|
||||
"hdbdropcreatetable": {
|
||||
"plugin_name": "com.sap.hana.di.dropcreatetable"
|
||||
},
|
||||
"hdbflowgraph": {
|
||||
"plugin_name": "com.sap.hana.di.flowgraph"
|
||||
},
|
||||
"hdbfunction": {
|
||||
"plugin_name": "com.sap.hana.di.function"
|
||||
},
|
||||
"hdbgraphworkspace": {
|
||||
"plugin_name": "com.sap.hana.di.graphworkspace"
|
||||
},
|
||||
"hdbhadoopmrjob": {
|
||||
"plugin_name": "com.sap.hana.di.virtualfunctionpackage.hadoop"
|
||||
},
|
||||
"hdbindex": {
|
||||
"plugin_name": "com.sap.hana.di.index"
|
||||
},
|
||||
"hdblibrary": {
|
||||
"plugin_name": "com.sap.hana.di.library"
|
||||
},
|
||||
"hdbmigrationtable": {
|
||||
"plugin_name": "com.sap.hana.di.table.migration"
|
||||
},
|
||||
"hdbprocedure": {
|
||||
"plugin_name": "com.sap.hana.di.procedure"
|
||||
},
|
||||
"hdbprojectionview": {
|
||||
"plugin_name": "com.sap.hana.di.projectionview"
|
||||
},
|
||||
"hdbprojectionviewconfig": {
|
||||
"plugin_name": "com.sap.hana.di.projectionview.config"
|
||||
},
|
||||
"hdbreptask": {
|
||||
"plugin_name": "com.sap.hana.di.reptask"
|
||||
},
|
||||
"hdbresultcache": {
|
||||
"plugin_name": "com.sap.hana.di.resultcache"
|
||||
},
|
||||
"hdbrole": {
|
||||
"plugin_name": "com.sap.hana.di.role"
|
||||
},
|
||||
"hdbroleconfig": {
|
||||
"plugin_name": "com.sap.hana.di.role.config"
|
||||
},
|
||||
"hdbsearchruleset": {
|
||||
"plugin_name": "com.sap.hana.di.searchruleset"
|
||||
},
|
||||
"hdbsequence": {
|
||||
"plugin_name": "com.sap.hana.di.sequence"
|
||||
},
|
||||
"hdbstatistics": {
|
||||
"plugin_name": "com.sap.hana.di.statistics"
|
||||
},
|
||||
"hdbstructuredprivilege": {
|
||||
"plugin_name": "com.sap.hana.di.structuredprivilege"
|
||||
},
|
||||
"hdbsynonym": {
|
||||
"plugin_name": "com.sap.hana.di.synonym"
|
||||
},
|
||||
"hdbsynonymconfig": {
|
||||
"plugin_name": "com.sap.hana.di.synonym.config"
|
||||
},
|
||||
"hdbsystemversioning": {
|
||||
"plugin_name": "com.sap.hana.di.systemversioning"
|
||||
},
|
||||
"hdbtable": {
|
||||
"plugin_name": "com.sap.hana.di.table"
|
||||
},
|
||||
"hdbtabledata": {
|
||||
"plugin_name": "com.sap.hana.di.tabledata"
|
||||
},
|
||||
"hdbtabletype": {
|
||||
"plugin_name": "com.sap.hana.di.tabletype"
|
||||
},
|
||||
"hdbtrigger": {
|
||||
"plugin_name": "com.sap.hana.di.trigger"
|
||||
},
|
||||
"hdbview": {
|
||||
"plugin_name": "com.sap.hana.di.view"
|
||||
},
|
||||
"hdbvirtualfunction": {
|
||||
"plugin_name": "com.sap.hana.di.virtualfunction"
|
||||
},
|
||||
"hdbvirtualfunctionconfig": {
|
||||
"plugin_name": "com.sap.hana.di.virtualfunction.config"
|
||||
},
|
||||
"hdbvirtualpackagehadoop": {
|
||||
"plugin_name": "com.sap.hana.di.virtualpackage.hadoop"
|
||||
},
|
||||
"hdbvirtualpackagesparksql": {
|
||||
"plugin_name": "com.sap.hana.di.virtualpackage.sparksql"
|
||||
},
|
||||
"hdbvirtualprocedure": {
|
||||
"plugin_name": "com.sap.hana.di.virtualprocedure"
|
||||
},
|
||||
"hdbvirtualprocedureconfig": {
|
||||
"plugin_name": "com.sap.hana.di.virtualprocedure.config"
|
||||
},
|
||||
"hdbvirtualtable": {
|
||||
"plugin_name": "com.sap.hana.di.virtualtable"
|
||||
},
|
||||
"hdbvirtualtableconfig": {
|
||||
"plugin_name": "com.sap.hana.di.virtualtable.config"
|
||||
},
|
||||
"properties": {
|
||||
"plugin_name": "com.sap.hana.di.tabledata.properties"
|
||||
},
|
||||
"tags": {
|
||||
"plugin_name": "com.sap.hana.di.tabledata.properties"
|
||||
},
|
||||
"txt": {
|
||||
"plugin_name": "com.sap.hana.di.copyonly"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
---
|
||||
applications:
|
||||
# -----------------------------------------------------------------------------------
|
||||
# HANA Database Content Deployer App
|
||||
# -----------------------------------------------------------------------------------
|
||||
- name: gdpr-db-deployer
|
||||
path: gen/db
|
||||
no-route: true
|
||||
health-check-type: process
|
||||
memory: 256M
|
||||
buildpack: nodejs_buildpack
|
||||
services:
|
||||
- gdpr-logs
|
||||
- gdpr-hdi
|
||||
# -----------------------------------------------------------------------------------
|
||||
# Backend Service
|
||||
# -----------------------------------------------------------------------------------
|
||||
- name: gdpr-srv
|
||||
path: gen/srv
|
||||
memory: 256M
|
||||
buildpack: nodejs_buildpack
|
||||
routes:
|
||||
- route: capire-gdpr-srv.cfapps.eu10.hana.ondemand.com
|
||||
services:
|
||||
- gdpr-logs
|
||||
- gdpr-hdi
|
||||
- gdpr-uaa
|
||||
- gdpr-auditlog
|
||||
# binding with parameters not yet supported -> binding done manually in .etc/deploy.sh
|
||||
#- name: gdpr-pdm
|
||||
# parameters: ./pdm-binding-config.json
|
||||
@@ -1,49 +0,0 @@
|
||||
{
|
||||
"name": "@capire/gdpr",
|
||||
"version": "0.0.1",
|
||||
"dependencies": {
|
||||
"@capire/orders": "../orders",
|
||||
"@sap/audit-logging": "^5.1.0",
|
||||
"@sap/cds": "^5.9",
|
||||
"express": "^4.17.1",
|
||||
"hdb": "^0.19.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rm -rf gen && cds build --production",
|
||||
"deploy": "sh .etc/deploy.sh",
|
||||
"undeploy": "sh .etc/undeploy.sh",
|
||||
"start": "cds run"
|
||||
},
|
||||
"cds": {
|
||||
"requires": {
|
||||
"auth": {
|
||||
"__comment__": "workaround to avoid approuter et al. setup",
|
||||
"impl": "srv/auth.js"
|
||||
},
|
||||
"audit-log": {
|
||||
"[development]": {
|
||||
"kind": "audit-log-to-console"
|
||||
},
|
||||
"[production]": {
|
||||
"kind": "audit-log-service"
|
||||
}
|
||||
},
|
||||
"db": {
|
||||
"kind": "sql"
|
||||
},
|
||||
"uaa": {
|
||||
"kind": "xsuaa"
|
||||
}
|
||||
},
|
||||
"features": {
|
||||
"audit_personal_data": true,
|
||||
"fiori_preview": true,
|
||||
"[production]": {
|
||||
"kibana_formatter": true
|
||||
}
|
||||
},
|
||||
"hana": {
|
||||
"deploy-format": "hdbtable"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
# how-to
|
||||
|
||||
## required services and subscriptions
|
||||
|
||||
services:
|
||||
- Audit Log Service
|
||||
- SAP HANA Cloud
|
||||
- SAP HANA Schemas & HDI Containers
|
||||
- Application Logging Service
|
||||
- Personal Data Manager
|
||||
- Authorization and Trust Management Service
|
||||
|
||||
subscriptions:
|
||||
- Audit Log Viewer Service
|
||||
- Personal Data Manager
|
||||
|
||||
## deploy
|
||||
|
||||
after adding the necessary entitlements, do:
|
||||
- `cf l` to log into the respective account
|
||||
- `cd gdpr` (if still in root of `cloud-cap-samples`)
|
||||
- `npm run deploy`, which executes build and deployment via `.etc/deploy.sh`
|
||||
|
||||
## authorization
|
||||
|
||||
create roles for Audit Log Viewer Service and Personal Data Manager, and assign the roles to the respective users
|
||||
|
||||
# open issues
|
||||
|
||||
- deploy via mta, which can bind with parameters, and get rid of scripts in `.etc`
|
||||
- use approuter to remove hacky custom auth impl (`srv/auth.js`)
|
||||
- clarify annotation `EntitySemantics`, which differs between audit logging (`Other`) and personal data manager (`LegalGround`)
|
||||
- annotations for order items Fiori preview app
|
||||
+ `Products` has `@cds.persistence.skip:'always'`
|
||||
- how to reuse intial data from `common`?
|
||||
@@ -1,20 +0,0 @@
|
||||
---
|
||||
create-services:
|
||||
- name: gdpr-logs # > for kibana
|
||||
broker: application-logs
|
||||
plan: standard
|
||||
- name: gdpr-hdi # > hana
|
||||
broker: hana
|
||||
plan: hdi-shared
|
||||
- name: gdpr-auditlog # > audit log sink
|
||||
broker: auditlog
|
||||
plan: standard
|
||||
# gdpr-pdm needs to exist before creating gdpr-uaa for authorization grant
|
||||
- name: gdpr-pdm # > personal data manager
|
||||
broker: personal-data-manager-service
|
||||
plan: standard
|
||||
parameters: ./.pdm/pdm-instance-config.json
|
||||
- name: gdpr-uaa # > uaa for authentication
|
||||
broker: xsuaa
|
||||
plan: application
|
||||
parameters: xs-security.json
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* workaround to avoid approuter et al. setup
|
||||
*/
|
||||
|
||||
const jwt = require('jsonwebtoken')
|
||||
const tenant = process.env.VCAP_SERVICES
|
||||
? JSON.parse(process.env.VCAP_SERVICES).xsuaa[0].credentials.tenantid
|
||||
: 'anonymous'
|
||||
|
||||
module.exports = (req, res, next) => {
|
||||
/*
|
||||
* decode JWT coming from Personal Data Manager
|
||||
*
|
||||
* DO NOT USE FOR PRODUCTION!
|
||||
* - no token validation
|
||||
* - no xsappname check
|
||||
*/
|
||||
const bearer = req.headers.authorization && req.headers.authorization.split('Bearer ')[1]
|
||||
if (bearer) {
|
||||
const { client_id: id, zid: tenant, scope: roles } = jwt.decode(bearer)
|
||||
req.user = {
|
||||
id,
|
||||
tenant,
|
||||
is: role => roles.some(r => r.endsWith(`.${role}`))
|
||||
}
|
||||
return next()
|
||||
}
|
||||
|
||||
// mock user that has every role EXCEPT PersonalDataManagerUser
|
||||
const basic = req.headers.authorization && req.headers.authorization.split('Basic ')[1]
|
||||
if (basic) {
|
||||
const [id] = Buffer.from(basic, 'base64').toString('utf-8').split(':')
|
||||
req.user = {
|
||||
id,
|
||||
tenant,
|
||||
is: role => role !== 'PersonalDataManagerUser'
|
||||
}
|
||||
return next()
|
||||
}
|
||||
|
||||
// no bearer & no basic -> 401
|
||||
res.set('WWW-Authenticate', 'Basic realm="Users"').status(401).end()
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using {
|
||||
sap.capire.orders,
|
||||
sap.capire.gdpr
|
||||
} from '../db/schema';
|
||||
|
||||
@requires : 'admin' // > authorization check
|
||||
service GDPRService {
|
||||
entity Customers as projection on gdpr.Customers;
|
||||
entity Orders as projection on orders.Orders;
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using {
|
||||
sap.capire.gdpr as gdpr,
|
||||
sap.capire.orders as orders
|
||||
} from '../db/data-privacy';
|
||||
|
||||
@requires : 'PersonalDataManagerUser' // > authorization check
|
||||
service PDMService {
|
||||
|
||||
entity Customers as projection on gdpr.Customers;
|
||||
entity CustomerPostalAddresses as projection on gdpr.CustomerPostalAddresses;
|
||||
entity Orders as projection on orders.Orders;
|
||||
|
||||
/*
|
||||
* additional annotations for Personal Data Manager's Search Fields
|
||||
*/
|
||||
annotate Customers with @(Communication.Contact : {
|
||||
n : {
|
||||
surname : lastName,
|
||||
given : firstName
|
||||
},
|
||||
bday : dateOfBirth
|
||||
});
|
||||
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user