Compare commits

..

2 Commits

Author SHA1 Message Date
Robin de Silva Jayasinghe
61d6c0d58f shared db at design- and runtime 2024-04-24 15:56:47 +02:00
Robin de Silva Jayasinghe
4179493ce7 intial change to add support for shared schema 2024-04-17 16:03:49 +02:00
22 changed files with 4239 additions and 3453 deletions

31
.eslintrc Normal file
View 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": "_" }]
}
}

View File

@@ -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

View File

@@ -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": {

43
bookstore/mta.yaml Normal file
View 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

View File

@@ -21,14 +21,32 @@
"model": "@capire/orders" "model": "@capire/orders"
}, },
"messaging": { "messaging": {
"[development]": { "kind": "file-based-messaging" }, "[development]": {
"[hybrid]": { "kind": "enterprise-messaging-shared" }, "kind": "file-based-messaging"
"[production]": { "kind": "enterprise-messaging" }
}, },
"[hybrid]": {
"kind": "enterprise-messaging-shared"
},
"[production]": {
"kind": "enterprise-messaging"
}
},
"db": { "kind": "sql" },
"[multimodule]": {
"db": { "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
View 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';

View File

@@ -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'
}
}
]

View 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"
}
}

View 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
}
]
}

View File

@@ -1 +1,2 @@
using from './db/common'; using from './db/common';
using from './app/services';

69
fiori/mta.yaml Normal file
View 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

View File

@@ -38,6 +38,15 @@
"db": { "db": {
"kind": "sql" "kind": "sql"
}, },
"[multimodule]": {
"db": {
"kind": "sqlite",
"impl": "@cap-js/sqlite",
"credentials": {
"url": "../db.sqlite"
}
}
},
"db-ext": { "db-ext": {
"[development]": { "[development]": {
"model": "db/sqlite" "model": "db/sqlite"

22
fiori/xs-security.json Normal file
View 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"
]
}

27
mta.yaml Normal file
View 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

View 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"
}
}

View 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
View 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

View File

@@ -4,5 +4,19 @@
"dependencies": { "dependencies": {
"@capire/common": "*", "@capire/common": "*",
"@sap/cds": ">=5" "@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
View File

@@ -0,0 +1,5 @@
{
"scopes": [],
"attributes": [],
"role-templates": []
}

1012
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -5,6 +5,7 @@
"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-cloud-sdk/resilience": "^3.14.0",
"@sap/cds": ">=7" "@sap/cds": ">=7"
}, },
"workspaces": [ "workspaces": [
@@ -21,12 +22,12 @@
], ],
"devDependencies": { "devDependencies": {
"@cap-js/sqlite": "^1", "@cap-js/sqlite": "^1",
"@sap/eslint-plugin-cds": "^3", "@sap/cds-dk": "^7",
"@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 +40,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,
@@ -53,6 +53,16 @@
"parallel": true, "parallel": true,
"timeout": 6666 "timeout": 6666
}, },
"cds": {
"requires": {
"db": {
"kind": "sql",
"[development]": {
"model": "db/sqlite"
}
}
}
},
"license": "SEE LICENSE IN LICENSE", "license": "SEE LICENSE IN LICENSE",
"private": true "private": true
} }

View File

@@ -17,7 +17,17 @@
"[hybrid]": { "kind": "enterprise-messaging-shared" }, "[hybrid]": { "kind": "enterprise-messaging-shared" },
"[production]": { "kind": "enterprise-messaging" } "[production]": { "kind": "enterprise-messaging" }
}, },
"db": { "kind": "sql" }
"db": { "kind": "sql" },
"[multimodule]": {
"db": {
"kind": "sqlite",
"impl": "@cap-js/sqlite",
"credentials": {
"url": "../db.sqlite"
}
}
}
} }
} }
} }