diff --git a/bookshop/@cds-models/AdminService/index.js b/bookshop/@cds-models/AdminService/index.js new file mode 100644 index 00000000..87ccb562 --- /dev/null +++ b/bookshop/@cds-models/AdminService/index.js @@ -0,0 +1,9 @@ +// This is an automatically generated file. Please do not change its contents manually! +const cds = require('@sap/cds') +const csn = cds.entities('AdminService') +module.exports.Book = csn.Books +module.exports.Books = csn.Books +module.exports.Author = csn.Authors +module.exports.Authors = csn.Authors +// actions +// enums diff --git a/bookshop/@cds-models/AdminService/index.ts b/bookshop/@cds-models/AdminService/index.ts new file mode 100644 index 00000000..5e18cfa6 --- /dev/null +++ b/bookshop/@cds-models/AdminService/index.ts @@ -0,0 +1,38 @@ +// 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 './..'; +export function _BookAspect any>(Base: TBase) { + return class Book 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 ?: _.Currency; + image ?: string; + }; +} +export class Book extends _._managedAspect(_BookAspect(__.Entity)) {} +export class Books extends Array {} + +export function _AuthorAspect any>(Base: TBase) { + return class Author extends Base { + ID ?: number; + name ?: string; + dateOfBirth ?: Date; + dateOfDeath ?: Date; + placeOfBirth ?: string; + placeOfDeath ?: string; + books ?: __.Association.to.many<_sap_capire_bookshop.Books>; + }; +} +export class Author extends _._managedAspect(_AuthorAspect(__.Entity)) {} +export class Authors extends Array {} diff --git a/bookshop/@cds-models/CatalogService/index.js b/bookshop/@cds-models/CatalogService/index.js new file mode 100644 index 00000000..f44022fc --- /dev/null +++ b/bookshop/@cds-models/CatalogService/index.js @@ -0,0 +1,10 @@ +// This is an automatically generated file. Please do not change its contents manually! +const cds = require('@sap/cds') +const csn = cds.entities('CatalogService') +module.exports.ListOfBook = csn.ListOfBooks +module.exports.ListOfBooks = csn.ListOfBooks +module.exports.Book = csn.Books +module.exports.Books = csn.Books +// actions +module.exports.submitOrder = 'submitOrder' +// enums diff --git a/bookshop/@cds-models/CatalogService/index.ts b/bookshop/@cds-models/CatalogService/index.ts new file mode 100644 index 00000000..62cbbeed --- /dev/null +++ b/bookshop/@cds-models/CatalogService/index.ts @@ -0,0 +1,56 @@ +// 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 './..'; +/** +* For displaying lists of Books +*/ +export function _ListOfBookAspect any>(Base: TBase) { + return class ListOfBook 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 ?: _.Currency; + image ?: string; + }; +} +export class ListOfBook extends _._managedAspect(_ListOfBookAspect(__.Entity)) {} +export class ListOfBooks extends Array {} + +/** +* For display in details pages +*/ +export function _BookAspect any>(Base: TBase) { + return class Book 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 ?: _.Currency; + image ?: string; + }; +} +export class Book extends _._managedAspect(_BookAspect(__.Entity)) {} +export class Books extends Array {} + +// function +export declare const submitOrder: (book: __.DeepRequired['ID'], quantity: number) => { + stock ?: number; +}; \ No newline at end of file diff --git a/bookshop/@cds-models/UserService/index.js b/bookshop/@cds-models/UserService/index.js new file mode 100644 index 00000000..4756c32e --- /dev/null +++ b/bookshop/@cds-models/UserService/index.js @@ -0,0 +1,8 @@ +// This is an automatically generated file. Please do not change its contents manually! +const cds = require('@sap/cds') +const csn = cds.entities('UserService') +module.exports.me = csn.me +module.exports.me_ = csn.me +// actions +module.exports.login = 'login' +// enums diff --git a/bookshop/@cds-models/UserService/index.ts b/bookshop/@cds-models/UserService/index.ts new file mode 100644 index 00000000..faf4a830 --- /dev/null +++ b/bookshop/@cds-models/UserService/index.ts @@ -0,0 +1,17 @@ +// This is an automatically generated file. Please do not change its contents manually! +import * as __ from './../_'; +/** +* The current user +*/ +export function _meAspect any>(Base: TBase) { + return class me extends Base { + id ?: string; + locale ?: string; + tenant ?: string; + }; +} +export class me extends _meAspect(__.Entity) {} +export class me_ extends Array {} + +// function +export declare const login: () => me; \ No newline at end of file diff --git a/bookshop/@cds-models/_/index.js b/bookshop/@cds-models/_/index.js new file mode 100644 index 00000000..82ef6143 --- /dev/null +++ b/bookshop/@cds-models/_/index.js @@ -0,0 +1,5 @@ +// This is an automatically generated file. Please do not change its contents manually! +const cds = require('@sap/cds') +const csn = cds.entities('_') +// actions +// enums diff --git a/bookshop/@cds-models/_/index.ts b/bookshop/@cds-models/_/index.ts new file mode 100644 index 00000000..d74e40c9 --- /dev/null +++ b/bookshop/@cds-models/_/index.ts @@ -0,0 +1,30 @@ +// This is an automatically generated file. Please do not change its contents manually! + +export namespace Association { + export type to = T; + export namespace to { + export type many = T; + } +} + +export namespace Composition { + export type of = T; + export namespace of { + export type many = T; + } +} + +export class Entity { + static data (this:T, input:Object) : T { + return {} as T // mock + } +} + +export type EntitySet = T[] & { + data (input:object[]) : T[] + data (input:object) : T +}; + +export type DeepRequired = { + [K in keyof T]: DeepRequired +} & Required; diff --git a/bookshop/@cds-models/index.js b/bookshop/@cds-models/index.js new file mode 100644 index 00000000..4c9dafa5 --- /dev/null +++ b/bookshop/@cds-models/index.js @@ -0,0 +1,5 @@ +// This is an automatically generated file. Please do not change its contents manually! +const cds = require('@sap/cds') +const csn = cds.entities('') +// actions +// enums diff --git a/bookshop/@cds-models/index.ts b/bookshop/@cds-models/index.ts new file mode 100644 index 00000000..665da8c4 --- /dev/null +++ b/bookshop/@cds-models/index.ts @@ -0,0 +1,45 @@ +// 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 _cuidAspect any>(Base: TBase) { + return class cuid extends Base { + ID ?: string; + }; +} +export class cuid extends _cuidAspect(__.Entity) {} +// the following represents the CDS aspect 'managed' +export function _managedAspect any>(Base: TBase) { + return class managed extends Base { + createdAt ?: Date; + /** + * Canonical user ID + */ + createdBy ?: User; + modifiedAt ?: Date; + /** + * Canonical user ID + */ + modifiedBy ?: User; + }; +} +export class managed extends _managedAspect(__.Entity) {} +// the following represents the CDS aspect 'temporal' +export function _temporalAspect any>(Base: TBase) { + return class temporal extends Base { + validFrom ?: Date; + validTo ?: Date; + }; +} +export class temporal extends _temporalAspect(__.Entity) {} +// the following represents the CDS aspect 'extensible' +export function _extensibleAspect any>(Base: TBase) { + return class extensible extends Base { + extensions__ ?: string; + }; +} +export class extensible extends _extensibleAspect(__.Entity) {} \ No newline at end of file diff --git a/bookshop/@cds-models/sap/capire/bookshop/index.js b/bookshop/@cds-models/sap/capire/bookshop/index.js new file mode 100644 index 00000000..ada1033a --- /dev/null +++ b/bookshop/@cds-models/sap/capire/bookshop/index.js @@ -0,0 +1,11 @@ +// This is an automatically generated file. Please do not change its contents manually! +const cds = require('@sap/cds') +const csn = cds.entities('sap.capire.bookshop') +module.exports.Book = csn.Books +module.exports.Books = csn.Books +module.exports.Author = csn.Authors +module.exports.Authors = csn.Authors +module.exports.Genre = csn.Genres +module.exports.Genres = csn.Genres +// actions +// enums diff --git a/bookshop/@cds-models/sap/capire/bookshop/index.ts b/bookshop/@cds-models/sap/capire/bookshop/index.ts new file mode 100644 index 00000000..f373bb33 --- /dev/null +++ b/bookshop/@cds-models/sap/capire/bookshop/index.ts @@ -0,0 +1,51 @@ +// 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 _BookAspect any>(Base: TBase) { + return class Book extends Base { + ID ?: number; + title ?: string; + descr ?: string; + author ?: __.Association.to; + genre ?: __.Association.to; + stock ?: number; + price ?: number; + /** + * Type for an association to Currencies + * + * See https://cap.cloud.sap/docs/cds/common#type-currency + */ + currency ?: _.Currency; + image ?: string; + }; +} +export class Book extends _._managedAspect(_BookAspect(__.Entity)) {} +export class Books extends Array {} + +export function _AuthorAspect any>(Base: TBase) { + return class Author extends Base { + ID ?: number; + name ?: string; + dateOfBirth ?: Date; + dateOfDeath ?: Date; + placeOfBirth ?: string; + placeOfDeath ?: string; + books ?: __.Association.to.many; + }; +} +export class Author extends _._managedAspect(_AuthorAspect(__.Entity)) {} +export class Authors extends Array {} + +/** +* Hierarchically organized Code List for Genres +*/ +export function _GenreAspect any>(Base: TBase) { + return class Genre extends Base { + ID ?: number; + parent ?: __.Association.to; + children ?: __.Composition.of.many; + }; +} +export class Genre extends _sap_common._CodeListAspect(_GenreAspect(__.Entity)) {} +export class Genres extends Array {} diff --git a/bookshop/@cds-models/sap/common/index.js b/bookshop/@cds-models/sap/common/index.js new file mode 100644 index 00000000..606af5cc --- /dev/null +++ b/bookshop/@cds-models/sap/common/index.js @@ -0,0 +1,11 @@ +// This is an automatically generated file. Please do not change its contents manually! +const cds = require('@sap/cds') +const csn = cds.entities('sap.common') +module.exports.Language = csn.Languages +module.exports.Languages = csn.Languages +module.exports.Country = csn.Countries +module.exports.Countries = csn.Countries +module.exports.Currency = csn.Currencies +module.exports.Currencies = csn.Currencies +// actions +// enums diff --git a/bookshop/@cds-models/sap/common/index.ts b/bookshop/@cds-models/sap/common/index.ts new file mode 100644 index 00000000..1ca5862a --- /dev/null +++ b/bookshop/@cds-models/sap/common/index.ts @@ -0,0 +1,64 @@ +// 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 _CodeListAspect any>(Base: TBase) { + return class CodeList extends Base { + name ?: string; + descr ?: string; + }; +} +export class CodeList extends _CodeListAspect(__.Entity) {} +// the following represents the CDS aspect 'TextsAspect' +export function _TextsAspectAspect any>(Base: TBase) { + return class TextsAspect extends Base { + /** + * Type for a language code + */ + locale ?: Locale; + }; +} +export class TextsAspect extends _TextsAspectAspect(__.Entity) {} +/** +* Code list for languages +* +* See https://cap.cloud.sap/docs/cds/common#entity-sapcommonlanguages +*/ +export function _LanguageAspect any>(Base: TBase) { + return class Language extends Base { + /** + * Type for a language code + */ + code ?: Locale; + }; +} +export class Language extends _CodeListAspect(_LanguageAspect(__.Entity)) {} +export class Languages extends Array {} + +/** +* Code list for countries +* +* See https://cap.cloud.sap/docs/cds/common#entity-sapcommoncountries +*/ +export function _CountryAspect any>(Base: TBase) { + return class Country extends Base { + code ?: string; + }; +} +export class Country extends _CodeListAspect(_CountryAspect(__.Entity)) {} +export class Countries extends Array {} + +/** +* Code list for currencies +* +* See https://cap.cloud.sap/docs/cds/common#entity-sapcommoncurrencies +*/ +export function _CurrencyAspect any>(Base: TBase) { + return class Currency extends Base { + code ?: string; + symbol ?: string; + minorUnit ?: number; + }; +} +export class Currency extends _CodeListAspect(_CurrencyAspect(__.Entity)) {} +export class Currencies extends Array {} diff --git a/bookshop/db/schema.cds b/bookshop/db/schema.cds index ff7017ca..f2fb626f 100644 --- a/bookshop/db/schema.cds +++ b/bookshop/db/schema.cds @@ -3,9 +3,9 @@ namespace sap.capire.bookshop; entity Books : managed { key ID : Integer; - @mandatory title : localized String(111); + title : localized String(111) @mandatory ; descr : localized String(1111); - @mandatory author : Association to Authors; + author : Association to Authors @mandatory; genre : Association to Genres; stock : Integer; price : Decimal; @@ -15,7 +15,7 @@ entity Books : managed { entity Authors : managed { key ID : Integer; - @mandatory name : String(111); + name : String(111) @mandatory; dateOfBirth : Date; dateOfDeath : Date; placeOfBirth : String;