initialize mtx

This commit is contained in:
Wolfgang Koch
2021-04-29 10:10:09 +02:00
parent 2536f36596
commit 594043e55c
15 changed files with 5582 additions and 0 deletions

1
multitenancy/.cdsrc.json Normal file
View File

@@ -0,0 +1 @@
{}

29
multitenancy/.gitignore vendored Normal file
View File

@@ -0,0 +1,29 @@
# CAP multitenancy
_out
*.db
connection.properties
default-*.json
gen/
node_modules/
target/
# Web IDE, App Studio
.che/
.gen/
# MTA
*_mta_build_tmp
*.mtar
mta_archives/
# Other
.DS_Store
*.orig
*.log
*.iml
*.flattened-pom.xml
# IDEs
# .vscode
# .idea

20
multitenancy/.vscode/extensions.json vendored Normal file
View File

@@ -0,0 +1,20 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
// List of extensions which should be recommended for users of this workspace.
"recommendations": [
// >>>>>>>> Add CDS Editor here as soon it is available of vscode marketplace!,
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"mechatroner.rainbow-csv",
"humao.rest-client",
"alexcvzz.vscode-sqlite",
"hbenl.vscode-mocha-test-adapter",
"sdras.night-owl"
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": [
]
}

15
multitenancy/.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"command": "cds run --with-mocks --in-memory?",
"name": "cds run",
"request": "launch",
"type": "node-terminal",
"skipFiles": [ "<node_internals>/**" ]
}
]
}

7
multitenancy/.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,7 @@
{
"files.exclude": {
"**/.gitignore": true,
"**/.git": true,
"**/.vscode": true
}
}

25
multitenancy/.vscode/tasks.json vendored Normal file
View File

@@ -0,0 +1,25 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "cds watch",
"command": "cds",
"args": ["watch"],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"type": "shell",
"label": "cds run",
"command": "cds",
"args": ["run", "--with-mocks", "--in-memory?"],
"problemMatcher": []
}
]
}

25
multitenancy/README.md Normal file
View File

@@ -0,0 +1,25 @@
# Getting Started
Welcome to your new project.
It contains these folders and files, following our recommended project layout:
File or Folder | Purpose
---------|----------
`app/` | content for UI frontends goes here
`db/` | your domain models and data go here
`srv/` | your service models and code go here
`package.json` | project metadata and configuration
`readme.md` | this getting started guide
## Next Steps
- Open a new terminal and run `cds watch`
- (in VS Code simply choose _**Terminal** > Run Task > cds watch_)
- Start adding content, for example, a [db/schema.cds](db/schema.cds).
## Learn More
Learn more at https://cap.cloud.sap/docs/get-started/.

View File

@@ -0,0 +1,6 @@
namespace sap.capire.multitenancy;
using { sap.capire.bookshop.Books } from '../../bookshop';
using { sap.capire.orders.Orders } from '../../orders';
using { sap.capire.orders.Orders_Items } from '../../orders';
using { Country, managed, cuid } from '@sap/cds/common';

View File

