Compare commits
58 Commits
ESM
...
reproduce-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73f438d3c0 | ||
|
|
fd770b4a91 | ||
|
|
8eb42d1f98 | ||
|
|
4d3cd6be90 | ||
|
|
4f505e4cfe | ||
|
|
e23b04fffd | ||
|
|
0fb8dfd5c2 | ||
|
|
8d01b05034 | ||
|
|
809b96bc96 | ||
|
|
41a9e494ce | ||
|
|
c4432d8dd7 | ||
|
|
167a39790f | ||
|
|
8acd671f57 | ||
|
|
5d7af63ec1 | ||
|
|
ee1c30d464 | ||
|
|
8988bc8bc6 | ||
|
|
2e0945a10b | ||
|
|
38e19a0cc3 | ||
|
|
0e9d900d49 | ||
|
|
687c789ed5 | ||
|
|
41e431a119 | ||
|
|
c4515bef51 | ||
|
|
43d3512627 | ||
|
|
cf956bfc45 | ||
|
|
3a5a177796 | ||
|
|
8b10d8e054 | ||
|
|
ea42ad6ab3 | ||
|
|
8bef766860 | ||
|
|
ba1a8dd989 | ||
|
|
0364cf68bb | ||
|
|
ab500b36a8 | ||
|
|
708539fc21 | ||
|
|
816057f005 | ||
|
|
6f523089cd | ||
|
|
a3af15bc4f | ||
|
|
d4133e7def | ||
|
|
bb8cfd31c4 | ||
|
|
a0b1fa6df4 | ||
|
|
143c72a5e1 | ||
|
|
4c3c49260a | ||
|
|
ed788d4834 | ||
|
|
675e966c4b | ||
|
|
8228800c80 | ||
|
|
d5424f100d | ||
|
|
e186237100 | ||
|
|
27800aa2b1 | ||
|
|
d0b0a954bd | ||
|
|
e3c639763b | ||
|
|
d24e44e8f0 | ||
|
|
b5cc148499 | ||
|
|
283660aff3 | ||
|
|
06d605518d | ||
|
|
aad19ab2c9 | ||
|
|
5ffbd2b330 | ||
|
|
e08e5e0d3d | ||
|
|
f2bcc6c021 | ||
|
|
cf1ff4d61f | ||
|
|
2144e09c47 |
11
.github/dependabot.yml
vendored
11
.github/dependabot.yml
vendored
@@ -5,4 +5,13 @@ updates:
|
||||
directory: /
|
||||
versioning-strategy: increase-if-necessary
|
||||
schedule:
|
||||
interval: daily
|
||||
interval: weekly
|
||||
groups:
|
||||
production-dependencies:
|
||||
dependency-type: "production"
|
||||
development-dependencies:
|
||||
dependency-type: "development"
|
||||
ignore:
|
||||
- dependency-name: "chai"
|
||||
# chai 5 doesn't work atm w/ cds.test, TODO fix that in cds.test
|
||||
versions: ["5.x"]
|
||||
|
||||
4
.vscode/extensions.json
vendored
4
.vscode/extensions.json
vendored
@@ -4,13 +4,11 @@
|
||||
|
||||
// List of extensions which should be recommended for users of this workspace.
|
||||
"recommendations": [
|
||||
"qwtel.sqlite-viewer",
|
||||
"sapse.vscode-cds",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"esbenp.prettier-vscode",
|
||||
"mechatroner.rainbow-csv",
|
||||
"humao.rest-client",
|
||||
"alexcvzz.vscode-sqlite",
|
||||
"hbenl.vscode-mocha-test-adapter",
|
||||
"sdras.night-owl",
|
||||
"vsls-contrib.codetour"
|
||||
],
|
||||
|
||||
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@@ -14,8 +14,6 @@
|
||||
"**/odata-v4/okra/**"
|
||||
]
|
||||
},
|
||||
"mochaExplorer.debuggerConfig": "Debug Mocha Tests",
|
||||
"mochaExplorer.parallel": true,
|
||||
"eslint.probe": [
|
||||
"cds",
|
||||
"csn",
|
||||
|
||||
@@ -14,8 +14,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@sap/cds": "^7",
|
||||
"express": "^4.17.1",
|
||||
"passport": ">=0.4.1"
|
||||
"express": "^4.17.1"
|
||||
},
|
||||
"scripts": {
|
||||
"genres": "cds serve test/genres.cds",
|
||||
|
||||
@@ -1,29 +1,34 @@
|
||||
const cds = require('@sap/cds')
|
||||
module.exports = class CatalogService extends cds.ApplicationService { init() {
|
||||
|
||||
class CatalogService extends cds.ApplicationService { init(){
|
||||
|
||||
const { Books } = cds.entities ('sap.capire.bookshop')
|
||||
const { Books } = cds.entities('sap.capire.bookshop')
|
||||
const { ListOfBooks } = this.entities
|
||||
|
||||
// Reduce stock of ordered books if available stock suffices
|
||||
this.on ('submitOrder', async req => {
|
||||
const {book,quantity} = req.data
|
||||
if (quantity < 1) return req.reject (400,`quantity has to be 1 or more`)
|
||||
let b = await SELECT `stock` .from (Books,book)
|
||||
if (!b) return req.error (404,`Book #${book} doesn't exist`)
|
||||
let {stock} = b
|
||||
if (quantity > stock) return req.reject (409,`${quantity} exceeds stock for book #${book}`)
|
||||
await UPDATE (Books,book) .with ({ stock: stock -= quantity })
|
||||
await this.emit ('OrderedBook', { book, quantity, buyer:req.user.id })
|
||||
return { stock }
|
||||
})
|
||||
|
||||
// Add some discount for overstocked books
|
||||
this.after ('READ', ListOfBooks, each => {
|
||||
this.after('READ', ListOfBooks, each => {
|
||||
if (each.stock > 111) each.title += ` -- 11% discount!`
|
||||
})
|
||||
|
||||
// Reduce stock of ordered books if available stock suffices
|
||||
this.on('submitOrder', async req => {
|
||||
let { book:id, quantity } = req.data
|
||||
let book = await SELECT.from (Books, id, b => b.stock)
|
||||
|
||||
// Validate input data
|
||||
if (!book) return req.error (404, `Book #${id} doesn't exist`)
|
||||
if (quantity < 1) return req.error (400, `quantity has to be 1 or more`)
|
||||
if (quantity > book.stock) return req.error (409, `${quantity} exceeds stock for book #${id}`)
|
||||
|
||||
// Reduce stock in database and return updated stock value
|
||||
await UPDATE (Books, id) .with ({ stock: book.stock -= quantity })
|
||||
return book
|
||||
})
|
||||
|
||||
// Emit event when an order has been submitted
|
||||
this.after('submitOrder', async (_,req) => {
|
||||
let { book, quantity } = req.data
|
||||
await this.emit('OrderedBook', { book, quantity, buyer: req.user.id })
|
||||
})
|
||||
|
||||
// Delegate requests to the underlying generic service
|
||||
return super.init()
|
||||
}}
|
||||
|
||||
module.exports = { CatalogService }
|
||||
|
||||
@@ -10,12 +10,22 @@
|
||||
//
|
||||
using { sap.capire.bookshop.Books } from '@capire/bookshop';
|
||||
using { ReviewsService.Reviews } from '@capire/reviews';
|
||||
using { managed, cuid } from '@sap/cds/common';
|
||||
|
||||
extend Books with {
|
||||
reviews : Composition of many Reviews on reviews.subject = $self.ID;
|
||||
rating : type of Reviews:rating; // average rating
|
||||
numberOfReviews : Integer @title : '{i18n>NumberOfReviews}';
|
||||
Y_characteristics : Composition of many Y_Characteristic on Y_characteristics.parent = $self;
|
||||
}
|
||||
|
||||
entity Y_Characteristic : cuid, managed {
|
||||
parent : Association to one Books;
|
||||
characteristicId : String;
|
||||
name : String;
|
||||
value : String;
|
||||
uom : String;
|
||||
}
|
||||
|
||||
//
|
||||
// Extend Orders with Books as Products
|
||||
|
||||
@@ -79,3 +79,36 @@ Authorization: Basic alice:
|
||||
"dateOfBirth": "1564-04-26",
|
||||
"dateOfDeath": "1616-04-23"
|
||||
}
|
||||
|
||||
### Create book
|
||||
POST {{bookshop}}/admin/Books
|
||||
Content-Type: application/json
|
||||
Authorization: Basic alice:
|
||||
|
||||
{
|
||||
"ID": 291,
|
||||
"title": "Ttile1",
|
||||
"author_ID": 107,
|
||||
"numberOfReviews": 3,
|
||||
"Y_characteristics": [{
|
||||
"ID": "e326afd9-4688-4bf5-9664-783ff997cdf5",
|
||||
"characteristicId": "myid",
|
||||
"name": "myname"
|
||||
}]
|
||||
}
|
||||
|
||||
### Update book
|
||||
PUT {{bookshop}}/admin/Books(291)
|
||||
Content-Type: application/json
|
||||
Authorization: Basic alice:
|
||||
|
||||
{
|
||||
"title": "Ttile111111111",
|
||||
"author_ID": 107,
|
||||
"numberOfReviews": 4,
|
||||
"Y_characteristics": [{
|
||||
"ID": "e326afd9-4688-4bf5-9664-783ff997cdf5",
|
||||
"characteristicId": "myid123",
|
||||
"name": "myname123"
|
||||
}]
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
# __ldi.translation.uuid=c3431418-9caf-11e8-98d0-529269fb1459
|
||||
|
||||
# JCI app descriptor contains lower case TITLE
|
||||
appTitle=Bookshop Authors
|
||||
appTitle=Manage Authors
|
||||
|
||||
# JCI app descriptor contains lower case DESCRIPTION
|
||||
appSubTitle=Bookshop Authors
|
||||
appSubTitle=CAP Sample Application
|
||||
|
||||
# JCI app descriptor contains lower case DESCRIPTION
|
||||
appDescription=Bookshop Authors
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
"additionalParameters": "ignored"
|
||||
},
|
||||
"semanticObject": "Authors",
|
||||
"action": "display",
|
||||
"action": "manage",
|
||||
"title": "{{appTitle}}",
|
||||
"info": "{{appInfo}}",
|
||||
"subTitle": "{{appSubTitle}}",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# __ldi.translation.uuid=c3431418-9caf-11e8-98d0-529269fb1459
|
||||
|
||||
# JCI app descriptor contains lower case TITLE
|
||||
appTitle=Bookshop Sample
|
||||
appTitle=Manage Books
|
||||
|
||||
# JCI app descriptor contains lower case DESCRIPTION
|
||||
appSubTitle=CAP Sample Application
|
||||
|
||||
@@ -19,6 +19,22 @@
|
||||
"id": "ui5template.basicSAPUI5ApplicationProject",
|
||||
"-id": "ui5template.smartTemplate",
|
||||
"-version": "1.40.12"
|
||||
},
|
||||
"crossNavigation": {
|
||||
"inbounds": {
|
||||
"intent1": {
|
||||
"signature": {
|
||||
"parameters": {},
|
||||
"additionalParameters": "allowed"
|
||||
},
|
||||
"semanticObject": "Books",
|
||||
"action": "manage",
|
||||
"title": "{{appTitle}}",
|
||||
"info": "{{appInfo}}",
|
||||
"subTitle": "{{appSubTitle}}",
|
||||
"icon": "sap-icon://course-book"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"sap.ui5": {
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
"tileType": "sap.ushell.ui.tile.StaticTile",
|
||||
"properties": {
|
||||
"title": "Manage Authors",
|
||||
"targetURL": "#Authors-display"
|
||||
"targetURL": "#Authors-manage"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -99,7 +99,7 @@
|
||||
},
|
||||
"BrowseAuthors": {
|
||||
"semanticObject": "Authors",
|
||||
"action": "display",
|
||||
"action": "manage",
|
||||
"title": "Browse Authors",
|
||||
"signature": {
|
||||
"parameters": {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# __ldi.translation.uuid=c3431418-9caf-11e8-98d0-529269fb1459
|
||||
|
||||
# JCI app descriptor contains lower case TITLE
|
||||
appTitle=Bookshop Sample
|
||||
appTitle=Browse Books
|
||||
|
||||
# JCI app descriptor contains lower case DESCRIPTION
|
||||
appSubTitle=CAP Sample Application
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
"@capire/bookstore": "*",
|
||||
"@sap/cds": ">=5",
|
||||
"@cap-js-community/odata-v2-adapter": "^1",
|
||||
"express": "^4.17.1",
|
||||
"passport": ">=0.4.1"
|
||||
"express": "^4.17.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cap-js/sqlite": "^1"
|
||||
@@ -51,5 +50,10 @@
|
||||
"hana": {
|
||||
"deploy-format": "hdbtable"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sapux": [
|
||||
"app/admin-authors",
|
||||
"app/admin-books",
|
||||
"app/browse"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# __ldi.translation.uuid=c3431418-9caf-11e8-98d0-529269fb1459
|
||||
|
||||
# JCI app descriptor contains lower case TITLE
|
||||
appTitle=Bookshop Sample
|
||||
appTitle=Manage Orders
|
||||
|
||||
# JCI app descriptor contains lower case DESCRIPTION
|
||||
appSubTitle=CAP Sample Application
|
||||
|
||||
260
package-lock.json
generated
260
package-lock.json
generated
@@ -38,8 +38,7 @@
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@sap/cds": "^7",
|
||||
"express": "^4.17.1",
|
||||
"passport": ">=0.4.1"
|
||||
"express": "^4.17.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cap-js/sqlite": "*"
|
||||
@@ -79,8 +78,7 @@
|
||||
"@cap-js-community/odata-v2-adapter": "^1",
|
||||
"@capire/bookstore": "*",
|
||||
"@sap/cds": ">=5",
|
||||
"express": "^4.17.1",
|
||||
"passport": ">=0.4.1"
|
||||
"express": "^4.17.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cap-js/sqlite": "^1"
|
||||
@@ -302,100 +300,57 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@cap-js-community/odata-v2-adapter": {
|
||||
"version": "1.11.8",
|
||||
"resolved": "https://registry.npmjs.org/@cap-js-community/odata-v2-adapter/-/odata-v2-adapter-1.11.8.tgz",
|
||||
"integrity": "sha512-AqIQKmxoVhmYw3EqCyIJfzXCYK0o1BULN3LAHuNNfyobNNZe5YHPv11k29ZIR+y6+/1ce4r4E1rLNcpNx2npRw==",
|
||||
"version": "1.12.6",
|
||||
"resolved": "https://registry.npmjs.org/@cap-js-community/odata-v2-adapter/-/odata-v2-adapter-1.12.6.tgz",
|
||||
"integrity": "sha512-jYlHSbUhWdv7AKJ6FQFtsvEP7KC1f5RZ0DisbKBH39klSxl7LELOpSe6VMDPxtVfAm7s5EVgONao30n1xRlhig==",
|
||||
"dependencies": {
|
||||
"body-parser": "^1.20.2",
|
||||
"body-parser-xml": "^2.0.5",
|
||||
"express": "^4.18.2",
|
||||
"express-fileupload": "^1.4.1",
|
||||
"express": "^4.18.3",
|
||||
"express-fileupload": "^1.4.3",
|
||||
"http-proxy-middleware": "^2.0.6",
|
||||
"node-fetch": "^2.7.0",
|
||||
"xml2js": "^0.6.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@cap-js-community/odata-v2-adapter/node_modules/body-parser": {
|
||||
"version": "1.20.2",
|
||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz",
|
||||
"integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==",
|
||||
"dependencies": {
|
||||
"bytes": "3.1.2",
|
||||
"content-type": "~1.0.5",
|
||||
"debug": "2.6.9",
|
||||
"depd": "2.0.0",
|
||||
"destroy": "1.2.0",
|
||||
"http-errors": "2.0.0",
|
||||
"iconv-lite": "0.4.24",
|
||||
"on-finished": "2.4.1",
|
||||
"qs": "6.11.0",
|
||||
"raw-body": "2.5.2",
|
||||
"type-is": "~1.6.18",
|
||||
"unpipe": "1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8",
|
||||
"npm": "1.2.8000 || >= 1.4.16"
|
||||
}
|
||||
},
|
||||
"node_modules/@cap-js-community/odata-v2-adapter/node_modules/debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
|
||||
"dependencies": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@cap-js-community/odata-v2-adapter/node_modules/ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
|
||||
},
|
||||
"node_modules/@cap-js-community/odata-v2-adapter/node_modules/raw-body": {
|
||||
"version": "2.5.2",
|
||||
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz",
|
||||
"integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==",
|
||||
"dependencies": {
|
||||
"bytes": "3.1.2",
|
||||
"http-errors": "2.0.0",
|
||||
"iconv-lite": "0.4.24",
|
||||
"unpipe": "1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
"node_modules/@cap-js/cds-types": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@cap-js/cds-types/-/cds-types-0.1.0.tgz",
|
||||
"integrity": "sha512-aGIq8m3Ni2ScQtZWK4Rc/TnBJ4LjN4tdSmUatwUA5PSlCua8prheuDJ/k1xRL1F61Rsw0i6G5mZ2HbF2f2dbpA==",
|
||||
"peerDependencies": {
|
||||
"@sap/cds": ">=7"
|
||||
}
|
||||
},
|
||||
"node_modules/@cap-js/db-service": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@cap-js/db-service/-/db-service-1.3.2.tgz",
|
||||
"integrity": "sha512-EEwsEOM4ragtQdAuApjT77xhJac28EszCsH0/9yg1EYoCZMWk2n+hwWTk9yMnXGDZmmiKc6uScq8DetgyPvaGg==",
|
||||
"version": "1.6.1",
|
||||
"resolved": "https://registry.npmjs.org/@cap-js/db-service/-/db-service-1.6.1.tgz",
|
||||
"integrity": "sha512-tIYX1iiCmfSOIJ7au3ynfsh28/ZEFwgsBSXUOuhVAhmBPX9wgVF6BQ+XP4Qh7ktPt7woh1eoY9EqPYA1LTxwYQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=16",
|
||||
"npm": ">=8"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@sap/cds": ">=7.1.1"
|
||||
"@sap/cds": ">=7.6"
|
||||
}
|
||||
},
|
||||
"node_modules/@cap-js/sqlite": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@cap-js/sqlite/-/sqlite-1.3.1.tgz",
|
||||
"integrity": "sha512-eNJu8X6XzAy7zZUzD4r0EJ/B1upDlLotiCe3qoc+3GHwkYEXcZl2CIUNRyqIuJ6KGoBgbAA1l9iCExaZUX32uA==",
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@cap-js/sqlite/-/sqlite-1.5.1.tgz",
|
||||
"integrity": "sha512-nNo1FSMs+4mqhjWt4f3gdSrEOjkQ6/acmymPP1eHf1l49HdDj50JKatDcHuLdal1lr4gVmcMv9zwpRge0OH/4w==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@cap-js/db-service": "^1.3.1",
|
||||
"better-sqlite3": "^8"
|
||||
"@cap-js/db-service": "^1.6.0",
|
||||
"better-sqlite3": "^9.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16",
|
||||
"npm": ">=8"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@sap/cds": ">=7"
|
||||
"@sap/cds": ">=7.6"
|
||||
}
|
||||
},
|
||||
"node_modules/@capire/bookshop": {
|
||||
@@ -614,10 +569,11 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@sap/cds": {
|
||||
"version": "7.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@sap/cds/-/cds-7.4.0.tgz",
|
||||
"integrity": "sha512-bw+XokdzKfP6llyqf/pBsyZqqpwnn7JEFcwXfdVI+dtrXkW47qXPdxWS/CIzWOexuCM5mvkzl1vM/hVOeqMxwQ==",
|
||||
"version": "7.7.0",
|
||||
"resolved": "https://registry.npmjs.org/@sap/cds/-/cds-7.7.0.tgz",
|
||||
"integrity": "sha512-5+Yjn1WDlaycLQ1FlsMn6DGgf+U6/qpBT+Dq0B7RXlwPXtginjVMtPwf1gtf5GAUCt1QwSMekeYhVR9ukj1JnQ==",
|
||||
"dependencies": {
|
||||
"@cap-js/cds-types": "<1",
|
||||
"@sap/cds-compiler": "^4",
|
||||
"@sap/cds-fiori": "^1",
|
||||
"@sap/cds-foss": "^5.0.0"
|
||||
@@ -670,9 +626,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@sap/eslint-plugin-cds": {
|
||||
"version": "2.6.4",
|
||||
"resolved": "https://registry.npmjs.org/@sap/eslint-plugin-cds/-/eslint-plugin-cds-2.6.4.tgz",
|
||||
"integrity": "sha512-JOPv9UbqRYo0Ybl2bqrRWMr4VNlRb5RQZwAZzUB3vznpPZv9/YxpZLFqmqRIQntGXr+Ki1sRiwKIZjKpieh5Kw==",
|
||||
"version": "2.6.5",
|
||||
"resolved": "https://registry.npmjs.org/@sap/eslint-plugin-cds/-/eslint-plugin-cds-2.6.5.tgz",
|
||||
"integrity": "sha512-Opymu1yYubhkCoE8FoFNECZd5rl5DsPseVXJzOE7zQ04hh5AtyL0sWHtFUoDyvblCmSUTbaKcA8Zj1e1R2Ahqw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@sap/cds": ">=5.6.0",
|
||||
@@ -724,9 +680,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@types/jest": {
|
||||
"version": "29.5.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.8.tgz",
|
||||
"integrity": "sha512-fXEFTxMV2Co8ZF5aYFJv+YeA08RTYJfhtN5c9JSv/mFEMe+xxjufCb+PHL+bJcMs/ebPUsBu+UNTEz+ydXrR6g==",
|
||||
"version": "29.5.12",
|
||||
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.12.tgz",
|
||||
"integrity": "sha512-eDC8bTvT/QhYdxJAulQikueigY5AsdBRH2yDKW3yveW7svY3+DzN84/2NUgkw10RTiJbWqZrTtoGVdYlvFJdLw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"expect": "^29.0.0",
|
||||
@@ -734,9 +690,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "20.9.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.9.1.tgz",
|
||||
"integrity": "sha512-HhmzZh5LSJNS5O8jQKpJ/3ZcrrlG6L70hpGqMIAoM9YVD0YBRNWYsfwcXq8VnSjlNpCpgLzMXdiPo+dxcvSmiA==",
|
||||
"version": "20.11.24",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.24.tgz",
|
||||
"integrity": "sha512-Kza43ewS3xoLgCEpQrsT+xRo/EJej1y0kVYGiLFE1NEODXGzTfwiC6tXTLMQskn1X4/Rjlh0MQUvx9W+L9long==",
|
||||
"dependencies": {
|
||||
"undici-types": "~5.26.4"
|
||||
}
|
||||
@@ -882,12 +838,12 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/axios": {
|
||||
"version": "1.6.2",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz",
|
||||
"integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==",
|
||||
"version": "1.6.7",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.6.7.tgz",
|
||||
"integrity": "sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.15.0",
|
||||
"follow-redirects": "^1.15.4",
|
||||
"form-data": "^4.0.0",
|
||||
"proxy-from-env": "^1.1.0"
|
||||
}
|
||||
@@ -920,9 +876,9 @@
|
||||
]
|
||||
},
|
||||
"node_modules/better-sqlite3": {
|
||||
"version": "8.7.0",
|
||||
"resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-8.7.0.tgz",
|
||||
"integrity": "sha512-99jZU4le+f3G6aIl6PmmV0cxUIWqKieHxsiF7G34CVFiE+/UabpYqkU0NJIkY/96mQKikHeBjtR27vFfs5JpEw==",
|
||||
"version": "9.4.0",
|
||||
"resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-9.4.0.tgz",
|
||||
"integrity": "sha512-5kynxekMxSjCMiFyUBLHggFcJkCmiZi6fUkiGz/B5GZOvdRWQJD0klqCx5/Y+bm2AKP7I/DHbSFx26AxjruWNg==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
@@ -963,12 +919,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/body-parser": {
|
||||
"version": "1.20.1",
|
||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz",
|
||||
"integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==",
|
||||
"version": "1.20.2",
|
||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz",
|
||||
"integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==",
|
||||
"dependencies": {
|
||||
"bytes": "3.1.2",
|
||||
"content-type": "~1.0.4",
|
||||
"content-type": "~1.0.5",
|
||||
"debug": "2.6.9",
|
||||
"depd": "2.0.0",
|
||||
"destroy": "1.2.0",
|
||||
@@ -976,7 +932,7 @@
|
||||
"iconv-lite": "0.4.24",
|
||||
"on-finished": "2.4.1",
|
||||
"qs": "6.11.0",
|
||||
"raw-body": "2.5.1",
|
||||
"raw-body": "2.5.2",
|
||||
"type-is": "~1.6.18",
|
||||
"unpipe": "1.0.0"
|
||||
},
|
||||
@@ -1118,9 +1074,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/chai": {
|
||||
"version": "4.3.10",
|
||||
"resolved": "https://registry.npmjs.org/chai/-/chai-4.3.10.tgz",
|
||||
"integrity": "sha512-0UXG04VuVbruMUYbJ6JctvH0YnC/4q3/AkT18q4NaITo91CUm0liMS9VqzT9vZhVQ/1eqPanMWjBM+Juhfb/9g==",
|
||||
"version": "4.4.1",
|
||||
"resolved": "https://registry.npmjs.org/chai/-/chai-4.4.1.tgz",
|
||||
"integrity": "sha512-13sOfMv2+DWduEU+/xbun3LScLoqN17nBeTLUsmDfKdoiC1fr0n9PU4guu4AhRcOVFk/sW8LyZWHuhWtQZiF+g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"assertion-error": "^1.1.0",
|
||||
@@ -1649,13 +1605,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/express": {
|
||||
"version": "4.18.2",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz",
|
||||
"integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==",
|
||||
"version": "4.18.3",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-4.18.3.tgz",
|
||||
"integrity": "sha512-6VyCijWQ+9O7WuVMTRBTl+cjNNIzD5cY5mQ1WM8r/LEkI2u8EYpOotESNwzNlyCn3g+dmjKYI6BmNneSr/FSRw==",
|
||||
"dependencies": {
|
||||
"accepts": "~1.3.8",
|
||||
"array-flatten": "1.1.1",
|
||||
"body-parser": "1.20.1",
|
||||
"body-parser": "1.20.2",
|
||||
"content-disposition": "0.5.4",
|
||||
"content-type": "~1.0.4",
|
||||
"cookie": "0.5.0",
|
||||
@@ -1690,9 +1646,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/express-fileupload": {
|
||||
"version": "1.4.2",
|
||||
"resolved": "https://registry.npmjs.org/express-fileupload/-/express-fileupload-1.4.2.tgz",
|
||||
"integrity": "sha512-vk+9cK595jP03T+YgoYPAebynVCZuUBtW1JkyJnitQnWzlONHdxdAIm9yo99V4viTEftq7MUfzuqmWyqWGzMIg==",
|
||||
"version": "1.4.3",
|
||||
"resolved": "https://registry.npmjs.org/express-fileupload/-/express-fileupload-1.4.3.tgz",
|
||||
"integrity": "sha512-vRzZo2YELm68DfR/CX8RMXgeK9BTAANxigrKACPjCXFGEzkCt/QWbqaIXP3W61uaX/hLj0CAo3/EVelpSQXkqA==",
|
||||
"dependencies": {
|
||||
"busboy": "^1.6.0"
|
||||
},
|
||||
@@ -1844,9 +1800,9 @@
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/follow-redirects": {
|
||||
"version": "1.15.3",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz",
|
||||
"integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==",
|
||||
"version": "1.15.4",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.4.tgz",
|
||||
"integrity": "sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "individual",
|
||||
@@ -2602,9 +2558,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/node-abi": {
|
||||
"version": "3.51.0",
|
||||
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.51.0.tgz",
|
||||
"integrity": "sha512-SQkEP4hmNWjlniS5zdnfIXTk1x7Ome85RDzHlTbBtzE97Gfwz/Ipw4v/Ryk20DWIy3yCNVLVlGKApCnmvYoJbA==",
|
||||
"version": "3.54.0",
|
||||
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.54.0.tgz",
|
||||
"integrity": "sha512-p7eGEiQil0YUV3ItH4/tBb781L5impVmmx2E9FRKF7d18XXzp4PGT2tdYMFY6wQqgxD0IwNZOiSJ0/K0fSi/OA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"semver": "^7.3.5"
|
||||
@@ -2613,25 +2569,6 @@
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/node-fetch": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
|
||||
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
|
||||
"dependencies": {
|
||||
"whatwg-url": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "4.x || >=6.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"encoding": "^0.1.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"encoding": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/object-inspect": {
|
||||
"version": "1.13.1",
|
||||
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz",
|
||||
@@ -2731,31 +2668,6 @@
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/passport": {
|
||||
"version": "0.6.0",
|
||||
"resolved": "https://registry.npmjs.org/passport/-/passport-0.6.0.tgz",
|
||||
"integrity": "sha512-0fe+p3ZnrWRW74fe8+SvCyf4a3Pb2/h7gFkQ8yTJpAO50gDzlfjZUZTO1k5Eg9kUct22OxHLqDZoKUWRHOh9ug==",
|
||||
"dependencies": {
|
||||
"passport-strategy": "1.x.x",
|
||||
"pause": "0.0.1",
|
||||
"utils-merge": "^1.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/jaredhanson"
|
||||
}
|
||||
},
|
||||
"node_modules/passport-strategy": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/passport-strategy/-/passport-strategy-1.0.0.tgz",
|
||||
"integrity": "sha512-CB97UUvDKJde2V0KDWWB3lyf6PC3FaZP7YxZ2G8OAtn9p4HI9j9JLP9qjOGZFvyl8uwNT8qM+hGnz/n16NI7oA==",
|
||||
"engines": {
|
||||
"node": ">= 0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/path-exists": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
|
||||
@@ -2800,11 +2712,6 @@
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/pause": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz",
|
||||
"integrity": "sha512-KG8UEiEVkR3wGEb4m5yZkVCzigAD+cVEJck2CzYZO37ZGJfctvVptVO192MwrtPhzONn6go8ylnOdMhKqi4nfg=="
|
||||
},
|
||||
"node_modules/picomatch": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
|
||||
@@ -2960,9 +2867,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/raw-body": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz",
|
||||
"integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==",
|
||||
"version": "2.5.2",
|
||||
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz",
|
||||
"integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==",
|
||||
"dependencies": {
|
||||
"bytes": "3.1.2",
|
||||
"http-errors": "2.0.0",
|
||||
@@ -3113,9 +3020,9 @@
|
||||
"integrity": "sha512-0s+oAmw9zLl1V1cS9BtZN7JAd0cW5e0QH4W3LWEK6a4LaLEA2OTpGYWDY+6XasBLtz6wkm3u1xRw95mRuJ59WA=="
|
||||
},
|
||||
"node_modules/semver": {
|
||||
"version": "7.5.4",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz",
|
||||
"integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==",
|
||||
"version": "7.6.0",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz",
|
||||
"integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"lru-cache": "^6.0.0"
|
||||
@@ -3429,11 +3336,6 @@
|
||||
"node": ">=0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/tr46": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
|
||||
},
|
||||
"node_modules/tunnel-agent": {
|
||||
"version": "0.6.0",
|
||||
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
|
||||
@@ -3494,9 +3396,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.2.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz",
|
||||
"integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==",
|
||||
"version": "5.3.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz",
|
||||
"integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
@@ -3551,20 +3453,6 @@
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/webidl-conversions": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
|
||||
},
|
||||
"node_modules/whatwg-url": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
|
||||
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
|
||||
"dependencies": {
|
||||
"tr46": "~0.0.3",
|
||||
"webidl-conversions": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/which": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||
|
||||
@@ -676,7 +676,7 @@ describe('cds.ql → cqn', () => {
|
||||
.to.eql(INSERT.into(Foo).entries(...entries))
|
||||
.to.eql(INSERT.into(Foo).entries(entries))
|
||||
.to.eql({
|
||||
INSERT: { into: 'Foo', entries },
|
||||
INSERT: { into: cds.env.ql.quirks_mode ? 'Foo' : { ref: ['Foo'] }, entries },
|
||||
})
|
||||
})
|
||||
|
||||
@@ -692,7 +692,7 @@ describe('cds.ql → cqn', () => {
|
||||
.to.eql(INSERT.into(Foo).columns('a', 'b').rows([1, 2], [3, 4]))
|
||||
.to.eql({
|
||||
INSERT: {
|
||||
into: 'Foo',
|
||||
into: cds.env.ql.quirks_mode ? 'Foo' : { ref: ['Foo'] },
|
||||
columns: ['a', 'b'],
|
||||
rows: [
|
||||
[1, 2],
|
||||
@@ -706,7 +706,7 @@ describe('cds.ql → cqn', () => {
|
||||
expect(INSERT.into(Foo).columns('a', 'b').values([1, 2]))
|
||||
.to.eql(INSERT.into(Foo).columns('a', 'b').values(1, 2))
|
||||
.to.eql({
|
||||
INSERT: { into: 'Foo', columns: ['a', 'b'], values: [1, 2] },
|
||||
INSERT: { into: cds.env.ql.quirks_mode ? 'Foo' : { ref: ['Foo'] }, columns: ['a', 'b'], values: [1, 2] },
|
||||
})
|
||||
})
|
||||
|
||||
@@ -721,7 +721,7 @@ describe('cds.ql → cqn', () => {
|
||||
test('entity (..., <key>)', () => {
|
||||
const cqnWhere = {
|
||||
UPDATE: {
|
||||
entity: 'capire.bookshop.Books',
|
||||
entity: cds.env.ql.quirks_mode ? 'capire.bookshop.Books' : { ref: ['capire.bookshop.Books'] },
|
||||
where: [{ ref: ['ID'] }, '=', { val: 4711 }],
|
||||
},
|
||||
}
|
||||
@@ -765,7 +765,7 @@ describe('cds.ql → cqn', () => {
|
||||
.to.eql(UPDATE(Foo).with({ foo: 11, bar: { '-=': 22 } }))
|
||||
.to.eql({
|
||||
UPDATE: {
|
||||
entity: 'Foo',
|
||||
entity: cds.env.ql.quirks_mode ? 'Foo' : { ref: ['Foo'] },
|
||||
data: { foo: 11 },
|
||||
with: {
|
||||
bar: { xpr: [{ ref: ['bar'] }, '-', { val: 22 }] },
|
||||
@@ -776,7 +776,7 @@ describe('cds.ql → cqn', () => {
|
||||
// some more
|
||||
expect(UPDATE(Foo).with(`bar = coalesce(x,y), car = 'foo''s bar, car'`)).to.eql({
|
||||
UPDATE: {
|
||||
entity: 'Foo',
|
||||
entity: cds.env.ql.quirks_mode ? 'Foo' : { ref: ['Foo'] },
|
||||
data: {
|
||||
car: "foo's bar, car",
|
||||
},
|
||||
@@ -796,7 +796,7 @@ describe('cds.ql → cqn', () => {
|
||||
test('from (..., <key>)', () => {
|
||||
const cqnWhere = {
|
||||
DELETE: {
|
||||
from: 'capire.bookshop.Books',
|
||||
from: cds.env.ql.quirks_mode ? 'capire.bookshop.Books' : { ref: ['capire.bookshop.Books'] },
|
||||
where: [{ ref: ['ID'] }, '=', { val: 4711 }],
|
||||
},
|
||||
}
|
||||
|
||||
@@ -33,22 +33,51 @@ describe('cap/samples - Hierarchical Data', ()=>{
|
||||
]}
|
||||
))
|
||||
|
||||
it ('should generate correct queries for expands', ()=>{
|
||||
let q = SELECT.from (Cats, c => { c.ID, c.name, c.children (c => c.name) })
|
||||
expect (q) .to.eql ({
|
||||
SELECT: {
|
||||
from: { ref:[ "Categories" ] },
|
||||
columns: [
|
||||
{ ref: [ "ID" ] },
|
||||
{ ref: [ "name" ] },
|
||||
{ ref: [ "children" ], expand: [ {ref:['name']} ] },
|
||||
]
|
||||
}
|
||||
})
|
||||
if (q.forSQL) expect (q.forSQL()) .to.eql ({
|
||||
SELECT: {
|
||||
from: { ref:[ "Categories" ], as: "Categories" },
|
||||
columns: [
|
||||
{ ref: [ "Categories", "ID" ] },
|
||||
{ ref: [ "Categories", "name" ] },
|
||||
{ as: "children", SELECT: { expand: true,
|
||||
one: false,
|
||||
columns: [{ ref: [ "children", "name" ]}],
|
||||
from: { ref:["Categories"], as: "children" },
|
||||
where: [
|
||||
{ref:[ "Categories", "ID" ]}, "=", {ref:[ "children", "parent_ID" ]}
|
||||
],
|
||||
}},
|
||||
],
|
||||
}
|
||||
})
|
||||
if (q.toSql) expect (q.toSql()) .to.eql (
|
||||
`SELECT json_insert('{}',` +
|
||||
`'$."ID"',ID,` +
|
||||
`'$."name"',name,` +
|
||||
`'$."children"',children->'$'` +
|
||||
`) as _json_ FROM (` +
|
||||
`SELECT Categories.ID,Categories.name,(` +
|
||||
`SELECT jsonb_group_array(jsonb_insert('{}','$."name"',name)) as _json_ FROM (` +
|
||||
`SELECT children.name FROM Categories as children WHERE Categories.ID = children.parent_ID` +
|
||||
`)` +
|
||||
`) as children FROM Categories as Categories` +
|
||||
`)`
|
||||
)
|
||||
})
|
||||
|
||||
it ('supports nested reads', async()=>{
|
||||
if (require('semver').gte(cds.version, '5.9.0')) {
|
||||
expect (await
|
||||
SELECT.one.from (Cats, c=>{
|
||||
c.ID, c.name.as('parent'), c.children (c=>{
|
||||
c.name.as('child')
|
||||
})
|
||||
}) .where ({name:'Cat'})
|
||||
) .to.eql (
|
||||
{ ID:101, parent:'Cat', children:[
|
||||
{ child:'Kitty' },
|
||||
{ child:'Catwoman' },
|
||||
]}
|
||||
)
|
||||
return
|
||||
}
|
||||
expect (await
|
||||
SELECT.one.from (Cats, c=>{
|
||||
c.ID, c.name.as('parent'), c.children (c=>{
|
||||
@@ -57,32 +86,13 @@ describe('cap/samples - Hierarchical Data', ()=>{
|
||||
}) .where ({name:'Cat'})
|
||||
) .to.eql (
|
||||
{ ID:101, parent:'Cat', children:[
|
||||
{ ID:102, child:'Kitty' },
|
||||
{ ID:106, child:'Catwoman' },
|
||||
{ child:'Kitty' },
|
||||
{ child:'Catwoman' },
|
||||
]}
|
||||
)
|
||||
})
|
||||
|
||||
it ('supports deeply nested reads', async()=>{
|
||||
if (require('semver').gte(cds.version, '5.9.0')) {
|
||||
expect (await SELECT.one.from (Cats, c=>{
|
||||
c.ID, c.name, c.children (
|
||||
c => { c.name },
|
||||
{levels:3}
|
||||
)
|
||||
}) .where ({name:'Cat'})
|
||||
) .to.eql (
|
||||
{ ID:101, name:'Cat', children:[
|
||||
{ name:'Kitty', children:[
|
||||
{ name:'Kitty Cat', children:[
|
||||
{ name:'Aristocat' }, ]}, // level 3
|
||||
{ name:'Kitty Bat', children:[] }, ]},
|
||||
{ name:'Catwoman', children:[
|
||||
{ name:'Catalina', children:[] } ]},
|
||||
]}
|
||||
)
|
||||
return
|
||||
}
|
||||
expect (await SELECT.one.from (Cats, c=>{
|
||||
c.ID, c.name, c.children (
|
||||
c => { c.name },
|
||||
@@ -91,12 +101,12 @@ describe('cap/samples - Hierarchical Data', ()=>{
|
||||
}) .where ({name:'Cat'})
|
||||
) .to.eql (
|
||||
{ ID:101, name:'Cat', children:[
|
||||
{ ID:102, name:'Kitty', children:[
|
||||
{ ID:103, name:'Kitty Cat', children:[
|
||||
{ ID:104, name:'Aristocat' }, ]}, // level 3
|
||||
{ ID:105, name:'Kitty Bat', children:[] }, ]},
|
||||
{ ID:106, name:'Catwoman', children:[
|
||||
{ ID:107, name:'Catalina', children:[] } ]},
|
||||
{ name:'Kitty', children:[
|
||||
{ name:'Kitty Cat', children:[
|
||||
{ name:'Aristocat' }, ]}, // level 3
|
||||
{ name:'Kitty Bat', children:[] }, ]},
|
||||
{ name:'Catwoman', children:[
|
||||
{ name:'Catalina', children:[] } ]},
|
||||
]}
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user