Compare commits

..

2 Commits

Author SHA1 Message Date
Daniel O'Grady
3d41f8e4ec Slightly adjust JS files for samples to accomodate types 2022-09-15 16:03:24 +02:00
Daniel O'Grady
f891be5251 Add initial types for samples 2022-09-15 15:59:27 +02:00
119 changed files with 9068 additions and 741 deletions

View File

@@ -1,15 +1,15 @@
{
"extends": [
"eslint:recommended",
"plugin:@sap/cds/recommended"
],
"extends": "eslint:recommended",
"env": {
"browser": true,
"es2022": true,
"node": true,
"es6": true,
"jest": true,
"mocha": true
},
"parserOptions": {
"ecmaVersion": 2020
},
"globals": {
"SELECT": true,
"INSERT": true,

View File

@@ -26,5 +26,4 @@ jobs:
node-version: ${{ matrix.node-version }}
- run: npm i -g npm@8
- run: npm ci
- run: npm run test
- run: npm run test:mocha
- run: npm test

2
.gitignore vendored
View File

@@ -18,5 +18,3 @@ reviews/msg-box
reviews/db/test.db
*.openapi3.json
*.sqlite
*.db

12
.vscode/settings.json vendored
View File

@@ -14,13 +14,5 @@
"**/odata-v4/okra/**"
]
},
"mochaExplorer.parallel": true,
"eslint.validate": [
"cds",
"csn",
"csv",
"csv (semicolon)",
"tsv",
"tab"
]
}
"mochaExplorer.parallel": true
}

View 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('_')

View 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
View 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
View 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>

View 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

View 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> {
}

View 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

View 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> {
}

View File

@@ -56,7 +56,7 @@ const books = Vue.createApp ({
} catch (err) { books.user = { id: err.message } }
},
}
}).mount('#app')
}).mount("#app")
books.getUserInfo()
books.fetch() // initially fill list of books
@@ -65,25 +65,3 @@ document.addEventListener('keydown', (event) => {
// hide user info on request
if (event.key === 'u') books.user = undefined
})
axios.interceptors.request.use(csrfToken)
function csrfToken (request) {
if (request.method === 'head' || request.method === 'get') return request
if ('csrfToken' in document) {
request.headers['x-csrf-token'] = document.csrfToken
return request
}
return fetchToken().then(token => {
document.csrfToken = token
request.headers['x-csrf-token'] = document.csrfToken
return request
}).catch(_ => {
document.csrfToken = null // set mark to not try again
return request
})
function fetchToken() {
return axios.get('/', { headers: { 'x-csrf-token': 'fetch' } })
.then(res => res.headers['x-csrf-token'])
}
}

View File

@@ -2,4 +2,3 @@ namespace sap.capire.bookshop; //> important for reflection
using from './db/schema';
using from './srv/cat-service';
using from './srv/admin-service';
using from './srv/user-service';

5
bookshop/jsconfig.json Normal file
View File

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

View File

@@ -21,7 +21,9 @@
},
"cds": {
"requires": {
"db": "sql"
"db": {
"kind": "sql"
}
}
}
}

View File

