Compare commits

..

2 Commits

Author SHA1 Message Date
Christian Georgi
1f8a78fe8a Update 2022-03-23 23:25:04 +01:00
Christian Georgi
7f9474244b Deploy test 2022-03-23 16:58:52 +01:00
136 changed files with 12113 additions and 5164 deletions

View File

@@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
node-version: [16.x, 14.x]
node-version: [16.x, 14.x, 12.x]
steps:
- uses: actions/checkout@v2
@@ -24,6 +24,5 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm i -g npm@8
- run: npm ci
- run: npm test

1
.gitignore vendored
View File

@@ -12,7 +12,6 @@ target/
*.mtar
connection.properties
default-env.json
.cdsrc-private.json
packages/messageBox
reviews/msg-box
reviews/db/test.db

View File

@@ -16,8 +16,7 @@ app.use('/-/:tarball', (req,res,next) => {
console.debug ('GET', req.params)
try {
const { tarball } = req.params
const pkgFull = tarball.substring(0, tarball.lastIndexOf('-'))
const [, pkg ] = /^\w+-(.+)/.exec(pkgFull)
const [, pkg ] = /^\w+-(\w+)/.exec(tarball)
fs.lstat(tarball,(err => {
if (err) console.debug (`npm pack ../${pkg}`)
if (err) exec(`npm pack ../${pkg}`,{cwd},next)
@@ -32,7 +31,7 @@ app.use('/-/:tarball', (req,res,next) => {
app.use('/-', express.static(__dirname))
app.get('/*', (req,res)=>{
const urlRegex = /^\/(@[\w-]+)\/(.+)/
const urlRegex = /^\/(@\w+)\/(\w+)/
const url = decodeURIComponent(req.url)
console.debug ('GET',url)
try {

View File

@@ -104,7 +104,7 @@
},
{
"file": "fiori/app/services.cds",
"description": "### Annotations for SAP Fiori Elements\n\nAdds an SAP Fiori elements application to bookstore, thereby introducing:\n- OData Annotations in `.cds` files\n- Support for Fiori Draft\n- Support for Value Helps\n- Serving SAP Fiori apps locally\n\nSee the [Serving Fiori UIs](https://cap.cloud.sap/docs/advanced/fiori) documentation for more information.",
"description": "### Annotations for SAP Fiori Elements\n\n- [Adds an SAP Fiori elements application](https://cap.cloud.sap/docs/guides/fiori/) to bookstore, thereby introducing to:\n- [OData Annotations](https://cap.cloud.sap/docs/guides/fiori#adding-odata-annotations) in `.cds` files\n- Support for [Fiori Draft](https://cap.cloud.sap/docs/guides/fiori#draft)\n- Support for [Value Helps](https://cap.cloud.sap/docs/guides/fiori#value-help)\n- Serving SAP Fiori apps locally\n",
"line": 1,
"selection": {
"start": {
@@ -136,4 +136,4 @@
],
"isPrimary": true,
"description": "Overview of CAP Samples for Node.js"
}
}

View File

@@ -1,73 +0,0 @@
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.

View File

@@ -7,14 +7,13 @@ Find here a collection of samples for the [SAP Cloud Application Programming Mod
### Preliminaries
1. Ensure you have the latest LTS version of Node.js installed (see [Getting Started](https://cap.cloud.sap/docs/get-started/))
2. Install [**@sap/cds-dk**](https://cap.cloud.sap/docs/get-started/) globally:
1. Install [**@sap/cds-dk**](https://cap.cloud.sap/docs/get-started/) globally:
```sh
npm i -g @sap/cds-dk
```
3. _Optional:_ [Use Visual Studio Code](https://cap.cloud.sap/docs/get-started/tools#vscode)
2. _Optional:_ [Use Visual Studio Code](https://cap.cloud.sap/docs/get-started/tools#vscode)
### Download

View File

@@ -1,3 +0,0 @@
// This is an automatically generated file. Please do not change its contents manually!
const cds = require('@sap/cds')
const cson = cds.entities('_')

View File

@@ -1,35 +0,0 @@
// 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
}

View File

@@ -1,3 +0,0 @@
// This is an automatically generated file. Please do not change its contents manually!
const cds = require('@sap/cds')
const cson = cds.entities('')

View File

@@ -1,57 +0,0 @@
// 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>

View File

@@ -1,9 +0,0 @@
// 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

View File

@@ -1,66 +0,0 @@
// 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> {
}

View File

@@ -1,9 +0,0 @@
// 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

View File

@@ -1,68 +0,0 @@
// 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> {
}

3752
bookshop/app/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

12
bookshop/app/package.json Normal file
View File

@@ -0,0 +1,12 @@
{
"name": "approuter",
"dependencies": {
"@sap/approuter": "^10"
},
"engines": {
"node": "^16"
},
"scripts": {
"start": "node node_modules/@sap/approuter/approuter.js"
}
}

View File

@@ -10,7 +10,7 @@ const books = Vue.createApp ({
list: [],
book: undefined,
order: { quantity:1, succeeded:'', failed:'' },
user: undefined
user: {}
}
},
@@ -40,28 +40,19 @@ const books = Vue.createApp ({
} catch (e) {
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")
books.getUserInfo()
books.fetch() // initially fill list of books
// initially fill list of books
books.fetch()
document.addEventListener('keydown', (event) => {
// hide user info on request
if (event.key === 'u') books.user = undefined
// show user info on request
document.addEventListener('keydown', async (event) => {
if (event.key === 'u') {
try {
books.user = (await axios.get('/user/User')).data
} catch (err) { }
}
})

View File

@@ -18,17 +18,11 @@
<body class="small-container", style="margin-top: 70px;">
<div id='app'>
<form class="user" @submit.prevent="login">
<div v-if="user">
<div v-if="user.tenant">Tenant: {{ user.tenant }}</div>
<div> User: {{ user.id }}</div>
<div>Locale: {{ user.locale }}</div>
</div>
<div v-else>
<input type="submit" value="Login" class="muted-button">
<!-- <a href="/user/login()">Login</a> -->
</div>
</form>
<div v-if="user.ID && user.ID !== 'anonymous'" class="user">
<div>User: {{ user.ID }}</div>
<div>Locale: {{ user.locale }}</div>
<div>Tenant: {{ user.tenant }}</div>
</div>
<h1> Capire Books </h1>

19
bookshop/app/xs-app.json Normal file
View File

@@ -0,0 +1,19 @@
{
"authenticationMethod": "route",
"routes": [
{
"source": "^/app/(.*)$",
"target": "$1",
"localDir": ".",
"authenticationType": "xsuaa",
"cacheControl": "no-cache, no-store, must-revalidate"
},
{
"source": "^/(.*)$",
"target": "$1",
"destination": "srv-api",
"authenticationType": "xsuaa",
"csrfProtection": false
}
]
}

136
bookshop/db/src/.hdiconfig Normal file
View File

@@ -0,0 +1,136 @@
{
"file_suffixes": {
"csv": {
"plugin_name": "com.sap.hana.di.tabledata.source"
},
"hdbafllangprocedure": {
"plugin_name": "com.sap.hana.di.afllangprocedure"
},
"hdbanalyticprivilege": {
"plugin_name": "com.sap.hana.di.analyticprivilege"
},
"hdbcalculationview": {
"plugin_name": "com.sap.hana.di.calculationview"
},
"hdbcollection": {
"plugin_name": "com.sap.hana.di.collection"
},
"hdbconstraint": {
"plugin_name": "com.sap.hana.di.constraint"
},
"hdbdropcreatetable": {
"plugin_name": "com.sap.hana.di.dropcreatetable"
},
"hdbflowgraph": {
"plugin_name": "com.sap.hana.di.flowgraph"
},
"hdbfunction": {
"plugin_name": "com.sap.hana.di.function"
},
"hdbgraphworkspace": {
"plugin_name": "com.sap.hana.di.graphworkspace"
},
"hdbhadoopmrjob": {
"plugin_name": "com.sap.hana.di.virtualfunctionpackage.hadoop"
},
"hdbindex": {
"plugin_name": "com.sap.hana.di.index"
},
"hdblibrary": {
"plugin_name": "com.sap.hana.di.library"
},
"hdbmigrationtable": {
"plugin_name": "com.sap.hana.di.table.migration"
},
"hdbprocedure": {
"plugin_name": "com.sap.hana.di.procedure"
},
"hdbprojectionview": {
"plugin_name": "com.sap.hana.di.projectionview"
},
"hdbprojectionviewconfig": {
"plugin_name": "com.sap.hana.di.projectionview.config"
},
"hdbreptask": {
"plugin_name": "com.sap.hana.di.reptask"
},
"hdbresultcache": {
"plugin_name": "com.sap.hana.di.resultcache"
},
"hdbrole": {
"plugin_name": "com.sap.hana.di.role"
},
"hdbroleconfig": {
"plugin_name": "com.sap.hana.di.role.config"
},
"hdbsearchruleset": {
"plugin_name": "com.sap.hana.di.searchruleset"
},
"hdbsequence": {
"plugin_name": "com.sap.hana.di.sequence"
},
"hdbstatistics": {
"plugin_name": "com.sap.hana.di.statistics"
},
"hdbstructuredprivilege": {
"plugin_name": "com.sap.hana.di.structuredprivilege"
},
"hdbsynonym": {
"plugin_name": "com.sap.hana.di.synonym"
},
"hdbsynonymconfig": {
"plugin_name": "com.sap.hana.di.synonym.config"
},
"hdbsystemversioning": {
"plugin_name": "com.sap.hana.di.systemversioning"
},
"hdbtable": {
"plugin_name": "com.sap.hana.di.table"
},
"hdbtabledata": {
"plugin_name": "com.sap.hana.di.tabledata"
},
"hdbtabletype": {
"plugin_name": "com.sap.hana.di.tabletype"
},
"hdbtrigger": {
"plugin_name": "com.sap.hana.di.trigger"
},
"hdbview": {
"plugin_name": "com.sap.hana.di.view"
},
"hdbvirtualfunction": {
"plugin_name": "com.sap.hana.di.virtualfunction"
},
"hdbvirtualfunctionconfig": {
"plugin_name": "com.sap.hana.di.virtualfunction.config"
},
"hdbvirtualpackagehadoop": {
"plugin_name": "com.sap.hana.di.virtualpackage.hadoop"
},
"hdbvirtualpackagesparksql": {
"plugin_name": "com.sap.hana.di.virtualpackage.sparksql"
},
"hdbvirtualprocedure": {
"plugin_name": "com.sap.hana.di.virtualprocedure"
},
"hdbvirtualprocedureconfig": {
"plugin_name": "com.sap.hana.di.virtualprocedure.config"
},
"hdbvirtualtable": {
"plugin_name": "com.sap.hana.di.virtualtable"
},
"hdbvirtualtableconfig": {
"plugin_name": "com.sap.hana.di.virtualtable.config"
},
"properties": {
"plugin_name": "com.sap.hana.di.tabledata.properties"
},
"tags": {
"plugin_name": "com.sap.hana.di.tabledata.properties"
},
"txt": {
"plugin_name": "com.sap.hana.di.copyonly"
}
}
}

View File

@@ -0,0 +1,5 @@
[
"src/gen/**/*.hdbview",
"src/gen/**/*.hdbindex",
"src/gen/**/*.hdbconstraint"
]

View File

@@ -1,5 +0,0 @@
{
"compilerOptions": {
"checkJs": true
}
}

98
bookshop/mta.yaml Normal file
View File

@@ -0,0 +1,98 @@
---
_schema-version: '3.1'
ID: capire.bookshop
version: 1.0.0
description: "A simple self-contained bookshop service."
parameters:
enable-parallel-deployments: true
build-parameters:
before-all:
- builder: custom
commands:
- npx -p @sap/cds-dk cds build --production
modules:
- name: bookshop-srv
type: nodejs
path: gen/srv
parameters:
buildpack: nodejs_buildpack
build-parameters:
builder: npm-ci
provides:
- name: srv-api # required by consumers of CAP services (e.g. approuter)
properties:
srv-url: ${default-url}
- name: mtx-api # potentially required by approuter
properties:
mtx-url: ${default-url}
requires:
- name: bookshop-auth
- name: bookshop-db
- name: bookshop-registry
properties:
SUBSCRIPTION_URL: ${protocol}://\${tenant_subdomain}-${default-uri}
SUBSCRIPTION_URL_REPLACEMENT_RULES: [ [ '-srv', '' ] ]
- name: bookshop
type: approuter.nodejs
path: app/ # from cds.env.folders. Consider also cds.env.build.target -> gen/app
parameters:
keep-existing-routes: true
disk-quota: 256M
memory: 256M
requires:
- name: srv-api
group: destinations
properties:
name: srv-api # must be used in xs-app.json as well
url: ~{srv-url}
forwardAuthToken: true
- name: bookshop-auth
- name: mtx-api
group: destinations
properties:
name: mtx-api # must be used in xs-app.json as well
url: ~{mtx-url}
properties:
TENANT_HOST_PATTERN: "^(.*)-${default-uri}"
resources:
- name: bookshop-auth
type: org.cloudfoundry.managed-service
parameters:
service: xsuaa
service-plan: application
path: ./xs-security.json
config:
xsappname: bookshop-${org}-${space}
tenant-mode: shared
- name: bookshop-db
type: org.cloudfoundry.managed-service
parameters:
service: service-manager
service-plan: container
properties:
hdi-service-name: ${service-name}
- name: bookshop-registry
type: org.cloudfoundry.managed-service
requires:
- name: mtx-api
parameters:
service: saas-registry
service-plan: application
config:
xsappname: bookshop-${org}-${space}
appName: bookshop-${org}-${space}
displayName: bookshop
description: A simple CAP project.
category: 'Category'
appUrls:
getDependencies: ~{mtx-api/mtx-url}/mtx/v1/provisioning/dependencies
onSubscription: ~{mtx-api/mtx-url}/mtx/v1/provisioning/tenant/{tenantId}
onSubscriptionAsync: false
onUnSubscriptionAsync: false
callbackTimeoutMillis: 300000

4025
bookshop/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -10,9 +10,12 @@
"index.js"
],
"dependencies": {
"@sap/cds": ">=5.9",
"@sap/cds": "^5",
"@sap/cds-mtx": "^2",
"@sap/xssec": "^3",
"express": "^4.17.1",
"passport": ">=0.4.1"
"hdb": "^0.19.0",
"passport": "0.4.1"
},
"scripts": {
"genres": "cds serve test/genres.cds",
@@ -23,7 +26,24 @@
"requires": {
"db": {
"kind": "sql"
},
"[production]": {
"db": {
"kind": "hana-mt"
},
"auth": {
"kind": "xsuaa"
},
"multitenancy": true,
"approuter": {
"kind": "cloudfoundry"
}
}
},
"mtx": {
"element-prefix": "Z_",
"namespace-blocklist": [],
"extension-allowlist": []
}
}
}

View File

@@ -2,8 +2,7 @@ const cds = require('@sap/cds')
class CatalogService extends cds.ApplicationService { init(){
//const { Books } = this.entities ('sap.capire.bookshop')
const { Books, Book } = require('../@types/sap/capire/bookshop')
const { Books } = cds.entities ('sap.capire.bookshop')
// Reduce stock of ordered books if available stock suffices
this.on ('submitOrder', async req => {

View File

@@ -1,15 +1,11 @@
/**
* Exposes user information
*/
@requires : 'authenticated-user'
service UserService {
/**
* The current user
*/
@odata.singleton entity me {
id : String; // user id
@odata.singleton
entity User {
ID : String;
locale : String;
tenant : String;
}
action login() returns me;
}

View File

@@ -1,9 +1,11 @@
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')
})
}}
const cds = require('@sap/cds');
module.exports = cds.service.impl((srv) => {
srv.on('READ', 'User', ({ user }) => {
return {
ID: user.id,
locale: user.locale,
tenant: user.tenant,
};
});
});

View File

@@ -16,9 +16,9 @@ GET {{server}}/browse/$metadata
### ------------------------------------------------------------------------
# Browse Books as any user
GET {{server}}/browse/ListOfBooks?
GET {{server}}/browse/Books?
# &$select=title,stock
&$expand=genre
# &$expand=currency
# &sap-language=de
{{me}}

70
bookshop/xs-security.json Normal file
View File

@@ -0,0 +1,70 @@
{
"scopes": [
{
"name": "$XSAPPNAME.admin",
"description": "admin"
},
{
"name": "$XSAPPNAME.MtxDiagnose",
"description": "Diagnose MTX"
},
{
"name": "$XSAPPNAME.mtcallback",
"description": "Subscribe to applications",
"grant-as-authority-to-apps": [
"$XSAPPNAME(application,sap-provisioning,tenant-onboarding)"
]
},
{
"name": "$XSAPPNAME.mtdeployment",
"description": "Deploy applications"
},
{
"name": "$XSAPPNAME.ExtendCDS",
"description": "Extend CDS applications"
},
{
"name": "$XSAPPNAME.ExtendCDSdelete",
"description": "Extend CDS applications with undeployments"
}
],
"attributes": [],
"role-templates": [
{
"name": "admin",
"description": "generated",
"scope-references": [
"$XSAPPNAME.admin"
],
"attribute-references": []
},
{
"name": "MultitenancyAdministrator",
"description": "Administrate multitenant applications",
"scope-references": [
"$XSAPPNAME.MtxDiagnose",
"$XSAPPNAME.mtdeployment",
"$XSAPPNAME.mtcallback"
]
},
{
"name": "ExtensionDeveloper",
"description": "Extend application",
"scope-references": [
"$XSAPPNAME.ExtendCDS"
]
},
{
"name": "ExtensionDeveloperUndeploy",
"description": "Undeploy extension",
"scope-references": [
"$XSAPPNAME.ExtendCDSdelete"
]
}
],
"authorities": [
"$XSAPPNAME.MtxDiagnose",
"$XSAPPNAME.mtdeployment",
"$XSAPPNAME.mtcallback"
]
}

View File

@@ -1,7 +0,0 @@
// 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

View File

@@ -1,54 +0,0 @@
// 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> {
}

View File

@@ -1,7 +0,0 @@
// 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

View File

@@ -1,72 +0,0 @@
// 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) => {};

View File

@@ -1,7 +0,0 @@
// 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

View File

@@ -1,40 +0,0 @@
// 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> {
}

View File

@@ -1,5 +0,0 @@
// 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

View File

@@ -1,39 +0,0 @@
// 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> {
}

View File

@@ -1,5 +0,0 @@
// 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

View File

@@ -1,35 +0,0 @@
// 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) => {};

View File

@@ -1,3 +0,0 @@
// This is an automatically generated file. Please do not change its contents manually!
const cds = require('@sap/cds')
const cson = cds.entities('_')

View File

@@ -1,35 +0,0 @@
// 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
}

View File

@@ -1,3 +0,0 @@
// This is an automatically generated file. Please do not change its contents manually!
const cds = require('@sap/cds')
const cson = cds.entities('')

View File

@@ -1,57 +0,0 @@
// 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>

View File

@@ -1,9 +0,0 @@
// 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

View File

@@ -1,70 +0,0 @@
// 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> {
}

View File

@@ -1,7 +0,0 @@
// 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

View File

@@ -1,52 +0,0 @@
// 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> {
}

View File

@@ -1,7 +0,0 @@
// 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

View File

@@ -1,51 +0,0 @@
// 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> {
}

View File

@@ -1,9 +0,0 @@
// 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

View File

@@ -1,47 +0,0 @@
// 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> {
}

View File

@@ -1,9 +0,0 @@
// 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

View File

@@ -1,73 +0,0 @@
// 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> {
}

View File

@@ -1,5 +0,0 @@
{
"compilerOptions": {
"checkJs": true
}
}

View File

@@ -7,7 +7,7 @@
"@capire/orders": "*",
"@capire/common": "*",
"@capire/data-viewer": "*",
"@sap/cds": ">=5",
"@sap/cds": "^5",
"express": "^4.17.1"
},
"cds": {

View File

@@ -11,8 +11,7 @@ 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, Book } = require('../@types/sap/capire/bookshop')
const { Books } = db.entities ('sap.capire.bookshop')
//
// Delegate requests to read reviews to the ReviewsService
@@ -20,8 +19,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 } = 'SELECT' in req.query ? req.query.SELECT : {columns: [], limit: { rows: 0 }}
return ReviewsService.read ('Reviews',columns).limit(limit.rows).where({subject:String(id)})
const [id] = req.params, { columns, limit } = req.query.SELECT
return ReviewsService.read ('Reviews',columns).limit(limit).where({subject:String(id)})
}))
//
@@ -29,7 +28,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').where('ID = ' + book.ID).columns((/** @type {Book} */ b) => { b.title, b.price })
const { title, price } = await db.tx(msg).read (Books, 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 }],

View File

@@ -1,3 +0,0 @@
// This is an automatically generated file. Please do not change its contents manually!
const cds = require('@sap/cds')
const cson = cds.entities('_')

View File

@@ -1,35 +0,0 @@
// 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
}

View File

@@ -1,3 +0,0 @@
// This is an automatically generated file. Please do not change its contents manually!
const cds = require('@sap/cds')
const cson = cds.entities('')

View File

@@ -1,57 +0,0 @@
// 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>

View File

@@ -1,9 +0,0 @@
// 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

View File

@@ -1,47 +0,0 @@
// 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> {
}

