Compare commits
2 Commits
v7
...
multimodul
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
61d6c0d58f | ||
|
|
4179493ce7 |
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": "_" }]
|
||||
}
|
||||
}
|
||||
3
.github/dependabot.yml
vendored
3
.github/dependabot.yml
vendored
@@ -15,6 +15,3 @@ updates:
|
||||
- dependency-name: "chai"
|
||||
# chai 5 doesn't work atm w/ cds.test, TODO fix that in cds.test
|
||||
versions: ["5.x"]
|
||||
- dependency-name: "chai-as-promised"
|
||||
# chai-as-promised 8 doesn't work atm w/ cds.test, TODO fix that in cds.test
|
||||
versions: ["8.x"]
|
||||
|
||||
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": {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const cds = require('@sap/cds')
|
||||
const cds = require('@sap/cds/lib')
|
||||
|
||||
module.exports = class AdminService extends cds.ApplicationService { init(){
|
||||
this.before ('NEW','Authors', genid)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
const cds = require('@sap/cds')
|
||||
module.exports = class CatalogService extends cds.ApplicationService { init() {
|
||||
|
||||
const { Books } = cds.entities('sap.capire.bookshop')
|
||||
|
||||
43
bookstore/mta.yaml
Normal file
43
bookstore/mta.yaml
Normal file
@@ -0,0 +1,43 @@
|
||||
_schema-version: '3.1'
|
||||
ID: capire.bookstore
|
||||
version: 1.0.0
|
||||
description: "A simple CAP project."
|
||||
parameters:
|
||||
enable-parallel-deployments: true
|
||||
build-parameters:
|
||||
before-all:
|
||||
- builder: custom
|
||||
commands:
|
||||
- npm ci
|
||||
- npx cds build --production
|
||||
modules:
|
||||
- name: bookstore-srv
|
||||
type: nodejs
|
||||
path: gen/srv
|
||||
parameters:
|
||||
buildpack: nodejs_buildpack
|
||||
readiness-health-check-type: http
|
||||
readiness-health-check-http-endpoint: /health
|
||||
build-parameters:
|
||||
builder: npm
|
||||
provides:
|
||||
- name: srv-api # required by consumers of CAP services (e.g. approuter)
|
||||
properties:
|
||||
srv-url: ${default-url}
|
||||
requires:
|
||||
- name: bookstore-destination
|
||||
- name: bookstore-messaging
|
||||
- name: samples-db
|
||||
|
||||
resources:
|
||||
- name: bookstore-destination
|
||||
type: org.cloudfoundry.managed-service
|
||||
parameters:
|
||||
service: destination
|
||||
service-plan: lite
|
||||
- name: bookstore-messaging
|
||||
type: org.cloudfoundry.managed-service
|
||||
parameters:
|
||||
service: enterprise-messaging
|
||||
service-plan: default
|
||||
path: ./event-mesh.json
|
||||
@@ -21,14 +21,32 @@
|
||||
"model": "@capire/orders"
|
||||
},
|
||||
"messaging": {
|
||||
"[development]": { "kind": "file-based-messaging" },
|
||||
"[hybrid]": { "kind": "enterprise-messaging-shared" },
|
||||
"[production]": { "kind": "enterprise-messaging" }
|
||||
"[development]": {
|
||||
"kind": "file-based-messaging"
|
||||
},
|
||||
"[hybrid]": {
|
||||
"kind": "enterprise-messaging-shared"
|
||||
},
|
||||
"[production]": {
|
||||
"kind": "enterprise-messaging"
|
||||
}
|
||||
},
|
||||
"db": { "kind": "sql" },
|
||||
"[multimodule]": {
|
||||
"db": {
|
||||
"kind": "sql"
|
||||
"kind": "sqlite",
|
||||
"impl": "@cap-js/sqlite",
|
||||
"credentials": {
|
||||
"url": "../db.sqlite"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"log": { "service": true }
|
||||
"log": {
|
||||
"service": true
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sap/cds-dk": "^7"
|
||||
}
|
||||
}
|
||||
5
db/sqlite/index.cds
Normal file
5
db/sqlite/index.cds
Normal file
@@ -0,0 +1,5 @@
|
||||
using from '@capire/bookstore';
|
||||
using from '@capire/common';
|
||||
using from '@capire/orders';
|
||||
using from '@capire/reviews';
|
||||
using from '@capire/fiori';
|
||||
@@ -1,36 +0,0 @@
|
||||
const cds = require('@sap/eslint-plugin-cds')
|
||||
const globals = require('globals')
|
||||
const js = require('@eslint/js')
|
||||
|
||||
module.exports = [
|
||||
cds.configs.recommended,
|
||||
js.configs.recommended,
|
||||
{
|
||||
languageOptions: {
|
||||
globals: {
|
||||
es2022: true,
|
||||
...globals.browser,
|
||||
...globals.node,
|
||||
...globals.jest,
|
||||
...globals.mocha,
|
||||
cds: true,
|
||||
sap: true,
|
||||
CDL: true,
|
||||
CQL: true,
|
||||
CREATE: true,
|
||||
DELETE: true,
|
||||
DROP: true,
|
||||
INSERT: true,
|
||||
SELECT: true,
|
||||
UPDATE: true,
|
||||
UPSERT: true
|
||||
}
|
||||
},
|
||||
rules: {
|
||||
'no-console': 'off',
|
||||
'no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
|
||||
'require-atomic-updates': 'off',
|
||||
'require-await': 'warn'
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -1,7 +1,7 @@
|
||||
<!doctype html>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
@@ -10,22 +10,21 @@
|
||||
<script>
|
||||
window["sap-ushell-config"] = {
|
||||
defaultRenderer: "fiori2",
|
||||
applications: {},
|
||||
applications: {}
|
||||
};
|
||||
</script>
|
||||
|
||||
<script id="sap-ushell-bootstrap" src="https://ui5.sap.com/test-resources/sap/ushell/bootstrap/sandbox.js"></script>
|
||||
<script id="sap-ui-bootstrap" src="https://ui5.sap.com/resources/sap-ui-core.js"
|
||||
data-sap-ui-libs="sap.m, sap.ushell, sap.collaboration, sap.ui.layout" data-sap-ui-compatVersion="edge"
|
||||
data-sap-ui-theme="sap_horizon"></script>
|
||||
<script id="sap-ushell-bootstrap" src="https://sapui5.hana.ondemand.com/test-resources/sap/ushell/bootstrap/sandbox.js"></script>
|
||||
<script id="sap-ui-bootstrap" src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
|
||||
data-sap-ui-libs="sap.m, sap.ushell, sap.collaboration, sap.ui.layout"
|
||||
data-sap-ui-compatVersion="edge"
|
||||
data-sap-ui-theme="sap_horizon"
|
||||
data-sap-ui-frameOptions="allow"
|
||||
></script>
|
||||
<script>
|
||||
sap.ui.getCore().attachInit(() =>
|
||||
sap.ushell.Container.createRenderer().placeAt("content")
|
||||
);
|
||||
sap.ui.getCore().attachInit(()=> sap.ushell.Container.createRenderer().placeAt("content"))
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="sapUiBody" id="content">
|
||||
</body>
|
||||
|
||||
<body class="sapUiBody" id="content"></body>
|
||||
</html>
|
||||
12
fiori/app/router/package.json
Normal file
12
fiori/app/router/package.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "approuter",
|
||||
"dependencies": {
|
||||
"@sap/approuter": "^16.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^20.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node node_modules/@sap/approuter/approuter.js"
|
||||
}
|
||||
}
|
||||
22
fiori/app/router/xs-app.json
Normal file
22
fiori/app/router/xs-app.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"welcomeFile": "app/index.html",
|
||||
"routes": [
|
||||
{
|
||||
"source": "^/app/(.*)$",
|
||||
"target": "$1",
|
||||
"localDir": ".",
|
||||
"cacheControl": "no-cache, no-store, must-revalidate"
|
||||
},
|
||||
{
|
||||
"source": "^/appconfig/",
|
||||
"localDir": ".",
|
||||
"cacheControl": "no-cache, no-store, must-revalidate"
|
||||
},
|
||||
{
|
||||
"source": "^/(.*)$",
|
||||
"target": "$1",
|
||||
"destination": "srv-api",
|
||||
"csrfProtection": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
using from './db/common';
|
||||
using from './app/services';
|
||||
69
fiori/mta.yaml
Normal file
69
fiori/mta.yaml
Normal file
@@ -0,0 +1,69 @@
|
||||
_schema-version: '3.1'
|
||||
ID: capire.fiori
|
||||
version: 1.0.0
|
||||
description: "A simple CAP project."
|
||||
parameters:
|
||||
enable-parallel-deployments: true
|
||||
build-parameters:
|
||||
before-all:
|
||||
- builder: custom
|
||||
commands:
|
||||
- npm ci
|
||||
- npx cds build --production
|
||||
modules:
|
||||
- name: fiori-srv
|
||||
type: nodejs
|
||||
path: gen/srv
|
||||
parameters:
|
||||
buildpack: nodejs_buildpack
|
||||
readiness-health-check-type: http
|
||||
readiness-health-check-http-endpoint: /health
|
||||
build-parameters:
|
||||
builder: npm
|
||||
provides:
|
||||
- name: srv-api # required by consumers of CAP services (e.g. approuter)
|
||||
properties:
|
||||
srv-url: ${default-url}
|
||||
requires:
|
||||
- name: fiori-auth
|
||||
- name: fiori-destination
|
||||
- name: fiori-messaging
|
||||
- name: samples-db
|
||||
|
||||
- name: fiori
|
||||
type: approuter.nodejs
|
||||
path: app/router
|
||||
parameters:
|
||||
keep-existing-routes: true
|
||||
disk-quota: 256M
|
||||
memory: 256M
|
||||
requires:
|
||||
- name: srv-api
|
||||
group: destinations
|
||||
properties:
|
||||
name: srv-api # must be used in xs-app.json as well
|
||||
url: ~{srv-url}
|
||||
forwardAuthToken: true
|
||||
- name: fiori-auth
|
||||
|
||||
resources:
|
||||
- name: fiori-auth
|
||||
type: org.cloudfoundry.managed-service
|
||||
parameters:
|
||||
service: xsuaa
|
||||
service-plan: application
|
||||
path: ./xs-security.json
|
||||
config:
|
||||
xsappname: fiori-${org}-${space}
|
||||
tenant-mode: dedicated
|
||||
- name: fiori-destination
|
||||
type: org.cloudfoundry.managed-service
|
||||
parameters:
|
||||
service: destination
|
||||
service-plan: lite
|
||||
- name: fiori-messaging
|
||||
type: org.cloudfoundry.managed-service
|
||||
parameters:
|
||||
service: enterprise-messaging
|
||||
service-plan: default
|
||||
path: ./event-mesh.json
|
||||
@@ -38,6 +38,15 @@
|
||||
"db": {
|
||||
"kind": "sql"
|
||||
},
|
||||
"[multimodule]": {
|
||||
"db": {
|
||||
"kind": "sqlite",
|
||||
"impl": "@cap-js/sqlite",
|
||||
"credentials": {
|
||||
"url": "../db.sqlite"
|
||||
}
|
||||
}
|
||||
},
|
||||
"db-ext": {
|
||||
"[development]": {
|
||||
"model": "db/sqlite"
|
||||
|
||||
8
fiori/server.js
Normal file
8
fiori/server.js
Normal file
@@ -0,0 +1,8 @@
|
||||
// install OData v2 adapter
|
||||
const cds = require("@sap/cds")
|
||||
const proxy = require('@cap-js-community/odata-v2-adapter')
|
||||
const opts = global.it ? { target:'auto' } : {} // for tests, set 'auto' to detect port dynamically
|
||||
cds.on('bootstrap', app => app.use(proxy(opts))) // install proxy
|
||||
// cds.log('cov2ap','silent') // suppress anoying log outpout, e.g. for `npm run mocha -- --reporter nyan`
|
||||
|
||||
module.exports = require('@capire/bookstore/server.js')
|
||||
22
fiori/xs-security.json
Normal file
22
fiori/xs-security.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"scopes": [
|
||||
{
|
||||
"name": "$XSAPPNAME.emcallback",
|
||||
"description": "Enterprise-Messaging Callback Access",
|
||||
"grant-as-authority-to-apps": [
|
||||
"$XSSERVICENAME(fiori-messaging)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "$XSAPPNAME.emmanagement",
|
||||
"description": "Enterprise-Messaging Management Access"
|
||||
}
|
||||
],
|
||||
"attributes": [],
|
||||
"role-templates": [],
|
||||
"authorities-inheritance": false,
|
||||
"authorities": [
|
||||
"$XSAPPNAME.emmanagement",
|
||||
"$XSAPPNAME.mtcallback"
|
||||
]
|
||||
}
|
||||
@@ -1,10 +1,13 @@
|
||||
const cds = require ('@sap/cds')
|
||||
describe('Hello world!', () => {
|
||||
|
||||
beforeAll (()=> process.env.CDS_TYPESCRIPT = true)
|
||||
afterAll (()=> delete process.env.CDS_TYPESCRIPT)
|
||||
const {GET} = cds.test.in(__dirname,'../srv').run('serve', 'world.cds')
|
||||
|
||||
it('should say hello with class impl', async () => {
|
||||
const {data} = await GET`/say/hello(to='world')`
|
||||
expect(data.value).to.match(/Hello world.*typescript.*/i)
|
||||
expect(data.value).toMatch(/Hello world.*typescript.*/i)
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const cds = require ('@sap/cds')
|
||||
const cds = require ('@sap/cds/lib')
|
||||
const LOG = cds.log('cds.log')
|
||||
|
||||
module.exports = class LogService extends cds.Service {
|
||||
|
||||
27
mta.yaml
Normal file
27
mta.yaml
Normal file
@@ -0,0 +1,27 @@
|
||||
_schema-version: '3.1'
|
||||
ID: capire.samples
|
||||
version: 2.0.0
|
||||
description: "A monorepo with several samples for CAP."
|
||||
parameters:
|
||||
enable-parallel-deployments: true
|
||||
build-parameters:
|
||||
before-all:
|
||||
- builder: custom
|
||||
commands:
|
||||
- npm ci
|
||||
- npx cds build --production --ws
|
||||
modules:
|
||||
- name: samples-db-deployer
|
||||
type: hdb
|
||||
path: gen/db
|
||||
parameters:
|
||||
buildpack: nodejs_buildpack
|
||||
requires:
|
||||
- name: samples-db
|
||||
|
||||
resources:
|
||||
- name: samples-db
|
||||
type: com.sap.xs.hdi-container
|
||||
parameters:
|
||||
service: hana
|
||||
service-plan: hdi-shared
|
||||
12
orders/app/router/package.json
Normal file
12
orders/app/router/package.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "approuter",
|
||||
"dependencies": {
|
||||
"@sap/approuter": "^16.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^20.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node node_modules/@sap/approuter/approuter.js"
|
||||
}
|
||||
}
|
||||
22
orders/app/router/xs-app.json
Normal file
22
orders/app/router/xs-app.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"welcomeFile": "app/index.html",
|
||||
"routes": [
|
||||
{
|
||||
"source": "^/app/(.*)$",
|
||||
"target": "$1",
|
||||
"localDir": ".",
|
||||
"cacheControl": "no-cache, no-store, must-revalidate"
|
||||
},
|
||||
{
|
||||
"source": "^/appconfig/",
|
||||
"localDir": ".",
|
||||
"cacheControl": "no-cache, no-store, must-revalidate"
|
||||
},
|
||||
{
|
||||
"source": "^/(.*)$",
|
||||
"target": "$1",
|
||||
"destination": "srv-api",
|
||||
"csrfProtection": true
|
||||
}
|
||||
]
|
||||
}
|
||||
55
orders/mta.yaml
Normal file
55
orders/mta.yaml
Normal file
@@ -0,0 +1,55 @@
|
||||
_schema-version: '3.1'
|
||||
ID: capire.orders
|
||||
version: 1.0.0
|
||||
description: "A simple CAP project."
|
||||
parameters:
|
||||
enable-parallel-deployments: true
|
||||
build-parameters:
|
||||
before-all:
|
||||
- builder: custom
|
||||
commands:
|
||||
- npm ci
|
||||
- npx cds build --production
|
||||
modules:
|
||||
- name: orders-srv
|
||||
type: nodejs
|
||||
path: gen/srv
|
||||
parameters:
|
||||
buildpack: nodejs_buildpack
|
||||
readiness-health-check-type: http
|
||||
readiness-health-check-http-endpoint: /health
|
||||
build-parameters:
|
||||
builder: npm
|
||||
provides:
|
||||
- name: srv-api # required by consumers of CAP services (e.g. approuter)
|
||||
properties:
|
||||
srv-url: ${default-url}
|
||||
requires:
|
||||
- name: orders-auth
|
||||
|
||||
- name: orders
|
||||
type: approuter.nodejs
|
||||
path: app/router
|
||||
parameters:
|
||||
keep-existing-routes: true
|
||||
disk-quota: 256M
|
||||
memory: 256M
|
||||
requires:
|
||||
- name: srv-api
|
||||
group: destinations
|
||||
properties:
|
||||
name: srv-api # must be used in xs-app.json as well
|
||||
url: ~{srv-url}
|
||||
forwardAuthToken: true
|
||||
- name: orders-auth
|
||||
|
||||
resources:
|
||||
- name: orders-auth
|
||||
type: org.cloudfoundry.managed-service
|
||||
parameters:
|
||||
service: xsuaa
|
||||
service-plan: application
|
||||
path: ./xs-security.json
|
||||
config:
|
||||
xsappname: orders-${org}-${space}
|
||||
tenant-mode: dedicated
|
||||
@@ -4,5 +4,19 @@
|
||||
"dependencies": {
|
||||
"@capire/common": "*",
|
||||
"@sap/cds": ">=5"
|
||||
},
|
||||
"cds": {
|
||||
"requires": {
|
||||
"db": { "kind": "sql" },
|
||||
"[multimodule]": {
|
||||
"db": {
|
||||
"kind": "sqlite",
|
||||
"impl": "@cap-js/sqlite",
|
||||
"credentials": {
|
||||
"url": "../db.sqlite"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
5
orders/xs-security.json
Normal file
5
orders/xs-security.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"scopes": [],
|
||||
"attributes": [],
|
||||
"role-templates": []
|
||||
}
|
||||
1193
package-lock.json
generated
1193
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
18
package.json
18
package.json
@@ -5,6 +5,7 @@
|
||||
"repository": "https://github.com/sap-samples/cloud-cap-samples.git",
|
||||
"author": "daniel.hutzel@sap.com",
|
||||
"dependencies": {
|
||||
"@sap-cloud-sdk/resilience": "^3.14.0",
|
||||
"@sap/cds": ">=7"
|
||||
},
|
||||
"workspaces": [
|
||||
@@ -21,12 +22,12 @@
|
||||
],
|
||||
"devDependencies": {
|
||||
"@cap-js/sqlite": "^1",
|
||||
"@sap/eslint-plugin-cds": "^3",
|
||||
"@sap/cds-dk": "^7",
|
||||
"@sap/eslint-plugin-cds": "^2.6.1",
|
||||
"axios": "^1",
|
||||
"chai": "^4.3.4",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"chai-subset": "^1.6.0",
|
||||
"eslint": "^9",
|
||||
"semver": "^7"
|
||||
},
|
||||
"scripts": {
|
||||
@@ -39,8 +40,7 @@
|
||||
"jest": "npx jest --silent",
|
||||
"start": "cds watch fiori",
|
||||
"test": "npm run jest -- --silent",
|
||||
"test:hello": "cd hello && npm test",
|
||||
"lint": "eslint ."
|
||||
"test:hello": "cd hello && npm test"
|
||||
},
|
||||
"jest": {
|
||||
"testTimeout": 20000,
|
||||
@@ -53,6 +53,16 @@
|
||||
"parallel": true,
|
||||
"timeout": 6666
|
||||
},
|
||||
"cds": {
|
||||
"requires": {
|
||||
"db": {
|
||||
"kind": "sql",
|
||||
"[development]": {
|
||||
"model": "db/sqlite"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"private": true
|
||||
}
|
||||
@@ -17,7 +17,17 @@
|
||||
"[hybrid]": { "kind": "enterprise-messaging-shared" },
|
||||
"[production]": { "kind": "enterprise-messaging" }
|
||||
},
|
||||
"db": { "kind": "sql" }
|
||||
|
||||
"db": { "kind": "sql" },
|
||||
"[multimodule]": {
|
||||
"db": {
|
||||
"kind": "sqlite",
|
||||
"impl": "@cap-js/sqlite",
|
||||
"credentials": {
|
||||
"url": "../db.sqlite"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
const cds = require('@sap/cds')
|
||||
const { expect } = cds.test
|
||||
|
||||
describe('cds.ql → cqn', () => {
|
||||
|
||||
const cds = require('@sap/cds/lib')
|
||||
const { expect } = cds.test
|
||||
const Foo = { name: 'Foo' }
|
||||
const Books = { name: 'capire.bookshop.Books' }
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const cds = require('@sap/cds')
|
||||
const cds = require('@sap/cds/lib')
|
||||
|
||||
describe('cap/samples - Consuming Services locally', () => {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const cds = require('@sap/cds')
|
||||
const cds = require('@sap/cds/lib')
|
||||
|
||||
describe('cap/samples - Custom Handlers', () => {
|
||||
|
||||
@@ -8,10 +8,9 @@ describe('cap/samples - Custom Handlers', () => {
|
||||
})
|
||||
|
||||
it('should reject out-of-stock orders', async () => {
|
||||
await expect(POST `/browse/submitOrder ${{ book: 201, quantity: 5 }}`).to.be.fulfilled
|
||||
await expect(POST `/browse/submitOrder ${{ book: 201, quantity: 5 }}`).to.be.fulfilled
|
||||
await expect(POST `/browse/submitOrder ${{ book: 201, quantity: 5 }}`).to.be.rejectedWith(
|
||||
/409 - 5 exceeds stock for book #201/)
|
||||
await POST `/browse/submitOrder ${{ book: 201, quantity: 5 }}`
|
||||
await POST `/browse/submitOrder ${{ book: 201, quantity: 5 }}`
|
||||
await expect(POST `/browse/submitOrder ${{ book: 201, quantity: 5 }}`).to.be.rejectedWith(/409 - 5 exceeds stock for book #201/)
|
||||
const { data } = await GET`/admin/Books/201/stock/$value`
|
||||
expect(data).to.equal(2)
|
||||
})
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
// Quick hack: suppress deprecation warnings w/ Node22 caused by http-proxy (used by OData v2 proxy)
|
||||
// See also: https://github.com/http-party/node-http-proxy/pull/1666
|
||||
require('util')._extend = Object.assign
|
||||
|
||||
const cds = require('@sap/cds')
|
||||
const cds = require('@sap/cds/lib')
|
||||
|
||||
describe('cap/samples - Fiori APIs - v2', function() {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const cds = require('@sap/cds')
|
||||
const cds = require('@sap/cds/lib')
|
||||
|
||||
describe('cap/samples - Hello world!', () => {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const cds = require('@sap/cds')
|
||||
const cds = require('@sap/cds/lib')
|
||||
const { expect } = cds.test.in(__dirname,'..')
|
||||
|
||||
describe('cap/samples - Hierarchical Data', ()=>{
|
||||
@@ -77,27 +77,29 @@ describe('cap/samples - Hierarchical Data', ()=>{
|
||||
)
|
||||
})
|
||||
|
||||
it ('supports nested reads', ()=> expect (
|
||||
it ('supports nested reads', async()=>{
|
||||
expect (await
|
||||
SELECT.one.from (Cats, c=>{
|
||||
c.ID, c.name.as('parent'), c.children (c=>{
|
||||
c.name.as('child')
|
||||
})
|
||||
}) .where ({name:'Cat'})
|
||||
) .to.eventually.eql (
|
||||
) .to.eql (
|
||||
{ ID:101, parent:'Cat', children:[
|
||||
{ child:'Kitty' },
|
||||
{ child:'Catwoman' },
|
||||
]}
|
||||
))
|
||||
)
|
||||
})
|
||||
|
||||
it ('supports deeply nested reads', ()=> expect (
|
||||
SELECT.one.from (Cats, c=>{
|
||||
it ('supports deeply nested reads', async()=>{
|
||||
expect (await SELECT.one.from (Cats, c=>{
|
||||
c.ID, c.name, c.children (
|
||||
c => { c.name },
|
||||
{levels:3}
|
||||
)
|
||||
}) .where ({name:'Cat'})
|
||||
) .to.eventually.eql (
|
||||
) .to.eql (
|
||||
{ ID:101, name:'Cat', children:[
|
||||
{ name:'Kitty', children:[
|
||||
{ name:'Kitty Cat', children:[
|
||||
@@ -106,16 +108,18 @@ describe('cap/samples - Hierarchical Data', ()=>{
|
||||
{ name:'Catwoman', children:[
|
||||
{ name:'Catalina', children:[] } ]},
|
||||
]}
|
||||
))
|
||||
)
|
||||
})
|
||||
|
||||
it ('supports cascaded deletes', async()=>{
|
||||
const affectedRows = await DELETE.from (Cats) .where ({ID:[102,106]})
|
||||
expect (affectedRows) .to.be.greaterThan (0)
|
||||
await expect (SELECT`ID,name`.from(Cats) ).to.eventually.eql ([
|
||||
const expected = [
|
||||
{ ID:100, name:'Some Cats...' },
|
||||
{ ID:101, name:'Cat' },
|
||||
{ ID:108, name:'Catweazle' }
|
||||
])
|
||||
]
|
||||
expect ( await SELECT`ID,name`.from(Cats) ).to.eql (expected)
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const cds = require('@sap/cds')
|
||||
const cds = require('@sap/cds/lib')
|
||||
|
||||
describe('cap/samples - Localized Data', () => {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const cds = require('@sap/cds')
|
||||
const cds = require('@sap/cds/lib')
|
||||
|
||||
describe('cap/samples - Messaging', ()=>{
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const cds = require('@sap/cds')
|
||||
const cds = require('@sap/cds/lib')
|
||||
|
||||
describe('cap/samples - Bookshop APIs', () => {
|
||||
const { GET, expect, axios } = cds.test ('@capire/bookshop')
|
||||
@@ -8,10 +8,9 @@ describe('cap/samples - Bookshop APIs', () => {
|
||||
const { headers, status, data } = await GET `/browse/$metadata`
|
||||
expect(status).to.equal(200)
|
||||
expect(headers).to.contain({
|
||||
// 'content-type': 'application/xml', //> fails with 'application/xml;charset=utf-8', which is set by express
|
||||
'content-type': 'application/xml',
|
||||
'odata-version': '4.0',
|
||||
})
|
||||
expect(headers['content-type']).to.match(/application\/xml/)
|
||||
expect(data).to.contain('<EntitySet Name="Books" EntityType="CatalogService.Books">')
|
||||
expect(data).to.contain('<Annotation Term="Common.Label" String="Currency"/>')
|
||||
})
|
||||
@@ -29,8 +28,6 @@ describe('cap/samples - Bookshop APIs', () => {
|
||||
])
|
||||
})
|
||||
|
||||
describe('query options...', () => {
|
||||
|
||||
it('supports $search in multiple fields', async () => {
|
||||
const { data } = await GET `/browse/Books ${{
|
||||
params: { $search: 'Po', $select: `title,author` },
|
||||
@@ -89,7 +86,6 @@ describe('cap/samples - Bookshop APIs', () => {
|
||||
{ ID: 271, title: 'Catweazle' },
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
it('serves user info', async () => {
|
||||
const { data: alice } = await GET `/user/me`
|
||||
|
||||
Reference in New Issue
Block a user