diff --git a/.eslintrc b/.eslintrc index da867678..40fe0cb5 100644 --- a/.eslintrc +++ b/.eslintrc @@ -21,6 +21,7 @@ }, "rules": { "no-console": "off", - "require-atomic-updates": "off" + "require-atomic-updates": "off", + "require-await":"warn" } } diff --git a/bookshop/srv/cat-service.cds b/bookshop/srv/cat-service.cds index 606eb05a..f6fb00cd 100644 --- a/bookshop/srv/cat-service.cds +++ b/bookshop/srv/cat-service.cds @@ -1,12 +1,12 @@ using { sap.capire.bookshop as my } from '../db/schema'; service CatalogService @(path:'/browse') { - @readonly entity Books as SELECT from my.Books {*, + @readonly entity Books as SELECT from my.Books { *, author.name as author } excluding { createdBy, modifiedBy }; @readonly entity ListOfBooks as SELECT from Books - excluding { descr, stock }; + excluding { descr }; @requires: 'authenticated-user' action submitOrder ( book: Books:ID, amount: Integer ) returns { stock: Integer }; diff --git a/common/package.json b/common/package.json index d5c6dc24..c1998c24 100644 --- a/common/package.json +++ b/common/package.json @@ -1,4 +1,8 @@ { "name": "@capire/common", - "version": "1.0.0" + "description": "Provides a pre-built extension package for std @sap/cds/common", + "version": "1.0.0", + "dependencies": { + "@sap/cds": "latest" + } } diff --git a/fiori/srv/mashup.js b/fiori/srv/mashup.js index a5a1668f..8f68c9ef 100644 --- a/fiori/srv/mashup.js +++ b/fiori/srv/mashup.js @@ -48,7 +48,7 @@ module.exports = async()=>{ // called by server.js // // Reduce stock of ordered books for orders are created from Orders admin UI // - OrdersService.on ('OrderChanged', async (msg) => { + OrdersService.on ('OrderChanged', (msg) => { console.debug ('> received:', msg.event, msg.data) const { product, deltaAmount } = msg.data return UPDATE (Books) .where ('ID =', product) diff --git a/orders/srv/orders-service.js b/orders/srv/orders-service.js index 3c2c65d3..c4a8e825 100644 --- a/orders/srv/orders-service.js +++ b/orders/srv/orders-service.js @@ -16,7 +16,7 @@ class OrdersService extends cds.ApplicationService { this.before ('DELETE', 'Orders', async function(req) { const { ID } = req.data const Items = await SELECT.from (OrderItems, oi => { oi.product_ID, oi.amount }) .where ({up__ID:ID}) - if (Items) for (let it of Items) this.orderChanged (it.product_ID, -it.amount) + if (Items) await Promise.all (Items.map(it => this.orderChanged (it.product_ID, -it.amount))) }) return super.init() diff --git a/reviews/app/vue/app.js b/reviews/app/vue/app.js index fb115d68..b46a4892 100644 --- a/reviews/app/vue/app.js +++ b/reviews/app/vue/app.js @@ -37,7 +37,7 @@ const reviews = new Vue ({ reviews.message = {} }, - async newReview () { + newReview () { reviews.review = {} reviews.message = {} setTimeout (()=> $('form > input').focus(), 111) diff --git a/reviews/srv/reviews-service.js b/reviews/srv/reviews-service.js index cf9e03ce..0edbf187 100644 --- a/reviews/srv/reviews-service.js +++ b/reviews/srv/reviews-service.js @@ -14,7 +14,7 @@ module.exports = cds.service.impl (function(){ const {subject} = req.data const {rating} = await SELECT.one (['round(avg(rating),2) as rating']) .from (Reviews) .where ({subject}) global.it || console.log ('< emitting:', 'reviewed', { subject, rating }) - this.emit ('reviewed', { subject, rating }) + await this.emit ('reviewed', { subject, rating }) }) // Increment counter for reviews considered helpful