@sap/cds-dk 9.2.1 → 9.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/bin/bind.js +5 -8
- package/bin/up.js +12 -8
- package/lib/bind/cf.js +4 -0
- package/lib/bind/k8s.js +21 -0
- package/lib/bind/plugin.js +9 -0
- package/lib/build/buildTaskProviderFactory.js +8 -14
- package/lib/build/constants.js +1 -0
- package/lib/build/index.js +17 -2
- package/lib/build/plugin.js +5 -7
- package/lib/build/provider/hana/index.js +4 -4
- package/lib/env/schemas/cds-rc.js +2 -2
- package/lib/init/constants.js +3 -2
- package/lib/init/projectReader.js +2 -4
- package/lib/init/template/ams/index.js +1 -2
- package/lib/init/template/approuter/files/containerize.yaml.hbs +1 -1
- package/lib/init/template/approuter/index.js +1 -1
- package/lib/init/template/extension/files/.base/index.cds +6 -6
- package/lib/init/template/extension/index.js +5 -5
- package/lib/init/template/github-actions/files/{cf-github-deploy → github-deployment}/action.yaml +7 -5
- package/lib/init/template/github-actions/files/kyma-info/action.yaml +1 -1
- package/lib/init/template/github-actions/files/workflows/cf.yaml.hbs +10 -7
- package/lib/init/template/github-actions/files/workflows/kyma.yaml.hbs +6 -3
- package/lib/init/template/github-actions/files/workflows/test.yaml.hbs +5 -2
- package/lib/init/template/github-actions/index.js +8 -9
- package/lib/init/template/hana/index.js +2 -1
- package/lib/init/template/html5-repo/files/mta.yaml.hbs +5 -1
- package/lib/init/template/html5-repo/files/package.json.hbs +1 -1
- package/lib/init/template/html5-repo/index.js +24 -19
- package/lib/init/template/ias/files/mta.yaml.hbs +4 -3
- package/lib/init/template/ias/files/values.yaml.hbs +41 -40
- package/lib/init/template/mta/files/package.json +1 -1
- package/lib/init/template/nodejs/files/.vscode/extensions.json +0 -1
- package/lib/init/template/nodejs/files/package.json.hbs +3 -9
- package/lib/init/template/portal/files/mta.yaml.hbs +5 -1
- package/lib/init/template/portal/index.js +0 -1
- package/lib/init/template/sample/files/app/_i18n/i18n.properties +15 -0
- package/lib/init/template/sample/files/app/_i18n/i18n_de.properties +15 -0
- package/lib/init/template/sample/files/app/admin-books/fiori-service.cds +14 -15
- package/lib/init/template/sample/files/app/browse/fiori-service.cds +44 -44
- package/lib/init/template/sample/files/app/common.cds +99 -84
- package/lib/init/template/sample/files/db/schema.cds +22 -17
- package/lib/init/template/sample/files/package.json.hbs +1 -3
- package/lib/init/template/sample/files/srv/admin-service.cds +4 -3
- package/lib/init/template/sample/files/srv/cat-service.cds +28 -11
- package/lib/init/template/tiny-sample/files/nodejs/db/schema.cds +3 -3
- package/lib/init/template/typescript/files/package.json +1 -1
- package/lib/init/template/ui5/index.js +22 -0
- package/lib/lint/eslintHelp.json +5 -3
- package/npm-shrinkwrap.json +13 -13
- package/package.json +1 -1
- package/lib/init/template/sample/files/javascript/admin-service.js.hbs +0 -24
- package/lib/init/template/sample/files/javascript/cat-service.js.hbs +0 -43
- package/lib/init/template/sample/files/typescript/admin-service.ts.hbs +0 -16
- package/lib/init/template/sample/files/typescript/cat-service.ts.hbs +0 -38
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import cds from '@sap/cds'
|
|
2
|
-
|
|
3
|
-
import { Books } from '#cds-models/AdminService'
|
|
4
|
-
|
|
5
|
-
export class AdminService extends cds.ApplicationService { async init() {
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Generate primary keys for target entity in request
|
|
9
|
-
*/
|
|
10
|
-
this.before ('NEW', Books.drafts, async req => {
|
|
11
|
-
if (req.data.ID) return
|
|
12
|
-
const { ID } = await SELECT.one.from(Books).columns('max(ID) as ID') ?? { ID: 0 }
|
|
13
|
-
req.data.ID = ID! - ID! % 100 + 100 + 1
|
|
14
|
-
})
|
|
15
|
-
return super.init()
|
|
16
|
-
}}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import cds from '@sap/cds'
|
|
2
|
-
|
|
3
|
-
import { Books } from '#cds-models/sap/capire/bookshop'
|
|
4
|
-
import { submitOrder, OrderedBook, ListOfBooks } from '#cds-models/CatalogService'
|
|
5
|
-
|
|
6
|
-
export class CatalogService extends cds.ApplicationService { async init() {
|
|
7
|
-
|
|
8
|
-
// Add some discount for overstocked books
|
|
9
|
-
this.after('each', ListOfBooks, book => {
|
|
10
|
-
if (book?.stock === undefined || book.stock === null) return
|
|
11
|
-
if (book?.stock > 111) book.title += ` -- 11% discount!`
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
// Reduce stock of ordered books if available stock suffices
|
|
15
|
-
this.on(submitOrder, async req => {
|
|
16
|
-
let { book:id, quantity } = req.data
|
|
17
|
-
if(!id) return req.error (400, `Book ID missing`) // FIXED
|
|
18
|
-
let book = await SELECT.from (Books, id, b => b.stock)
|
|
19
|
-
|
|
20
|
-
// Validate input data
|
|
21
|
-
if (!book) return req.error (404, `Book #${id} doesn't exist`)
|
|
22
|
-
if (!quantity || quantity < 1) return req.error (400, `quantity has to be 1 or more`)
|
|
23
|
-
if (quantity > book.stock!) return req.error (409, `${quantity} exceeds stock for book #${id}`)
|
|
24
|
-
|
|
25
|
-
// Reduce stock in database and return updated stock value
|
|
26
|
-
await UPDATE (Books, id) .with ({ stock: book.stock! -= quantity })
|
|
27
|
-
return book
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
// Emit event when an order has been submitted
|
|
31
|
-
this.after(submitOrder, async (_,req) => {
|
|
32
|
-
let { book, quantity } = req.data
|
|
33
|
-
await this.emit(OrderedBook, { book, quantity, buyer: req.user.id })
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
// Delegate requests to the underlying generic service
|
|
37
|
-
return super.init()
|
|
38
|
-
}}
|