View File

@@ -1,9 +0,0 @@
// 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

View File

@@ -1,73 +0,0 @@
// 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> {
}

View File

@@ -1,5 +0,0 @@
{
"compilerOptions": {
"checkJs": true
}
}

View File

@@ -1,7 +0,0 @@
// 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

View File

@@ -1,40 +0,0 @@
// 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> {
}

View File

@@ -1,3 +0,0 @@
// This is an automatically generated file. Please do not change its contents manually!
const cds = require('@sap/cds')
const cson = cds.entities('_')

View File

@@ -1,35 +0,0 @@
// 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
}

View File

@@ -1,5 +0,0 @@
{
"compilerOptions": {
"checkJs": true
}
}

View File

@@ -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",

View File

@@ -11,7 +11,7 @@
},
"dataSources": {
"AdminService": {
"uri": "admin/",
"uri": "/admin/",
"type": "OData",
"settings": {
"odataVersion": "4.0"

View File

@@ -8,7 +8,7 @@
"i18n": "i18n/i18n.properties",
"dataSources": {
"AdminService": {
"uri": "admin/",
"uri": "/admin/",
"type": "OData",
"settings": {
"odataVersion": "4.0"

View File

@@ -19,14 +19,6 @@
"title": "Browse Books",
"targetURL": "#Books-display"
}
},
{
"id": "BrowseGenres",
"tileType": "sap.ushell.ui.tile.StaticTile",
"properties": {
"title": "Browse Genres (OData v2)",
"targetURL": "#Genres-display"
}
}
]
},
@@ -115,24 +107,6 @@
"url": "/admin-authors/webapp"
}
},
"BrowseGenres": {
"semanticObject": "Genres",
"action": "display",
"title": "Browse Genres",
"signature": {
"parameters": {
"Genre.ID": {
"renameTo": "ID"
}
},
"additionalParameters": "ignored"
},
"resolutionResult": {
"applicationType": "SAPUI5",
"additionalInformation": "SAPUI5.Component=genres",
"url": "/genres/webapp"
}
},
"ManageBooks": {
"semanticObject": "Books",
"action": "manage",

View File

@@ -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"

View File

@@ -1,8 +0,0 @@
using { sap.capire.bookshop } from '../../db/common';
annotate bookshop.GenreHierarchy {
ID @sap.hierarchy.node.for;
parent @sap.hierarchy.parent.node.for;
hierarchyLevel @sap.hierarchy.level.for;
drillState @sap.hierarchy.drill.state.for;
}

View File

@@ -1,7 +0,0 @@
sap.ui.define(["sap/suite/ui/generic/template/lib/AppComponent"], (AppComponent) =>
AppComponent.extend("genres.Component", {
metadata: {
manifest: "json",
},
})
);

View File

@@ -1,4 +0,0 @@
#XTIT
appTitle=Genres
#XTXT
appDescription=Browse Genres

View File

@@ -1,155 +0,0 @@
{
"_version": "1.8.0",
"sap.app": {
"id": "genres",
"type": "application",
"i18n": "i18n/i18n.properties",
"applicationVersion": {
"version": "1.0.0"
},
"title": "Browse Genres Hierarchy (OData v2)",
"description": "{{appDescription}}",
"tags": {
"keywords": []
},
"crossNavigation": {
"inbounds": {
"appShow": {
"title": "{{appTitle}}",
"semanticObject": "GenreHierarchy",
"action": "display",
"deviceTypes": {
"desktop": true,
"tablet": true,
"phone": true
},
"icon": "sap-icon://settings",
"size": "1x1"
}
},
"outbounds": {}
},
"ach": "",
"resources": "resources.json",
"dataSources": {
"main": {
"uri": "/v2/browse",
"type": "OData",
"settings": {
"annotations": ["localAnnotations"],
"localUri": "localService/metadata.xml"
}
},
"localAnnotations": {
"type": "ODataAnnotation",
"uri": "annotations/localAnnotations.xml",
"settings": {
"localUri": "annotations/localAnnotations.xml"
}
}
},
"offline": false,
"sourceTemplate": {
"id": "ui5template.smartTemplate",
"version": "1.40.12"
}
},
"sap.ui": {
"technology": "UI5",
"icons": {
"icon": "",
"favIcon": "",
"phone": "",
"phone@2": "",
"tablet": "",
"tablet@2": ""
},
"deviceTypes": {
"desktop": true,
"tablet": true,
"phone": true
},
"supportedThemes": ["sap_hcb", "sap_belize", "sap_belize_deep", "sap_fiori_3"]
},
"sap.ui5": {
"resources": {
"js": [],
"css": []
},
"dependencies": {
"minUI5Version": "1.65.6",
"libs": {},
"components": {}
},
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"uri": "i18n/i18n.properties"
},
"@i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"uri": "i18n/i18n.properties"
},
"json": {
"type": "sap.ui.model.json.JSONModel"
},
"i18n|sap.suite.ui.generic.template.ListReport|Genres": {
"type": "sap.ui.model.resource.ResourceModel",
"uri": "i18n/ListReport/Genres/i18n.properties"
},
"": {
"dataSource": "main",
"preload": true,
"settings": {
"useBatch": true,
"defaultBindingMode": "TwoWay",
"defaultCountMode": "Inline",
"refreshAfterChange": true,
"metadataUrlParams": {
"sap-value-list": "none"
}
}
}
},
"contentDensities": {
"compact": true,
"cozy": true
}
},
"sap.ui.generic.app": {
"_version": "1.3.0",
"settings": {
"forceGlobalRefresh": false,
"useColumnLayoutForSmartForm": false,
"showBasicSearch": false
},
"pages": {
"ListReport|Genres": {
"entitySet": "GenreHierarchy",
"component": {
"name": "sap.suite.ui.generic.template.ListReport",
"list": true,
"settings": {
"condensedTableLayout": true,
"smartVariantManagement": true,
"tableType": "TreeTable",
"enableTableFilterInPageVariant": true,
"dataLoadSettings": {
"loadDataOnAppLaunch": "always"
}
}
}
}
}
},
"sap.fiori": {
"registrationIds": [],
"archeType": "transactional"
},
"sap.platform.hcp": {
"uri": ""
},
"sap.platform.cf": {
"oAuthScopes": []
}
}

