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:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
@@ -18,21 +19,10 @@ jobs:
|
||||
node-version: [20.x, 18.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v2
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- run: npm ci
|
||||
- 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": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@sap/cds": ">=7",
|
||||
"@sap/cds": "^7",
|
||||
"express": "^4.17.1"
|
||||
},
|
||||
"scripts": {
|
||||
|
||||
@@ -4,8 +4,8 @@ module.exports = class CatalogService extends cds.ApplicationService { init() {
|
||||
const { ListOfBooks } = this.entities
|
||||
|
||||
// Add some discount for overstocked books
|
||||
this.after('each', ListOfBooks, book => {
|
||||
if (book.stock > 111) book.title += ` -- 11% discount!`
|
||||
this.after('READ', ListOfBooks, each => {
|
||||
if (each.stock > 111) each.title += ` -- 11% discount!`
|
||||
})
|
||||
|
||||
// Reduce stock of ordered books if available stock suffices
|
||||
|
||||
@@ -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"
|
||||
}]
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
hello(req: Request) {
|
||||
|
||||
6892
package-lock.json
generated
6892
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
112
package.json
112
package.json
@@ -1,58 +1,56 @@
|
||||
{
|
||||
"name": "@capire/samples",
|
||||
"version": "2.0.0",
|
||||
"description": "A monorepo with several samples for CAP.",
|
||||
"repository": "https://github.com/sap-samples/cloud-cap-samples.git",
|
||||
"author": "daniel.hutzel@sap.com",
|
||||
"dependencies": {
|
||||
"@sap/cds": ">=7"
|
||||
},
|
||||
"workspaces": [
|
||||
"./bookshop",
|
||||
"./bookstore",
|
||||
"./common",
|
||||
"./data-viewer",
|
||||
"./fiori",
|
||||
"./hello",
|
||||
"./media",
|
||||
"./orders",
|
||||
"./loggers",
|
||||
"./reviews"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@cap-js/sqlite": "^1",
|
||||
"@sap/eslint-plugin-cds": "^3",
|
||||
"axios": "^1",
|
||||
"chai": "^4.3.4",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"chai-subset": "^1.6.0",
|
||||
"eslint": "^9",
|
||||
"semver": "^7"
|
||||
},
|
||||
"scripts": {
|
||||
"cleanup": "rm -rf node_modules && rm -rf */node_modules && rm -rf */*/node_modules",
|
||||
"bookshop": "cds watch bookshop",
|
||||
"fiori": "cds watch fiori",
|
||||
"hello": "cds watch hello",
|
||||
"media": "cds watch media",
|
||||
"mocha": "CDS_TEST_SILENT=y npx mocha",
|
||||
"jest": "npx jest --silent",
|
||||
"start": "cds watch fiori",
|
||||
"test": "npm run jest -- --silent",
|
||||
"test:hello": "cd hello && npm test",
|
||||
"lint": "eslint ."
|
||||
},
|
||||
"jest": {
|
||||
"testTimeout": 20000,
|
||||
"testMatch": [
|
||||
"**/*.test.js"
|
||||
]
|
||||
},
|
||||
"mocha": {
|
||||
"recursive": true,
|
||||
"parallel": true,
|
||||
"timeout": 6666
|
||||
},
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"private": true
|
||||
}
|
||||
"name": "@capire/samples",
|
||||
"version": "2.0.0",
|
||||
"description": "A monorepo with several samples for CAP.",
|
||||
"repository": "https://github.com/sap-samples/cloud-cap-samples.git",
|
||||
"author": "daniel.hutzel@sap.com",
|
||||
"dependencies": {
|
||||
"@sap/cds": ">=7"
|
||||
},
|
||||
"workspaces": [
|
||||
"./bookshop",
|
||||
"./bookstore",
|
||||
"./common",
|
||||
"./data-viewer",
|
||||
"./fiori",
|
||||
"./hello",
|
||||
"./media",
|
||||
"./orders",
|
||||
"./loggers",
|
||||
"./reviews"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@cap-js/sqlite": "^1",
|
||||
"@sap/eslint-plugin-cds": "^2.6.1",
|
||||
"axios": "^1",
|
||||
"chai": "^4.3.4",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"chai-subset": "^1.6.0",
|
||||
"semver": "^7"
|
||||
},
|
||||
"scripts": {
|
||||
"cleanup": "rm -rf node_modules && rm -rf */node_modules && rm -rf */*/node_modules",
|
||||
"bookshop": "cds watch bookshop",
|
||||
"fiori": "cds watch fiori",
|
||||
"hello": "cds watch hello",
|
||||
"media": "cds watch media",
|
||||
"mocha": "CDS_TEST_SILENT=y npx mocha",
|
||||
"jest": "npx jest --silent",
|
||||
"start": "cds watch fiori",
|
||||
"test": "npm run jest -- --silent",
|
||||
"test:hello": "cd hello && npm test"
|
||||
},
|
||||
"jest": {
|
||||
"testTimeout": 20000,
|
||||
"testMatch": [
|
||||
"**/*.test.js"
|
||||
]
|
||||
},
|
||||
"mocha": {
|
||||
"recursive": true,
|
||||
"parallel": true,
|
||||
"timeout": 6666
|
||||
},
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"private": true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user