Compare commits

..

9 Commits

Author SHA1 Message Date
nkaputnik
2f1af693c9 Finalize ToDo's 2022-07-28 15:29:53 +02:00
nkaputnik
d2ab511d6d Package.json 2022-07-28 14:58:32 +02:00
nkaputnik
6c27228d62 Sandbox API with Application Service 2022-07-28 14:55:37 +02:00
nkaputnik
44880c7745 Better Sandbox API 2022-07-28 14:54:08 +02:00
nkaputnik
9c2a7598f2 First push 2022-07-26 09:47:56 +02:00
nkaputnik
9617e576f0 First push 2022-07-26 09:47:30 +02:00
nkaputnik
c3c9dae80d First push 2022-07-26 09:45:34 +02:00
nkaputnik
2b6d4c625e First push 2022-05-06 11:09:04 +02:00
nkaputnik
7d46db42ec First push 2022-05-06 11:05:33 +02:00
30 changed files with 738 additions and 10506 deletions

View File

@@ -10,7 +10,7 @@ const books = Vue.createApp ({
list: [], list: [],
book: undefined, book: undefined,
order: { quantity:1, succeeded:'', failed:'' }, order: { quantity:1, succeeded:'', failed:'' },
user: undefined user: {}
} }
}, },
@@ -42,25 +42,19 @@ const books = Vue.createApp ({
} }
}, },
async login() { async fetchUserInfo() {
try { try {
const { data:user } = await axios.post('/user/login',{}) const { data } = await axios.get('/user/me')
if (user.id !== 'anonymous') books.user = user books.user = data
} catch (err) { books.user = { id: err.message } } } catch (err) { books.user = { id: err.message } }
}, }
async getUserInfo() {
try {
const { data:user } = await axios.get('/user/me')
if (user.id !== 'anonymous') books.user = user
} catch (err) { books.user = { id: err.message } }
},
} }
}).mount("#app") }).mount("#app")
books.getUserInfo() // initially fill list of books
books.fetch() // initially fill list of books books.fetch()
books.fetchUserInfo()
document.addEventListener('keydown', (event) => { document.addEventListener('keydown', (event) => {
// hide user info on request // hide user info on request
if (event.key === 'u') books.user = undefined if (event.key === 'u') books.user = undefined

View File

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

View File

@@ -0,0 +1,2 @@
using from '..\..\schema';

View File

@@ -4,7 +4,7 @@
* currencies, if not obtained through @capire/common. * currencies, if not obtained through @capire/common.
*/ */
export default async (db)=>{ module.exports = async (db)=>{
const has_common = db.model.definitions['sap.common.Currencies'].elements.numcode const has_common = db.model.definitions['sap.common.Currencies'].elements.numcode
if (has_common) return if (has_common) return

View File

@@ -1,7 +1,14 @@
using { Currency, managed, sap } from '@sap/cds/common'; using {
Currency,
managed,
sap,
extensible
} from '@sap/cds/common';
namespace sap.capire.bookshop; namespace sap.capire.bookshop;
entity Books : managed { @Extensibility.Any.Enabled : true
entity Books : managed, extensible {
key ID : Integer; key ID : Integer;
title : localized String(111); title : localized String(111);
descr : localized String(1111); descr : localized String(1111);
@@ -11,21 +18,39 @@ entity Books : managed {
price : Decimal; price : Decimal;
currency : Currency; currency : Currency;
image : LargeBinary @Core.MediaType : 'image/png'; image : LargeBinary @Core.MediaType : 'image/png';
authorName : String;
} }
entity Authors : managed {
entity Authors : managed, extensible {
key ID : Integer; key ID : Integer;
name : String(111); name : String(111);
dateOfBirth : Date; dateOfBirth : Date;
dateOfDeath : Date; dateOfDeath : Date;
placeOfBirth : String; placeOfBirth : String;
placeOfDeath : String; placeOfDeath : String;
books : Association to many Books on books.author = $self;
books : Association to many Books
on books.author = $self;
} }
/** Hierarchically organized Code List for Genres */ extend Authors with {
virtual age : Integer;
virtual exampleBook: String;
}
/**
* Hierarchically organized Code List for Genres
*/
entity Genres : sap.common.CodeList { entity Genres : sap.common.CodeList {
key ID : Integer; key ID : Integer;
parent : Association to Genres; parent : Association to Genres;
children : Composition of many Genres on children.parent = $self; children : Composition of many Genres
on children.parent = $self;
}
entity Publishers: managed {
key ID: Integer;
name: String(111);
} }

View File

@@ -0,0 +1,17 @@
async function run() {
//debugger
//while (true) {}
//process.exit()
//1.substring()
// let res = await specialselect
let res = await SELECT.one`title`.from(`Books`).where(`ID=201`)
let { title } = res
let Author = req.data
//await srv.read('Books')
Author.modifiedBy = "Custom Event handler changed this!"
Author.placeOfDeath = " --- Somewhere over " + title + " --- create in Sandbox"
//await this.emit("createdAuthor", { Author })
return Author
}
run()

View File

@@ -0,0 +1,41 @@
function getYear(v) {
return parseInt(v.substr(0, 4))
}
function getMonth(v) {
return parseInt(v.substr(5, 2))
}
function getDay(v) {
return parseInt(v.substr(8, 2))
}
function getAge(from, to) {
if (from === undefined || from == null) return 0
if (to === undefined || to == null) to = new Date().toISOString()
let year = getYear(to) - getYear(from) - 1
if (
getMonth(to) > getMonth(from) ||
(getMonth(to) === getMonth(from) && getDay(to) >= getDay(from))
) {
year++
}
return year
}
async function run() {
const result_ = Array.isArray(result) ? result : [result]
for (const row of result_) {
row.age = getAge(row.dateOfBirth, row.dateOfDeath)
let res = await SELECT.one`title`.from(`Books`).where({ author_ID: row.ID })
if (!res) {
res = {}
}
let { title } = res
if (!title) {
title = "no Books yet"
}
row.exampleBook = title
//let pub = await SELECT.one`name`.from(`sap_capire_bookshop_Publishers`)
}
}
run()

View File

@@ -0,0 +1,9 @@
async function run() {
const {stock, price, author_ID} = req.data
if (stock<0) return req.reject('409', 'Stock must not be negative')
if (price<0) return req.reject('409', 'Price must not be negative')
let {name} = await SELECT.one`name`.from(`Authors`).where({ID: author_ID})
req.data.authorName=name
}
output = run()

View File

@@ -0,0 +1,6 @@
const result_ = Array.isArray(result) ? result : [result];
for (const row of result_) {
if (row.stock > 50) {
row.title += " ---Order now for a 10% discount!";
}
}

View File

@@ -0,0 +1,9 @@
async function run() {
const {author, newName} = req.data
let a = await SELECT `name`.from(`Authors`).where({ID: author})
if(!a) return req.error (404, `Can't rename a non-existing author`)
await UPDATE (`Authors`,author).with ({ name: newName })
//await this.emit ('renamedAuthor', { author, newName })
output.msg = 'Success'
}
run()

View File

@@ -0,0 +1,5 @@
async function run() {
let {Author} = req.data
Author.placeOfBirth += ' --- modified in custom event'
}
run()

View File

@@ -1,2 +1,2 @@
import { CatalogService } from './srv/cat-service.js' const { CatalogService } = require('./srv/cat-service')
export { CatalogService } module.exports = { CatalogService }

112
bookshop/notebook.md Normal file
View File

@@ -0,0 +1,112 @@
# Base assumption
Event handlers will always use **publicly available application API's**(services)
- already done in Sandbox API by overwriting **SELECT**, **UPDATE**, **READ** and **CREATE**
## Inbound data for validations
- req.target plus expand on related data
- lazy loading on expand
- event facade could have an explicit publishing of specific services or documents (e.g. remote services)
- CQN Protocol adapter for subsequent reads --> req.data plus application service calls
- what is the CDS subset to put in?
- req.data + target-rec (proxy, unloaded)
- ORM type lazy loading (dereferenced)
- application developer could actually provide custom proxies for specific functions
- performance impact of multiple accesses to object graph and multiple DB roundtrips
- can static code checking or developer annotations influence what is loaded into a graph?
- alternative: Stripped-down SELECT limited to req.target and ID
- application service only
- access rights of user respected
- What about to-many relationships? For compositions essential, for associations to be questioned
- Application Service Reads
- outbound data for changes
- call remote services
- register new remote services dynamically
- CAP provides an API on remote services - connect doesn't need to be done by extension developer
- alternative: declarative remote services plumbing with CDS service facade
- model looks like static internal services, remote calls done transparently behind the scenes
-Emit Events
- choreography of extension points
- deep inserts vs. fine grained operations
- input validation may be suited for fine grained operations
- today not in scope for performance reasons
- two different use case: Insert new page to book vs. update order-header with items-constraints in place
- reject request, return errors and warnings - suitable for UI, too
*/
/*
Annotations available:
Entity level
@expression.constraint : [{if: 'expression evaluates to bool'}, on: ['INSERT, UPDATE, DELETE'], error: 'Transaction Rollback and error message', warning: 'Transaction proceeds and warning message']
@expression.computed : [{expression: 'ability to access request payload and modify it', on: ['INSERT, UPDATE']}]
@event : [{if: 'expression evaluates to bool', on: ['INSERT, UPDATE, DELETE, READ'], when: 'before or after, default before', emit: 'Event Name', to: 'Messaging target, optional'}]
@expresion.code :[{file: 'file name', on:['insert', 'update'], when: 'before or after, default before'},
{source: 'each => { if (each.stock > 111) {each.title += `-- 11% discount!`; each.price= each.price*0.9}', on:['insert', 'update'], when: 'before or after'}]
Atribute Level
@assert.constraint : {if: 'stock>=0 OR stock <1000', error: 'i18n/error102'};
@event : {if: 'expression evaluates to bool', on: ['INSERT, UPDATE, DELETE, READ'], when: 'before or after', emit: 'Event Name', to: 'Messaging target, optional' }
Functions available:
EXISTS(association target)
COUNT,AVG,MIN,MAX,SUM: Composition items, arrays etc
OLD: before image
EACH: loop over composition items
Events covered:
CRUD --> Longhand and Shorthand supported?
Upsert as one event?
Before and after:
Before can change change request payload and stop transaction
After should trigger only asynchronous messages
Specific Events for status changes? I think expression based event emitter suffices
*/
//Entity level annotations
@expression.constraint : [{if: 'stock>100 AND price>15)', on: ['INSERT', 'UPDATE'], error: 'No Book over price 15 should have more than 100 stock' }, // error, rollback transactions
{if: 'stock>90 AND price>15)', on: ['I', 'U'], warning: 'No Book over price 15 should have more than 100 stock' }] //warning, proceed with transaction but report warning back to UI
@expression.computed : {expression: 'if(stock>100) then price=price*0.9', on: ['INSERT']} //ability to modify the payload of the request, but nothing beyond it
@expresion.code :[{file: 'sap.capire.bookshop-Books-beforeInsert', on:['insert', 'update'], when: 'before'}, //naming can be arbitrary?
{source: 'each => { if (each.stock > 111) {each.title += `-- 11% discount!`; each.price= each.price*0.9}', on:['insert', 'update'], when: 'before'}] //alternative
@event : { if:'price>200', emit: 'Expensive Book', to: 'RulesEngine'}
entity Books : managed {
key ID : Integer;
title : localized String(111); @event : {if: 'old.title="Hello"', emit: 'Hello changed' } //old refers to before Image. No "to" clause means message is emitted to any subscriber interested
descr : localized String(1111);
author : Association to Authors @assert.constraint: 'exists(author)'; //function calls need to evaluate to bool
genre : Association to Genres;
stock : Integer @assert.constraint : {if: 'stock>=0 OR stock <1000', error: 'Stock not within permitted parameters'}; //when operand is used, no auto-insert
price : Decimal(9,2) @assert.constraint : '>0'; //insert operand on left side by default
currency : Currency;
image : LargeBinary @Core.MediaType : 'image/png';
stockWorth: Decimal(9,2) @expression.computed : 'stock*price'; //persisted on write. Overhead in runtime, but performance benefit on read. Payload ignored?
// stockWorth2 = stock*price; -- long term goal from compiler team, not persisted on write, but calculated on read
stockWorth3 : Decimal @expression.computed: 'if (stock*price>1000) then stockWorth3=stock.price else stockworth3=1000'; //which altenative?
stockWorth4 : Decimal @expression.computed: {if: '(stock*price>1000)', then: 'stockWorth3=stock.price', else: 'stockworth3=1000'};
}
//@assert.expression: 'dateOfBirth<dateOfDeath'
entity Authors : managed {
key ID : Integer;
name : String(111);
dateOfBirth : Date ;
dateOfDeath : Date @expression.constraint: '>dateOfBirth';
placeOfBirth : String;
placeOfDeath : String;
books : Association to many Books on books.author = $self;
}
/** Hierarchically organized Code List for Genres */
entity Genres : sap.common.CodeList {
key ID : Integer;
parent : Association to Genres;
children : Composition of many Genres on children.parent = $self;
}
```
```

View File

@@ -2,7 +2,6 @@
"name": "@capire/bookshop", "name": "@capire/bookshop",
"version": "1.0.0", "version": "1.0.0",
"description": "A simple self-contained bookshop service.", "description": "A simple self-contained bookshop service.",
"type": "module",
"files": [ "files": [
"app", "app",
"srv", "srv",
@@ -13,7 +12,8 @@
"dependencies": { "dependencies": {
"@sap/cds": ">=5.9", "@sap/cds": ">=5.9",
"express": "^4.17.1", "express": "^4.17.1",
"passport": ">=0.4.1" "passport": ">=0.4.1",
"vm2": ">=3.9.9"
}, },
"scripts": { "scripts": {
"genres": "cds serve test/genres.cds", "genres": "cds serve test/genres.cds",
@@ -22,8 +22,12 @@
}, },
"cds": { "cds": {
"requires": { "requires": {
"code-extensibility" : true,
"db": { "db": {
"kind": "sql" "kind": "sqlite",
"credentials": {
"database": "sqlite.db"
}
} }
} }
} }

BIN
bookshop/sqlite.db Normal file

Binary file not shown.

View File

@@ -1,5 +1,30 @@
using {sap.capire.bookshop as my} from '../db/schema'; using {sap.capire.bookshop as my} from '../db/schema';
service AdminService @(requires:'admin') {
entity Books as projection on my.Books; service AdminService // @(requires : 'admin')
entity Authors as projection on my.Authors; {
entity Books as projection on my.Books actions {
action increaseStock(count : Integer);
function stock() returns Integer;
};
@Extensibility : {
Fields.Enabled : true,
Fields.Quota: 100,
Relations.Enabled : false,
Annotations.Enabled : true,
Logic.Enabled : true,
Logic.constraints: true,
Logic.calculations: true,
Logic.Handler : [create, update, delete, read]
}
entity Authors as projection on my.Authors;
action renameAuthor(author : Authors:ID, newName : String) returns {
msg : String
};
function getStock(book: Books:ID) returns Integer;
event newBook : {
book : Books:ID;
name : Books:title
};
} }

View File

@@ -1,12 +1,135 @@
import cds from '@sap/cds' const cds = require("@sap/cds")
//const cds_sandbox = require("sap/cds/sandbox")
const { VM, VMScript } = require("vm2")
const fs = require("fs")
const path = require("path")
const { nextTick } = require("process")
export default cds.service.impl (function(){ class AdminService extends cds.ApplicationService {
this.before ('NEW','Authors', genid) init() {
this.before ('NEW','Books', genid) this.after("READ", async (result, req) => {
if (!(result === undefined || result == null)) {
const code = getCode(req.target.name, "READ")
if (code) {
await executeCode.call(this, code, req, result)
}
}
}) })
this.before("CREATE", async (req) => {
const code = getCode(req.target.name, "CREATE")
if (code) {
await executeCode.call(this, code, req)
}
})
this.before("UPDATE", async (req) => {
const code = getCode(req.target.name, "CREATE")
if (code) {
await executeCode.call(this, code, req)
}
})
this.on("*", async (req, next) => {
if (!(req.target === undefined || req.target == null)) return next()
//ToDo: check whether action or event is part of an extension
// DO NOT OVERWRITE EXISTING Action Implementations!
// evaluate: Can we augment action implementation with super.next?
if (req.constructor.name === "EventMessage") {
const code = getCode(req.event, "ON")
if (code) {
await executeCode.call(this, code, req)
}
} else if (req.constructor.name === "ODataRequest") {
var output = {}
const code = getCode(this.name + "." + req.event, "ON")
if (code) {
await executeCode.call(this, code, req, {}, output)
return output
}
}
})
//ToDo: Prefix for Service not in event emitter
this.before("CREATE", "Authors", async (req) => {
let Author = req.data
await this.emit("createdAuthor", { Author })
})
return super.init()
}
}
var counter = 1;
function newLabel() {return "VM2 - req: " + counter++}
//should only work in local exection (cds watch)
// alternative: Upon Bootstrapping, merge files into CSN
function getCodeFromFile(name, operation) {
const filename = name + "." + operation + ".js"
const file = path.join(__dirname, "..", "handlers", filename)
try {
const code = fs.readFileSync(file, "utf8")
return code
} catch (error) {
return ""
}
}
//after push this should be the only thing that works
function getCodeFromAnnotation(name, operation) {
return ""
}
function getCode(name, operation) {
let code=getCodeFromAnnotation(name, operation)
if (code==="") {code=getCodeFromFile(name, operation)}
return code
}
function scanCode(code) {
//ESLINT
}
async function executeCode(code, req, result, output) {
const srv = this
const label=newLabel()
console.time(label)
const vm = new VM({
console: "inherit",
timeout: 500,
allowAsync: true,
sandbox: { req, //todo: isolate req.data, req.reject, req.error, req.message
result, //important for READ
output, //used for Action Implementation
SELECT : (class extends require('@sap/cds/lib/ql/SELECT') {then(r,e) {return srv.run(this).then(r,e)}})._api(),
INSERT : (class extends require('@sap/cds/lib/ql/INSERT') {then(r,e) {return srv.run(this).then(r,e)}})._api(),
UPDATE : (class extends require('@sap/cds/lib/ql/UPDATE') {then(r,e) {return srv.run(this).then(r,e)}})._api(),
CREATE : (class extends require('@sap/cds/lib/ql/CREATE') {then(r,e) {return srv.run(this).then(r,e)}})._api(),
//srv: this,
JSON },
})
try {
await vm.run(code)
return output
} catch (error) {
console.log(error)
req.reject("409", "Error in VM")
}
finally {
console.timeEnd(label)
}
// console.log(req.data)
}
/** Generate primary keys for target entity in request */ /** Generate primary keys for target entity in request */
async function genid(req) { async function genid(req) {
const {ID} = await cds.tx(req).run (SELECT.one.from(req.target).columns('max(ID) as ID')) const { ID } = await cds
req.data.ID = ID - ID % 100 + 100 + 1 .tx(req)
.run(SELECT.one.from(req.target).columns("max(ID) as ID"))
req.data.ID = ID - (ID % 100) + 100 + 1
} }
module.exports = { AdminService }

View File

@@ -10,6 +10,8 @@ service CatalogService @(path:'/browse') {
author.name as author author.name as author
} excluding { createdBy, modifiedBy }; } excluding { createdBy, modifiedBy };
@readonly entity Publishers as projection on my.Publishers;
@requires: 'authenticated-user' @requires: 'authenticated-user'
action submitOrder ( book: Books:ID, quantity: Integer ) returns { stock: Integer }; action submitOrder ( book: Books:ID, quantity: Integer ) returns { stock: Integer };
event OrderedBook : { book: Books:ID; quantity: Integer; buyer: String }; event OrderedBook : { book: Books:ID; quantity: Integer; buyer: String };

View File

@@ -1,8 +1,8 @@
import cds from '@sap/cds' const cds = require('@sap/cds')
export class CatalogService extends cds.ApplicationService { init(){ class CatalogService extends cds.ApplicationService { init(){
const { Books } = this.entities ('sap.capire.bookshop') const { Books } = cds.entities ('sap.capire.bookshop')
// Reduce stock of ordered books if available stock suffices // Reduce stock of ordered books if available stock suffices
this.on ('submitOrder', async req => { this.on ('submitOrder', async req => {
@@ -24,3 +24,5 @@ export class CatalogService extends cds.ApplicationService { init(){
return super.init() return super.init()
}} }}
module.exports = { CatalogService }

View File

@@ -0,0 +1,11 @@
//this file is machine-created during cds.build
namespace sap.capire.bookshop; //> important for reflection
using from '../db/schema';
using from '../srv/cat-service';
using from '../srv/admin-service';
annotate AdminService.Authors with @extension.logic: [{when: 'CREATE', code: 'async function run() {\r\n \/\/debugger\r\n \/\/while (true) {}\r\n \/\/process.exit()\r\n \/\/1.substring()\r\n \/\/ let res = await specialselect\r\n let res = await SELECT.one`title`.from(`Books`).where(`ID=201`)\r\n let { title } = res\r\n let Author = req.data\r\n Author.modifiedBy = \"Custom Event handler changed this!\"\r\n Author.placeOfDeath = \" --- Somewhere over \" + title + \" --- create in Sandbox\"\r\n \/\/await this.emit(\"createdAuthor\", { Author })\r\n return Author\r\n}\r\nrun()\r\n'},
{when: 'READ', code: 'function getYear(v) {\r\n return parseInt(v.substr(0, 4))\r\n}\r\nfunction getMonth(v) {\r\n return parseInt(v.substr(5, 2))\r\n}\r\nfunction getDay(v) {\r\n return parseInt(v.substr(8, 2))\r\n}\r\n\r\nfunction getAge(from, to) {\r\n if (from === undefined || from == null) return 0\r\n if (to === undefined || to == null) to = new Date().toISOString()\r\n let year = getYear(to) - getYear(from) - 1\r\n if (\r\n getMonth(to) > getMonth(from) ||\r\n (getMonth(to) === getMonth(from) && getDay(to) >= getDay(from))\r\n ) {\r\n year++\r\n }\r\n return year\r\n}\r\n\r\nconst result_ = Array.isArray(result) ? result : [result]\r\nfor (const row of result_) {\r\n row.modifiedBy += \" --- read in sandbox\"\r\n row.age = getAge(row.dateOfBirth, row.dateOfDeath)\r\n}'}
];
annotate AdminService.Books with @extension.logic;
annotate CatalogService.ListOfBooks with @extension.logic;

View File

@@ -1,7 +1,9 @@
/** /**
* Exposes user information * Exposes user information
*/ */
@requires: 'authenticated-user'
service UserService { service UserService {
/** /**
* The current user * The current user
*/ */
@@ -11,5 +13,4 @@ service UserService {
tenant : String; tenant : String;
} }
action login() returns me;
} }

View File

@@ -1,10 +1,4 @@
import cds from '@sap/cds' const cds = require('@sap/cds')
module.exports = cds.service.impl((srv) => {
export default class UserService extends cds.Service { init(){ srv.on('READ', 'me', ({ tenant, user, locale }) => ({ id: user.id, locale, tenant }))
this.on('READ', 'me', ({ tenant, user, locale }) => ({ id: user.id, locale, tenant }))
this.on('login', (req) => {
if (req.user._is_anonymous)
req._.res.set('WWW-Authenticate','Basic realm="Users"').sendStatus(401)
else return this.read('me')
}) })
}}

View File

@@ -1,10 +1,46 @@
@server = http://localhost:4004 @server = http://localhost:4004
@me = Authorization: Basic {{$processEnv USER}}: @me = Authorization: Basic {{$processEnv USER}}:
@id = 2000
### ------------------------------------------------------------------------
# Fetch Authors
GET {{server}}/admin/Authors
### ------------------------------------------------------------------------
# Fetch one Author
GET {{server}}/admin/Authors({{id}})
### ------------------------------------------------------------------------
# Create Author
POST {{server}}/admin/Authors
Content-Type: application/json;IEEE754Compatible=true
{
"ID": {{id}},
"name": "Nick",
"placeOfBirth": "Somewhere",
"placeOfDeath": "over the Rainbox",
"dateOfBirth" : "1975-05-27"
}
### ------------------------------------------------------------------------
# rename author via unbound action
POST {{server}}/admin/renameAuthor
Content-Type: application/json
{{me}}
{ "author":{{id}}, "newName":"Super Nick" }
### ------------------------------------------------------------------------ ### ------------------------------------------------------------------------
# Get service info # Get service info
GET {{server}}/browse GET {{server}}/admin
{{me}}
### ------------------------------------------------------------------------
# Get $metadata document
GET {{server}}/admin/$metadata
{{me}} {{me}}
@@ -23,27 +59,12 @@ GET {{server}}/browse/ListOfBooks?
{{me}} {{me}}
### ------------------------------------------------------------------------
# Fetch Authors as admin
GET {{server}}/admin/Authors?
# &$select=name,dateOfBirth,placeOfBirth
# &$expand=books($select=title;$expand=currency)
# &$filter=ID eq 101
# &sap-language=de
Authorization: Basic alice:
### ------------------------------------------------------------------------ ### ------------------------------------------------------------------------
# Create Author # Fetch Books as admin
POST {{server}}/admin/Authors GET {{server}}/admin/Books
Content-Type: application/json;IEEE754Compatible=true
Authorization: Basic alice:
{
"ID": 112,
"name": "Shakespeeeeere",
"age": 22
}
### ------------------------------------------------------------------------ ### ------------------------------------------------------------------------
# Create book # Create book
@@ -52,12 +73,12 @@ Content-Type: application/json;IEEE754Compatible=true
Authorization: Basic alice: Authorization: Basic alice:
{ {
"ID": 2, "ID": 16,
"title": "Poems : Pocket Poets", "title": "Deh4",
"descr": "The Everyman's Library Pocket Poets hardcover series is popular for its compact size and reasonable price which does not compromise content. Poems: Bronte contains poems that demonstrate a sensibility elemental in its force with an imaginative discipline and flexibility of the highest order. Also included are an Editor's Note and an index of first lines.", "descr": "The Everyman's Library Pocket Poets hardcover series is popular for its compact size and reasonable price which does not compromise content. Poems: Bronte contains poems that demonstrate a sensibility elemental in its force with an imaginative discipline and flexibility of the highest order. Also included are an Editor's Note and an index of first lines.",
"author": { "ID": 101 }, "author": { "ID": 101 },
"genre": { "ID": 12 }, "genre": { "ID": 12 },
"stock": 5, "stock": -100,
"price": "12.05", "price": "12.05",
"currency": { "code": "USD" } "currency": { "code": "USD" }
} }

View File

@@ -39,7 +39,7 @@ annotate AdminService.Authors with @(UI : {
// Workaround to avoid errors for unknown db-specific calculated fields above // Workaround to avoid errors for unknown db-specific calculated fields above
extend sap.capire.bookshop.Authors with { extend sap.capire.bookshop.Authors with {
virtual age : Integer; //virtual age : Integer;
virtual lifetime : String; virtual lifetime : String;
} }

View File

@@ -50,6 +50,10 @@
} }
}, },
"sap.ui5": { "sap.ui5": {
"flexEnabled": true,
"config": {
"experimentalCAPScenario": true
},
"dependencies": { "dependencies": {
"minUI5Version": "1.81.0", "minUI5Version": "1.81.0",
"libs": { "libs": {

View File

@@ -22,6 +22,10 @@
} }
}, },
"sap.ui5": { "sap.ui5": {
"flexEnabled": true,
"config": {
"experimentalCAPScenario": true
},
"dependencies": { "dependencies": {
"libs": { "libs": {
"sap.fe.templates": {} "sap.fe.templates": {}

View File

@@ -53,6 +53,10 @@
} }
}, },
"sap.ui5": { "sap.ui5": {
"flexEnabled": true,
"config": {
"experimentalCAPScenario": true
},
"dependencies": { "dependencies": {
"minUI5Version": "1.81.0", "minUI5Version": "1.81.0",
"libs": { "libs": {

View File

@@ -10,7 +10,21 @@
<script> <script>
window["sap-ushell-config"] = { window["sap-ushell-config"] = {
defaultRenderer: "fiori2", defaultRenderer: "fiori2",
applications: {} applications: {},
bootstrapPlugins: {
RuntimeAuthoringPlugin: {
component: "sap.ushell.plugins.rta",
config: {
validateAppVersion: false,
},
},
PersonalizePlugin: {
component: "sap.ushell.plugins.rta-personalize",
config: {
validateAppVersion: false,
},
},
}
}; };
</script> </script>
@@ -22,7 +36,11 @@
data-sap-ui-frameOptions="allow" data-sap-ui-frameOptions="allow"
></script> ></script>
<script> <script>
sap.ui.getCore().attachInit(()=> sap.ushell.Container.createRenderer().placeAt("content")) sap.ui.getCore().attachInit(()=> sap.ushell.Container.createRenderer().placeAt("content"));
sap.ui
.getCore()
.getConfiguration()
.setFlexibilityServices([{ connector: "SessionStorageConnector" }]);
</script> </script>
</head> </head>

View File

@@ -36,7 +36,10 @@
} }
}, },
"db": { "db": {
"kind": "sql" "kind": "sqlite",
"credentials": {
"database": "sqlite.db"
}
}, },
"db-ext": { "db-ext": {
"[development]": { "[development]": {

10594
package-lock.json generated

File diff suppressed because it is too large Load Diff