@@ -0,0 +1,136 @@
{
"file_suffixes": {
"csv": {
"plugin_name": "com.sap.hana.di.tabledata.source"
},
"hdbafllangprocedure": {
"plugin_name": "com.sap.hana.di.afllangprocedure"
},
"hdbanalyticprivilege": {
"plugin_name": "com.sap.hana.di.analyticprivilege"
},
"hdbcalculationview": {
"plugin_name": "com.sap.hana.di.calculationview"
},
"hdbcollection": {
"plugin_name": "com.sap.hana.di.collection"
},
"hdbconstraint": {
"plugin_name": "com.sap.hana.di.constraint"
},
"hdbdropcreatetable": {
"plugin_name": "com.sap.hana.di.dropcreatetable"
},
"hdbflowgraph": {
"plugin_name": "com.sap.hana.di.flowgraph"
},
"hdbfunction": {
"plugin_name": "com.sap.hana.di.function"
},
"hdbgraphworkspace": {
"plugin_name": "com.sap.hana.di.graphworkspace"
},
"hdbhadoopmrjob": {
"plugin_name": "com.sap.hana.di.virtualfunctionpackage.hadoop"
},
"hdbindex": {
"plugin_name": "com.sap.hana.di.index"
},
"hdblibrary": {
"plugin_name": "com.sap.hana.di.library"
},
"hdbmigrationtable": {
"plugin_name": "com.sap.hana.di.table.migration"
},
"hdbprocedure": {
"plugin_name": "com.sap.hana.di.procedure"
},
"hdbprojectionview": {
"plugin_name": "com.sap.hana.di.projectionview"
},
"hdbprojectionviewconfig": {
"plugin_name": "com.sap.hana.di.projectionview.config"
},
"hdbreptask": {
"plugin_name": "com.sap.hana.di.reptask"
},
"hdbresultcache": {
"plugin_name": "com.sap.hana.di.resultcache"
},
"hdbrole": {
"plugin_name": "com.sap.hana.di.role"
},
"hdbroleconfig": {
"plugin_name": "com.sap.hana.di.role.config"
},
"hdbsearchruleset": {
"plugin_name": "com.sap.hana.di.searchruleset"
},
"hdbsequence": {
"plugin_name": "com.sap.hana.di.sequence"
},
"hdbstatistics": {
"plugin_name": "com.sap.hana.di.statistics"
},
"hdbstructuredprivilege": {
"plugin_name": "com.sap.hana.di.structuredprivilege"
},
"hdbsynonym": {
"plugin_name": "com.sap.hana.di.synonym"
},
"hdbsynonymconfig": {
"plugin_name": "com.sap.hana.di.synonym.config"
},
"hdbsystemversioning": {
"plugin_name": "com.sap.hana.di.systemversioning"
},
"hdbtable": {
"plugin_name": "com.sap.hana.di.table"
},
"hdbtabledata": {
"plugin_name": "com.sap.hana.di.tabledata"
},
"hdbtabletype": {
"plugin_name": "com.sap.hana.di.tabletype"
},
"hdbtrigger": {
"plugin_name": "com.sap.hana.di.trigger"
},
"hdbview": {
"plugin_name": "com.sap.hana.di.view"
},
"hdbvirtualfunction": {
"plugin_name": "com.sap.hana.di.virtualfunction"
},
"hdbvirtualfunctionconfig": {
"plugin_name": "com.sap.hana.di.virtualfunction.config"
},
"hdbvirtualpackagehadoop": {
"plugin_name": "com.sap.hana.di.virtualpackage.hadoop"
},
"hdbvirtualpackagesparksql": {
"plugin_name": "com.sap.hana.di.virtualpackage.sparksql"
},
"hdbvirtualprocedure": {
"plugin_name": "com.sap.hana.di.virtualprocedure"
},
"hdbvirtualprocedureconfig": {
"plugin_name": "com.sap.hana.di.virtualprocedure.config"
},
"hdbvirtualtable": {
"plugin_name": "com.sap.hana.di.virtualtable"
},
"hdbvirtualtableconfig": {
"plugin_name": "com.sap.hana.di.virtualtable.config"
},
"properties": {
"plugin_name": "com.sap.hana.di.tabledata.properties"
},
"tags": {
"plugin_name": "com.sap.hana.di.tabledata.properties"
},
"txt": {
"plugin_name": "com.sap.hana.di.copyonly"
}
}
}

89
multitenancy/mta.yaml Normal file
View File

@@ -0,0 +1,89 @@
## Generated mta.yaml based on template version 0.4.0
## appName = multitenancy
## language=nodejs; multitenant=true
## approuter=
_schema-version: '3.1'
ID: multitenancy
version: 1.0.0
description: "A simple CAP project."
parameters:
enable-parallel-deployments: true
build-parameters:
before-all:
- builder: custom
commands:
- npm install --production
- npx -p @sap/cds-dk cds build --production
modules:
# --------------------- SERVER MODULE ------------------------
- name: multitenancy-srv
# ------------------------------------------------------------
type: nodejs
path: gen/srv
properties:
SAP_JWT_TRUST_ACL: [{"clientid":"*","identityzone":"sap-provisioning"}] # Trust between server and SaaS Manager
requires:
# Resources extracted from CAP configuration
- name: multitenancy-db-mt
- name: multitenancy-uaa-mt
- name: multitenancy-registry
provides:
- name: srv-api # required by consumers of CAP services (e.g. approuter)
properties:
srv-url: ${default-url}
- name: mtx-api # potentially required by approuter
properties:
mtx-url: ${default-url}
resources:
# services extracted from CAP configuration
# 'service-plan' can be configured via 'cds.requires.<name>.vcap.plan'
# ------------------------------------------------------------
- name: multitenancy-db-mt
# ------------------------------------------------------------
type: org.cloudfoundry.managed-service
parameters:
service: service-manager
service-plan: container
properties:
hdi-service-name: ${service-name}
# ------------------------------------------------------------
- name: multitenancy-uaa-mt
# ------------------------------------------------------------
type: org.cloudfoundry.managed-service
parameters:
service: xsuaa
service-plan: application
path: ./xs-security.json
config:
xsappname: multitenancy-${space} # name + space dependency
tenant-mode: shared
- name: multitenancy-registry
type: org.cloudfoundry.managed-service
requires:
- name: multitenancy-uaa-mt
- name: mtx-api
properties:
prop: ~{mtx-url}
parameters:
param: ~{mtx-url}
parameters:
service: saas-registry
service-plan: application
config:
xsappname: multitenancy-${space}
appName: multitenancy
displayName: multitenancy
description: A simple CAP project.
#category: 'Category'
appUrls:
onSubscription: ~{mtx-api/mtx-url}/mtx/v1/provisioning/tenant/{tenantId}
onSubscriptionAsync: false
onUnSubscriptionAsync: false
callbackTimeoutMillis: 300000

