Compare commits
1 Commits
refactor/s
...
reproduce-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73f438d3c0 |
31
.eslintrc
Normal file
31
.eslintrc
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"extends": [
|
||||||
|
"plugin:@sap/cds/recommended",
|
||||||
|
"eslint:recommended"
|
||||||
|
],
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"es2022": true,
|
||||||
|
"node": true,
|
||||||
|
"jest": true,
|
||||||
|
"mocha": true
|
||||||
|
},
|
||||||
|
"globals": {
|
||||||
|
"SELECT": true,
|
||||||
|
"INSERT": true,
|
||||||
|
"UPSERT": true,
|
||||||
|
"UPDATE": true,
|
||||||
|
"DELETE": true,
|
||||||
|
"CREATE": true,
|
||||||
|
"DROP": true,
|
||||||
|
"CDL": true,
|
||||||
|
"CQL": true,
|
||||||
|
"cds": true
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"no-console": "off",
|
||||||
|
"require-atomic-updates": "off",
|
||||||
|
"require-await":"warn",
|
||||||
|
"no-unused-vars": ["warn", { "argsIgnorePattern": "_" }]
|
||||||
|
}
|
||||||
|
}
|
||||||
16
.github/workflows/node.js.yml
vendored
16
.github/workflows/node.js.yml
vendored
@@ -11,6 +11,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
@@ -18,21 +19,10 @@ jobs:
|
|||||||
node-version: [20.x, 18.x]
|
node-version: [20.x, 18.x]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v2
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm test
|
- run: npm test
|
||||||
|
|
||||||
lint:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 20.x
|
|
||||||
- run: npm ci
|
|
||||||
- run: npm run lint
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
"@cap-js/sqlite": "*"
|
"@cap-js/sqlite": "*"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sap/cds": ">=7",
|
"@sap/cds": "^7",
|
||||||
"express": "^4.17.1"
|
"express": "^4.17.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ module.exports = class CatalogService extends cds.ApplicationService { init() {
|
|||||||
const { ListOfBooks } = this.entities
|
const { ListOfBooks } = this.entities
|
||||||
|
|
||||||
// Add some discount for overstocked books
|
// Add some discount for overstocked books
|
||||||
this.after('each', ListOfBooks, book => {
|
this.after('READ', ListOfBooks, each => {
|
||||||
if (book.stock > 111) book.title += ` -- 11% discount!`
|
if (each.stock > 111) each.title += ` -- 11% discount!`
|
||||||
})
|
})
|
||||||
|
|
||||||
// Reduce stock of ordered books if available stock suffices
|
// Reduce stock of ordered books if available stock suffices
|
||||||
|
|||||||
@@ -10,12 +10,22 @@
|
|||||||
//
|
//
|
||||||
using { sap.capire.bookshop.Books } from '@capire/bookshop';
|
using { sap.capire.bookshop.Books } from '@capire/bookshop';
|
||||||
using { ReviewsService.Reviews } from '@capire/reviews';
|
using { ReviewsService.Reviews } from '@capire/reviews';
|
||||||
|
using { managed, cuid } from '@sap/cds/common';
|
||||||
|
|
||||||
extend Books with {
|
extend Books with {
|
||||||
reviews : Composition of many Reviews on reviews.subject = $self.ID;
|
reviews : Composition of many Reviews on reviews.subject = $self.ID;
|
||||||
rating : type of Reviews:rating; // average rating
|
rating : type of Reviews:rating; // average rating
|
||||||
numberOfReviews : Integer @title : '{i18n>NumberOfReviews}';
|
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
|
// Extend Orders with Books as Products
|
||||||
|
|||||||
@@ -79,3 +79,36 @@ Authorization: Basic alice:
|
|||||||
"dateOfBirth": "1564-04-26",
|
"dateOfBirth": "1564-04-26",
|
||||||
"dateOfDeath": "1616-04-23"
|
"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"
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
const eslintCds = require('@sap/eslint-plugin-cds')
|
|
||||||
const eslintJs = require('@eslint/js')
|
|
||||||
const globals = require('globals')
|
|
||||||
|
|
||||||
module.exports = [
|
|
||||||
eslintJs.configs.recommended,
|
|
||||||
eslintCds.configs.recommended,
|
|
||||||
{
|
|
||||||
languageOptions: {
|
|
||||||
globals: {
|
|
||||||
sap: true,
|
|
||||||
...globals.es2022,
|
|
||||||
...globals.browser,
|
|
||||||
...globals.node,
|
|
||||||
...globals.jest,
|
|
||||||
...globals.mocha,
|
|
||||||
...eslintCds.configs.recommended.languageOptions.globals
|
|
||||||
}
|
|
||||||
},
|
|
||||||
rules: {
|
|
||||||
'no-console': 'off',
|
|
||||||
'no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
|
|
||||||
'require-atomic-updates': 'off',
|
|
||||||
'require-await': 'warn'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Request } from "@sap/cds"
|
import type { Request } from "@sap/cds/apis/services"
|
||||||
|
|
||||||
module.exports = class say {
|
module.exports = class say {
|
||||||
hello(req: Request) {
|
hello(req: Request) {
|
||||||
|
|||||||
796
package-lock.json
generated
796
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -21,12 +21,11 @@
|
|||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@cap-js/sqlite": "^1",
|
"@cap-js/sqlite": "^1",
|
||||||
"@sap/eslint-plugin-cds": "^3",
|
"@sap/eslint-plugin-cds": "^2.6.1",
|
||||||
"axios": "^1",
|
"axios": "^1",
|
||||||
"chai": "^4.3.4",
|
"chai": "^4.3.4",
|
||||||
"chai-as-promised": "^7.1.1",
|
"chai-as-promised": "^7.1.1",
|
||||||
"chai-subset": "^1.6.0",
|
"chai-subset": "^1.6.0",
|
||||||
"eslint": "^9",
|
|
||||||
"semver": "^7"
|
"semver": "^7"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -39,8 +38,7 @@
|
|||||||
"jest": "npx jest --silent",
|
"jest": "npx jest --silent",
|
||||||
"start": "cds watch fiori",
|
"start": "cds watch fiori",
|
||||||
"test": "npm run jest -- --silent",
|
"test": "npm run jest -- --silent",
|
||||||
"test:hello": "cd hello && npm test",
|
"test:hello": "cd hello && npm test"
|
||||||
"lint": "eslint ."
|
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
"testTimeout": 20000,
|
"testTimeout": 20000,
|
||||||
|
|||||||
Reference in New Issue
Block a user