View File

@@ -5,6 +5,5 @@
using from './admin-authors/fiori-service';
using from './admin-books/fiori-service';
using from './browse/fiori-service';
using from './genres/fiori-service';
using from './common';
using from '@capire/bookstore/srv/mashup';

View File

@@ -1,14 +0,0 @@
namespace sap.capire.bookshop;
using { sap.capire.bookshop } from '@capire/bookstore/srv/mashup';
entity GenreHierarchy : bookshop.Genres {
hierarchyLevel : Integer default 0;
drillState : String default 'leaf';
parent : Association to GenreHierarchy;
children : Composition of many GenreHierarchy on children.parent = $self;
}
extend service CatalogService with {
@readonly entity GenreHierarchy as projection on bookshop.GenreHierarchy;
}

View File

@@ -1,16 +0,0 @@
ID;parent_ID;name;hierarchyLevel;drillState
10;;Fiction;0;expanded
11;10;Drama;1;leaf
12;10;Poetry;1;leaf
13;10;Fantasy;1;leaf
14;10;Science Fiction;1;leaf
15;10;Romance;1;leaf
16;10;Mystery;1;leaf
17;10;Thriller;1;leaf
18;10;Dystopia;1;leaf
20;;Non-Fiction;0;expanded
19;10;Fairy Tale;1;leaf
21;20;Biography;1;expanded
22;21;Autobiography;2;leaf
23;20;Essay;1;leaf
24;20;Speech;1;leaf
1 ID parent_ID name hierarchyLevel drillState
2 10 Fiction 0 expanded
3 11 10 Drama 1 leaf
4 12 10 Poetry 1 leaf
5 13 10 Fantasy 1 leaf
6 14 10 Science Fiction 1 leaf
7 15 10 Romance 1 leaf
8 16 10 Mystery 1 leaf
9 17 10 Thriller 1 leaf
10 18 10 Dystopia 1 leaf
11 20 Non-Fiction 0 expanded
12 19 10 Fairy Tale 1 leaf
13 21 20 Biography 1 expanded
14 22 21 Autobiography 2 leaf
15 23 20 Essay 1 leaf
16 24 20 Speech 1 leaf