5086
multitenancy/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

84
multitenancy/package.json Normal file
View File

@@ -0,0 +1,84 @@
{
"name": "multitenancy",
"version": "1.0.0",
"description": "A simple CAP project.",
"repository": "<Add your repository here>",
"license": "UNLICENSED",
"private": true,
"dependencies": {
"@capire/fiori": "../fiori",
"@sap/cds": "5.0.6",
"@sap/cds-mtx": "1.2.1",
"@sap/hana-client": "^2",
"@sap/hdi-deploy": "^4",
"@sap/instance-manager": "^2",
"@sap/xssec": "^3",
"express": "^4",
"passport": "^0"
},
"devDependencies": {
"sqlite3": "^5.0.2"
},
"scripts": {
"start": "cds run"
},
"eslintConfig": {
"extends": "eslint:recommended",
"env": {
"es2020": true,
"node": true,
"jest": true,
"mocha": true
},
"globals": {
"SELECT": true,
"INSERT": true,
"UPDATE": true,
"DELETE": true,
"CREATE": true,
"DROP": true,
"CDL": true,
"CQL": true,
"CXL": true,
"cds": true
},
"rules": {
"no-console": "off",
"require-atomic-updates": "off"
}
},
"cds": {
"requires": {
"multitenancy": true,
"auth": {
"strategy": "JWT"
},
"db": {
"kind": "hana",
"vcap": {
"label": "service-manager"
}
},
"uaa": {
"kind": "xsuaa"
}
},
"hana": {
"deploy-format": "hdbtable"
},
"mtx": {
"element-prefix": "Z_",
"namespace-blacklist": [
"com.sap.",
"sap."
],
"entity-whitelist": [],
"service-whitelist": []
},
"auth": {
"passport": {
"strategy": "JWT"
}
}
}
}

7
multitenancy/server.js Normal file
View File

@@ -0,0 +1,7 @@
const cds = require ('@sap/cds');
cds.on('bootstrap', async app => {
await cds.mtx.in(app);
});
module.exports = cds.server;

View File

@@ -0,0 +1,15 @@
using {sap.capire.bookshop as bookshop } from '../../bookshop/db/schema';
using {sap.capire.orders as orders } from '../../orders/db/schema';
service MultitenancyService {
entity Books as projection on bookshop.Books;
entity Orders as projection on orders.Orders;
entity Orders_Items as projection on orders.Orders_Items;
}
using AdminService from '../../bookshop/srv/admin-service';
using CatalogService from '../../bookshop/srv/cat-service';
annotate AdminService with @restrict : false;
annotate CatalogService with @restrict : false;

View File

@@ -0,0 +1,37 @@
{
"xsappname": "multitenancy-${space}",
"tenant-mode": "shared",
"scopes": [
{ "name": "$XSAPPNAME.ExtendCDS", "description": "Extend CDS application" },
{ "name": "$XSAPPNAME.ExtendCDSdelete", "description": "Extend CDS application with undeploy" },
{ "name": "$XSAPPNAME.MtxDiagnose", "description": "Diagnose MTX sidecar" },
{
"name": "$XSAPPNAME.Callback",
"description": "With this scope set, the callbacks for subscribe, unsubscribe and getDependencies can be called.",
"grant-as-authority-to-apps": [
"$XSAPPNAME(application,sap-provisioning,tenant-onboarding)"
]
}
],
"authorities": [
"$XSAPPNAME.MtxDiagnose"
],
"role-templates": [
{
"name": "ExtensionDeveloper",
"description": "Extend application",
"scope-references": [
"$XSAPPNAME.ExtendCDS"
],
"attribute-references": []
},
{
"name": "ExtensionDeveloperUndeploy",
"description": "Undeploy extension",
"scope-references": [
"$XSAPPNAME.ExtendCDSdelete"
],
"attribute-references": []
}
]
}