Compare commits
19 Commits
reproduce-
...
refactor/s
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
55e4c92a60 | ||
|
|
7738f85036 | ||
|
|
d9f50d635f | ||
|
|
546f374b08 | ||
|
|
bb127bcc58 | ||
|
|
d08749fd21 | ||
|
|
be5696b14e | ||
|
|
9263f747c7 | ||
|
|
ead660bfe4 | ||
|
|
e2712acaec | ||
|
|
426b64caaf | ||
|
|
ac6d87dc03 | ||
|
|
b716b1e0f8 | ||
|
|
de8fd4b86a | ||
|
|
464e7c40dc | ||
|
|
cabaf29c63 | ||
|
|
68a50148fe | ||
|
|
71ff72cdd8 | ||
|
|
74fe9fb76f |
31
.eslintrc
31
.eslintrc
@@ -1,31 +0,0 @@
|
|||||||
{
|
|
||||||
"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,7 +11,6 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
@@ -19,10 +18,21 @@ jobs:
|
|||||||
node-version: [20.x, 18.x]
|
node-version: [20.x, 18.x]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v4
|
||||||
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('READ', ListOfBooks, each => {
|
this.after('each', ListOfBooks, book => {
|
||||||
if (each.stock > 111) each.title += ` -- 11% discount!`
|
if (book.stock > 111) book.title += ` -- 11% discount!`
|
||||||
})
|
})
|
||||||
|
|
||||||
// Reduce stock of ordered books if available stock suffices
|
// Reduce stock of ordered books if available stock suffices
|
||||||
|
|||||||
@@ -10,22 +10,12 @@
|
|||||||
//
|
//
|
||||||
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,36 +79,3 @@ 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"
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
|
|||||||
27
eslint.config.js
Normal file
27
eslint.config.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
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 type { Request } from "@sap/cds/apis/services"
|
import { Request } from "@sap/cds"
|
||||||
|
|
||||||
module.exports = class say {
|
module.exports = class say {
|
||||||
hello(req: Request) {
|
hello(req: Request) {
|
||||||
|
|||||||
6888
package-lock.json
generated
6888
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
112
package.json
112
package.json
@@ -1,56 +1,58 @@
|
|||||||
{
|
{
|
||||||
"name": "@capire/samples",
|
"name": "@capire/samples",
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"description": "A monorepo with several samples for CAP.",
|
"description": "A monorepo with several samples for CAP.",
|
||||||
"repository": "https://github.com/sap-samples/cloud-cap-samples.git",
|
"repository": "https://github.com/sap-samples/cloud-cap-samples.git",
|
||||||
"author": "daniel.hutzel@sap.com",
|
"author": "daniel.hutzel@sap.com",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sap/cds": ">=7"
|
"@sap/cds": ">=7"
|
||||||
},
|
},
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"./bookshop",
|
"./bookshop",
|
||||||
"./bookstore",
|
"./bookstore",
|
||||||
"./common",
|
"./common",
|
||||||
"./data-viewer",
|
"./data-viewer",
|
||||||
"./fiori",
|
"./fiori",
|
||||||
"./hello",
|
"./hello",
|
||||||
"./media",
|
"./media",
|
||||||
"./orders",
|
"./orders",
|
||||||
"./loggers",
|
"./loggers",
|
||||||
"./reviews"
|
"./reviews"
|
||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@cap-js/sqlite": "^1",
|
"@cap-js/sqlite": "^1",
|
||||||
"@sap/eslint-plugin-cds": "^2.6.1",
|
"@sap/eslint-plugin-cds": "^3",
|
||||||
"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",
|
||||||
"semver": "^7"
|
"eslint": "^9",
|
||||||
},
|
"semver": "^7"
|
||||||
"scripts": {
|
},
|
||||||
"cleanup": "rm -rf node_modules && rm -rf */node_modules && rm -rf */*/node_modules",
|
"scripts": {
|
||||||
"bookshop": "cds watch bookshop",
|
"cleanup": "rm -rf node_modules && rm -rf */node_modules && rm -rf */*/node_modules",
|
||||||
"fiori": "cds watch fiori",
|
"bookshop": "cds watch bookshop",
|
||||||
"hello": "cds watch hello",
|
"fiori": "cds watch fiori",
|
||||||
"media": "cds watch media",
|
"hello": "cds watch hello",
|
||||||
"mocha": "CDS_TEST_SILENT=y npx mocha",
|
"media": "cds watch media",
|
||||||
"jest": "npx jest --silent",
|
"mocha": "CDS_TEST_SILENT=y npx mocha",
|
||||||
"start": "cds watch fiori",
|
"jest": "npx jest --silent",
|
||||||
"test": "npm run jest -- --silent",
|
"start": "cds watch fiori",
|
||||||
"test:hello": "cd hello && npm test"
|
"test": "npm run jest -- --silent",
|
||||||
},
|
"test:hello": "cd hello && npm test",
|
||||||
"jest": {
|
"lint": "eslint ."
|
||||||
"testTimeout": 20000,
|
},
|
||||||
"testMatch": [
|
"jest": {
|
||||||
"**/*.test.js"
|
"testTimeout": 20000,
|
||||||
]
|
"testMatch": [
|
||||||
},
|
"**/*.test.js"
|
||||||
"mocha": {
|
]
|
||||||
"recursive": true,
|
},
|
||||||
"parallel": true,
|
"mocha": {
|
||||||
"timeout": 6666
|
"recursive": true,
|
||||||
},
|
"parallel": true,
|
||||||
"license": "SEE LICENSE IN LICENSE",
|
"timeout": 6666
|
||||||
"private": true
|
},
|
||||||
}
|
"license": "SEE LICENSE IN LICENSE",
|
||||||
|
"private": true
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user