View File

@@ -3,10 +3,9 @@
"version": "1.0.0",
"dependencies": {
"@capire/bookstore": "*",
"@sap/cds": ">=5",
"@sap/cds-odata-v2-adapter-proxy": "^1.9.0",
"@sap/cds": "^5",
"express": "^4.17.1",
"passport": ">=0.4.1"
"passport": "^0.4.1"
},
"scripts": {
"start": "cds run --in-memory?",
@@ -15,7 +14,7 @@
"cds": {
"requires": {
"auth": {
"kind": "dummy-auth"
"strategy": "dummy"
},
"ReviewsService": {
"kind": "odata",
@@ -52,4 +51,4 @@
}
}
}
}
}

View File

@@ -1,8 +1 @@
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')
module.exports = require('@capire/bookstore/server.js')

View File

@@ -1,3 +0,0 @@
// This is an automatically generated file. Please do not change its contents manually!
const cds = require('@sap/cds')
const cson = cds.entities('_')

View File

@@ -1,35 +0,0 @@
// 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
}

View File

@@ -1,5 +0,0 @@
{
"compilerOptions": {
"checkJs": true
}
}

View File

@@ -7,11 +7,11 @@
"start:ts": "cds-ts serve srv/world.cds"
},
"dependencies": {
"@sap/cds": ">=5.0.4"
"@sap/cds": "^5.0.4"
},
"devDependencies": {
"@types/jest": "*",
"@types/node": "*",
"@types/jest": "^27.0.2",
"@types/node": "^16.11.6",
"ts-jest": "^27.0.2",
"typescript": "^4.3.5"
},