@@ -1,10 +1,9 @@
const cds = require('@sap/cds/lib')
const cds = require('@sap/cds')
module.exports = class AdminService extends cds.ApplicationService { init(){
module.exports = cds.service.impl (function(){
this.before ('NEW','Authors', genid)
this.before ('NEW','Books', genid)
return super.init()
}}
})
/** Generate primary keys for target entity in request */
async function genid (req) {

View File

@@ -2,8 +2,8 @@ const cds = require('@sap/cds')
class CatalogService extends cds.ApplicationService { init(){
const { Books } = cds.entities ('sap.capire.bookshop')
const { ListOfBooks } = this.entities
//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 => {
@@ -19,7 +19,7 @@ class CatalogService extends cds.ApplicationService { init(){
})
// Add some discount for overstocked books
this.after ('READ', ListOfBooks, each => {
this.after ('READ','ListOfBooks', each => {
if (each.stock > 111) each.title += ` -- 11% discount!`
})

View File

@@ -5,7 +5,7 @@ service UserService {
/**
* The current user
*/
@odata.singleton entity me @cds.persistence.skip {
@odata.singleton entity me {
id : String; // user id
locale : String;
tenant : String;

View 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

View 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> {
}

View 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

View 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) => {};

View 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

View 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> {
}

View 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

View 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> {
}

View 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

View 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) => {};

View 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('_')

View 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
}

View 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
View 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>

View 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

View 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> {
}

View 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

View 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> {
}

View 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

View 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> {
}

View 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

View 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> {
}

View 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

View 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
View File

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

View File

@@ -19,4 +19,4 @@ module.exports = cds.server
// For didactic reasons in capire
const { ReviewsService, OrdersService } = cds.requires
if (!ReviewsService?.credentials && !OrdersService?.credentials) cds.requires.messaging = false
if (!ReviewsService.credentials && !OrdersService.credentials) cds.requires.messaging = false

View File

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

View 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

View 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> {
}

View 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

View 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
View File

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

View 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

View 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> {
}

View 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('_')

View 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
}

View File

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

View File

@@ -2,12 +2,12 @@
* Exposes data + entity metadata
*/
@requires:'authenticated-user'
@odata service DataService @( path:'-data' ) {
service DataService @( path:'-data' ) {
/**
* Metadata like name and columns/elements
*/
entity Entities @cds.persistence.skip {
entity Entities {
key name : String;
columns: Composition of many {
name : String;
@@ -19,7 +19,7 @@
/**
* The actual data, organized by column name
*/
entity Data @cds.persistence.skip {
entity Data {
record : array of {
column : String;
data : String;

View File

@@ -33,7 +33,7 @@ annotate CatalogService.Books with @(UI : {
////////////////////////////////////////////////////////////////////////////
//
// Books List Page
// Books Object Page
//
annotate CatalogService.Books with @(UI : {
SelectionFields : [

View File

@@ -10,31 +10,40 @@ using { sap.common } from '@capire/common';
// Books Lists
//
annotate my.Books with @(
Common.SemanticKey : [ID],
UI : {
Identification : [{ Value: title }],
SelectionFields : [
ID,
author_ID,
price,
currency_code
],
LineItem : [
{ Value: ID, Label: '{i18n>Title}' },
{ Value: author.ID, Label: '{i18n>Author}' },
{ Value: genre.name },
{ Value: stock },
{ Value: price },
{ Value: currency.symbol, Label: ' ' },
]
}
Common.SemanticKey : [ID],
UI : {
Identification : [{Value : title}],
SelectionFields : [
ID,
author_ID,
price,
currency_code
],
LineItem : [
{
Value : ID,
Label : '{i18n>Title}'
},
{
Value : author.ID,
Label : '{i18n>Author}'
},
{Value : genre.name},
{Value : stock},
{Value : price},
{
Value : currency.symbol,
Label : ' '
},
]
}
) {
ID @Common: {
SemanticObject : 'Books',
Text: title,
TextArrangement : #TextOnly
};
author @ValueList.entity : 'Authors';
ID @Common: {
SemanticObject : 'Books',
Text: title,
TextArrangement : #TextOnly
};
author @ValueList.entity : 'Authors';
};
////////////////////////////////////////////////////////////////////////////
@@ -42,10 +51,10 @@ annotate my.Books with @(
// Books Details
//
annotate my.Books with @(UI : {HeaderInfo : {
TypeName : '{i18n>Book}',
TypeNamePlural : '{i18n>Books}',
Title : { Value: title },
Description : { Value: author.name }
TypeName : '{i18n>Book}',
TypeNamePlural : '{i18n>Books}',
Title : {Value : title},
Description : {Value : author.name}
}, });
@@ -54,13 +63,19 @@ annotate my.Books with @(UI : {HeaderInfo : {
// Books Elements
//
annotate my.Books with {
ID @title: '{i18n>ID}';
title @title: '{i18n>Title}';
genre @title: '{i18n>Genre}' @Common: { Text: genre.name, TextArrangement: #TextOnly };
author @title: '{i18n>Author}' @Common: { Text: author.name, TextArrangement: #TextOnly };
price @title: '{i18n>Price}' @Measures.ISOCurrency : currency_code;
stock @title: '{i18n>Stock}';
descr @UI.MultiLineText;
ID @title : '{i18n>ID}';
title @title : '{i18n>Title}';
genre @title : '{i18n>Genre}' @Common : {
Text : genre.name,
TextArrangement : #TextOnly
};
author @title : '{i18n>Author}' @Common : {
Text : author.name,
TextArrangement : #TextOnly
};
price @title : '{i18n>Price}' @Measures.ISOCurrency : currency_code;
stock @title : '{i18n>Stock}';
descr @UI.MultiLineText;
}
////////////////////////////////////////////////////////////////////////////
@@ -68,17 +83,17 @@ annotate my.Books with {
// Genres List
//
annotate my.Genres with @(
Common.SemanticKey : [name],
UI : {
SelectionFields : [name],
LineItem : [
{ Value: name },
{
Value : parent.name,
Label: 'Main Genre'
},
],
}
Common.SemanticKey : [name],
UI : {
SelectionFields : [name],
LineItem : [
{Value : name},
{
Value : parent.name,
Label : 'Main Genre'
},
],
}
);
////////////////////////////////////////////////////////////////////////////
@@ -86,18 +101,18 @@ annotate my.Genres with @(
// Genre Details
//
annotate my.Genres with @(UI : {
Identification : [{ Value: name}],
HeaderInfo : {
TypeName : '{i18n>Genre}',
TypeNamePlural : '{i18n>Genres}',
Title : { Value: name },
Description : { Value: ID }
},
Facets : [{
$Type : 'UI.ReferenceFacet',
Label : '{i18n>SubGenres}',
Target : 'children/@UI.LineItem'
}, ],
Identification : [{Value : name}],
HeaderInfo : {
TypeName : '{i18n>Genre}',
TypeNamePlural : '{i18n>Genres}',
Title : {Value : name},
Description : {Value : ID}
},
Facets : [{
$Type : 'UI.ReferenceFacet',
Label : '{i18n>SubGenres}',
Target : 'children/@UI.LineItem'
}, ],
});
////////////////////////////////////////////////////////////////////////////
@@ -105,8 +120,8 @@ annotate my.Genres with @(UI : {
// Genres Elements
//
annotate my.Genres with {
ID @title: '{i18n>ID}';
name @title: '{i18n>Genre}';
ID @title : '{i18n>ID}';
name @title : '{i18n>Genre}';
}
////////////////////////////////////////////////////////////////////////////
@@ -114,24 +129,24 @@ annotate my.Genres with {
// Authors List
//
annotate my.Authors with @(
Common.SemanticKey : [ID],
UI : {
Identification : [{ Value: name}],
SelectionFields : [name],
LineItem : [
{ Value: ID },
{ Value: dateOfBirth },
{ Value: dateOfDeath },
{ Value: placeOfBirth },
{ Value: placeOfDeath },
],
}
Common.SemanticKey : [ID],
UI : {
Identification : [{Value : name}],
SelectionFields : [name],
LineItem : [
{Value : ID},
{Value : dateOfBirth},
{Value : dateOfDeath},
{Value : placeOfBirth},
{Value : placeOfDeath},
],
}
) {
ID @Common: {
SemanticObject : 'Authors',
Text: name,
TextArrangement : #TextOnly,
};
ID @Common: {
SemanticObject : 'Authors',
Text: name,
TextArrangement : #TextOnly,
};
};
////////////////////////////////////////////////////////////////////////////
@@ -139,16 +154,16 @@ annotate my.Authors with @(
// Author Details
//
annotate my.Authors with @(UI : {
HeaderInfo : {
TypeName : '{i18n>Author}',
TypeNamePlural : '{i18n>Authors}',
Title : { Value: name },
Description : { Value: dateOfBirth }
},
Facets : [{
$Type : 'UI.ReferenceFacet',
Target : 'books/@UI.LineItem'
}, ],
HeaderInfo : {
TypeName : '{i18n>Author}',
TypeNamePlural : '{i18n>Authors}',
Title : {Value : name},
Description : {Value : dateOfBirth}
},
Facets : [{
$Type : 'UI.ReferenceFacet',
Target : 'books/@UI.LineItem'
}, ],
});
@@ -157,12 +172,12 @@ annotate my.Authors with @(UI : {
// Authors Elements
//
annotate my.Authors with {
ID @title: '{i18n>ID}';
name @title: '{i18n>Name}';
dateOfBirth @title: '{i18n>DateOfBirth}';
dateOfDeath @title: '{i18n>DateOfDeath}';
placeOfBirth @title: '{i18n>PlaceOfBirth}';
placeOfDeath @title: '{i18n>PlaceOfDeath}';
ID @title : '{i18n>ID}';
name @title : '{i18n>Name}';
dateOfBirth @title : '{i18n>DateOfBirth}';
dateOfDeath @title : '{i18n>DateOfDeath}';
placeOfBirth @title : '{i18n>PlaceOfBirth}';
placeOfDeath @title : '{i18n>PlaceOfDeath}';
}
////////////////////////////////////////////////////////////////////////////
@@ -170,18 +185,18 @@ annotate my.Authors with {
// Languages List
//
annotate common.Languages with @(
Common.SemanticKey : [code],
Identification : [{ Value: code}],
UI : {
SelectionFields : [
name,
descr
],
LineItem : [
{ Value: code },
{ Value: name },
],
}
Common.SemanticKey : [code],
Identification : [{Value : code}],
UI : {
SelectionFields : [
name,
descr
],
LineItem : [
{Value : code},
{Value : name},
],
}
);
////////////////////////////////////////////////////////////////////////////
@@ -189,22 +204,22 @@ annotate common.Languages with @(
// Language Details
//
annotate common.Languages with @(UI : {
HeaderInfo : {
TypeName : '{i18n>Language}',
TypeNamePlural : '{i18n>Languages}',
Title : { Value: name },
Description : { Value: descr }
},
Facets : [{
$Type : 'UI.ReferenceFacet',
Label : '{i18n>Details}',
Target : '@UI.FieldGroup#Details'
}, ],
FieldGroup #Details : {Data : [
{ Value: code },
{ Value: name },
{ Value: descr }
]},
HeaderInfo : {
TypeName : '{i18n>Language}',
TypeNamePlural : '{i18n>Languages}',
Title : {Value : name},
Description : {Value : descr}
},
Facets : [{
$Type : 'UI.ReferenceFacet',
Label : '{i18n>Details}',
Target : '@UI.FieldGroup#Details'
}, ],
FieldGroup #Details : {Data : [
{Value : code},
{Value : name},
{Value : descr}
]},
});
////////////////////////////////////////////////////////////////////////////
@@ -212,19 +227,19 @@ annotate common.Languages with @(UI : {
// Currencies List
//
annotate common.Currencies with @(
Common.SemanticKey : [code],
Identification : [{ Value: code}],
UI : {
SelectionFields : [
name,
descr
],
LineItem : [
{ Value: descr },
{ Value: symbol },
{ Value: code },
],
}
Common.SemanticKey : [code],
Identification : [{Value : code}],
UI : {
SelectionFields : [
name,
descr
],
LineItem : [
{Value : descr},
{Value : symbol},
{Value : code},
],
}
);
////////////////////////////////////////////////////////////////////////////
@@ -232,35 +247,35 @@ annotate common.Currencies with @(
// Currency Details
//
annotate common.Currencies with @(UI : {
HeaderInfo : {
TypeName : '{i18n>Currency}',
TypeNamePlural : '{i18n>Currencies}',
Title : { Value: descr },
Description : { Value: code }
},
Facets : [
{
$Type : 'UI.ReferenceFacet',
Label : '{i18n>Details}',
Target : '@UI.FieldGroup#Details'
HeaderInfo : {
TypeName : '{i18n>Currency}',
TypeNamePlural : '{i18n>Currencies}',
Title : {Value : descr},
Description : {Value : code}
},
{
$Type : 'UI.ReferenceFacet',
Label : '{i18n>Extended}',
Target : '@UI.FieldGroup#Extended'
},
],
FieldGroup #Details : {Data : [
{ Value: name },
{ Value: symbol },
{ Value: code },
{ Value: descr }
]},
FieldGroup #Extended : {Data : [
{ Value: numcode },
{ Value: minor },
{ Value: exponent }
]},
Facets : [
{
$Type : 'UI.ReferenceFacet',
Label : '{i18n>Details}',
Target : '@UI.FieldGroup#Details'
},
{
$Type : 'UI.ReferenceFacet',
Label : '{i18n>Extended}',
Target : '@UI.FieldGroup#Extended'
},
],
FieldGroup #Details : {Data : [
{Value : name},
{Value : symbol},
{Value : code},
{Value : descr}
]},
FieldGroup #Extended : {Data : [
{Value : numcode},
{Value : minor},
{Value : exponent}
]},
});
////////////////////////////////////////////////////////////////////////////
@@ -268,7 +283,7 @@ annotate common.Currencies with @(UI : {
// Currencies Elements
//
annotate common.Currencies with {
numcode @title: '{i18n>NumCode}';
minor @title: '{i18n>MinorUnit}';
exponent @title: '{i18n>Exponent}';
numcode @title : '{i18n>NumCode}';
minor @title : '{i18n>MinorUnit}';
exponent @title : '{i18n>Exponent}';
}

View File

@@ -1 +0,0 @@
using from './db/common';

View File

@@ -14,6 +14,9 @@
},
"cds": {
"requires": {
"auth": {
"kind": "dummy-auth"
},
"ReviewsService": {
"kind": "odata",
"model": "@capire/reviews"
@@ -43,10 +46,10 @@
"[production]": {
"model": "db/hana"
}
},
"hana": {
"deploy-format": "hdbtable"
}
},
"hana": {
"deploy-format": "hdbtable"
}
}
}

3
hello/@types/_/index.js Normal file
View 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
hello/@types/_/index.ts Normal file
View 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
hello/jsconfig.json Normal file
View File

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

View File

@@ -12,8 +12,23 @@
"devDependencies": {
"@types/jest": "*",
"@types/node": "*",
"ts-jest": "^27.0.2",
"typescript": "^4.3.5"
},
"jest": {
"testEnvironment": "node",
"preset": "ts-jest",
"globals": {
"ts-jest": {
"diagnostics": {
"_comment": "see https://githubmemory.com/repo/kulshekhar/ts-jest/issues/2722",
"ignoreCodes": [
151001
]
}
}
}
},
"eslintConfig": {
"extends": "eslint:recommended",
"env": {

View File

@@ -1,13 +0,0 @@
const cds = require ('@sap/cds')
describe('Hello world!', () => {
beforeAll (()=> process.env.CDS_TYPESCRIPT = true)
afterAll (()=> delete process.env.CDS_TYPESCRIPT)
const {GET} = cds.test.in(__dirname,'../srv').run('serve', 'world.cds')
it('should say hello with class impl', async () => {
const {data} = await GET`/say/hello(to='world')`
expect(data.value).toMatch(/Hello world.*typescript.*/i)
})
})

View File

@@ -0,0 +1,15 @@
process.env.CDS_TYPESCRIPT = 'true';
import * as cds from '@sap/cds';
//@ts-ignore
const {GET} = cds.test.in(__dirname,'../srv').run('serve', 'world.cds');
describe('Hello world!', () => {
afterAll(() => { delete process.env.CDS_TYPESCRIPT; });
it('should say hello with class impl from a typescript file', async () => {
const {data} = await GET`/say/hello(to='world')`
expect(data.value).toMatch(/Hello world.*typescript.*/i)
})
})

3
media/@types/_/index.js Normal file
View 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
media/@types/_/index.ts Normal file
View 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
}

View 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('sap.capire.media.MediaServer')
module.exports.Media = cson.Media
module.exports.Media_ = cson.Media

View File

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

@@ -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('sap.capire.media')
module.exports.Media = cson.Media
module.exports.Media_ = cson.Media

View File

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

5
media/jsconfig.json Normal file
View File

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

View 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

View File

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

3
orders/@types/_/index.js Normal file
View 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
orders/@types/_/index.ts Normal file
View 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
orders/@types/index.js Normal file
View 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
orders/@types/index.ts Normal file
View 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>

View 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

View File

@@ -0,0 +1,50 @@
// This is an automatically generated file. Please do not change its contents manually!
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<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> {
}
/**
* 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

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

View 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> {
}

View 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

View 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> {
}

View File

@@ -16,12 +16,11 @@ using { OrdersService } from '../srv/orders-service';
@odata.draft.enabled
annotate OrdersService.Orders with @(
UI: {
SelectionFields: [ createdBy ],
SelectionFields: [ createdAt, createdBy ],
LineItem: [
{Value: OrderNo, Label:'OrderNo'},
{Value: buyer, Label:'Customer'},
{Value: currency.symbol, Label:'Currency'},
{Value: createdAt, Label:'Date'},
{Value: createdAt, Label:'Date'}
],
HeaderInfo: {
TypeName: 'Order', TypeNamePlural: 'Orders',

View File

@@ -13,7 +13,7 @@
applications: {
"manage-orders": {
title: "Manage Orders",
description: "CAP Sample App",
description: "... testing FE v42",
additionalInformation: "SAPUI5.Component=orders",
applicationType : "URL",
url: "/orders/webapp",

View File

@@ -3,8 +3,8 @@
"sap.app": {
"id": "orders",
"type": "application",
"title": "Order Management",
"description": "CAP Sample Application",
"title": "Order Books",
"description": "Sample Application",
"i18n": "i18n/i18n.properties",
"dataSources": {
"OrdersService": {

View File

@@ -2,7 +2,7 @@ using { Currency, User, managed, cuid } from '@sap/cds/common';
namespace sap.capire.orders;
entity Orders : cuid, managed {
OrderNo : String(22) @title:'Order Number'; //> readable key
OrderNo : String @title:'Order Number'; //> readable key
Items : Composition of many {
key ID : UUID;
product : Association to Products;

5
orders/jsconfig.json Normal file
View File

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

7045
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -8,15 +8,7 @@
"@sap/cds": ">=5.5.3"
},
"workspaces": [
"./bookshop",
"./bookstore",
"./common",
"./data-viewer",
"./fiori",
"./hello",
"./media",
"./orders",
"./reviews"
"./*/"
],
"devDependencies": {
"axios": "^0",
@@ -37,7 +29,6 @@
"jest": "npx jest",
"start": "cds watch fiori",
"test": "npm run jest -- --silent",
"test:mocha": "npx mocha --parallel --recursive --timeout 20000",
"test:hello": "cd hello && npm test"
},
"jest": {

View 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

View 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) => {};

View 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('_')

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