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
84 changed files with 2059 additions and 5 deletions

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

5
bookshop/jsconfig.json Normal file
View File

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

View File

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

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

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

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

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

5
orders/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('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('_')

35
reviews/@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
reviews/@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
reviews/@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.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')
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> {
}

5
reviews/jsconfig.json Normal file
View File

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