View File

@@ -1,3 +0,0 @@
// This is an automatically generated file. Please do not change its contents manually!
const cds = require('@sap/cds')
const cson = cds.entities('_')

View File

@@ -1,35 +0,0 @@
// 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
}

View File

@@ -1,5 +0,0 @@
// This is an automatically generated file. Please do not change its contents manually!
const cds = require('@sap/cds')
const cson = cds.entities('sap.capire.media.MediaServer')
module.exports.Media = cson.Media
module.exports.Media_ = cson.Media

View File

@@ -1,22 +0,0 @@
// This is an automatically generated file. Please do not change its contents manually!
import * as __ from './../../../../_';
export function Media<TBase extends new (...args: any[]) => {}>(Base: TBase) {
return class MediaAspect extends Base {
id: number;
content: string;
mediaType: string;
fileName: string;
applicationName: string;
};
}
const MediaXtended = Media(__.Entity)
export type Media = InstanceType<typeof MediaXtended>
export class Media_ extends Array<Media> {
}

View File

@@ -1,5 +0,0 @@
// This is an automatically generated file. Please do not change its contents manually!
const cds = require('@sap/cds')
const cson = cds.entities('sap.capire.media')
module.exports.Media = cson.Media
module.exports.Media_ = cson.Media

View File

@@ -1,22 +0,0 @@
// This is an automatically generated file. Please do not change its contents manually!
import * as __ from './../../../_';
export function Media<TBase extends new (...args: any[]) => {}>(Base: TBase) {
return class MediaAspect extends Base {
id: number;
content: string;
mediaType: string;
fileName: string;
applicationName: string;
};
}
const MediaXtended = Media(__.Entity)
export type Media = InstanceType<typeof MediaXtended>
export class Media_ extends Array<Media> {
}

View File

@@ -1,5 +0,0 @@
{
"compilerOptions": {
"checkJs": true
}
}

View File

@@ -1,5 +0,0 @@
// 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

View File

@@ -1,37 +0,0 @@
// 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 _ 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;
};
/**
* 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> {
}

View File

@@ -1,3 +0,0 @@
// This is an automatically generated file. Please do not change its contents manually!
const cds = require('@sap/cds')
const cson = cds.entities('_')

View File

@@ -1,35 +0,0 @@
// 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
}

Some files were not shown because too many files have changed in this diff Show More