@sap/cds-dk 4.9.7 → 6.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +77 -0
- package/bin/activate.js +4 -4
- package/bin/add.js +11 -5
- package/bin/bind.js +16 -28
- package/bin/build/all.js +2 -2
- package/bin/build/index.js +12 -19
- package/bin/cds.js +22 -19
- package/bin/compile/index.js +12 -3
- package/bin/deploy/index.js +15 -9
- package/bin/deploy/to-hana.js +4 -4
- package/bin/deploy/to-sqlite.js +1 -1
- package/bin/env.js +13 -4
- package/bin/eval.js +1 -1
- package/bin/fix-redirects.js +1 -1
- package/bin/import.js +44 -179
- package/bin/repl.js +1 -1
- package/bin/watch.js +10 -15
- package/lib/bind/BindingManager.js +87 -0
- package/lib/bind/bindingResolver.js +15 -87
- package/lib/bind/bindingUtil.js +18 -11
- package/lib/bind/cfKeyProvider.js +58 -29
- package/lib/bind/kubernetesCredentialsProvider.js +44 -21
- package/lib/bind/userCdsrcJsonStorageProvider.js +12 -18
- package/lib/cds.js +13 -0
- package/lib/client/base_command.js +3 -2
- package/lib/client/extend.js +6 -7
- package/lib/client/helper/fs_helper.js +7 -8
- package/lib/client/settings_manager.js +14 -10
- package/lib/compile/index.js +9 -10
- package/lib/compile/openapi/csdl2openapi.js +151 -43
- package/lib/compile/openapi/index.js +2 -2
- package/lib/compile/to-xsuaa.js +3 -2
- package/lib/import/common.js +342 -27
- package/lib/import/importapi.js +81 -13
- package/lib/import/message.js +4 -4
- package/lib/import/odata/index.js +141 -0
- package/lib/import/{utils → odata/metadataconverter}/MetadataConverter.js +2 -2
- package/lib/import/{utils → odata/metadataconverter}/MetadataConverterFactory.js +1 -1
- package/lib/import/{utils → odata/util}/MultiMap.js +0 -0
- package/lib/import/{v2parser.js → odata/v2parser.js} +405 -468
- package/lib/import/{v4parser.js → odata/v4parser.js} +311 -322
- package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Aggregation.V1.json +0 -0
- package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Authorization.V1.json +0 -0
- package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Capabilities.V1.json +0 -0
- package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Core.V1.json +0 -0
- package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Measures.V1.json +0 -0
- package/lib/import/{vocabularies → odata/vocabularies}/Org.OData.Validation.V1.json +0 -0
- package/lib/import/openapi/importOpenAPI.js +521 -0
- package/lib/import/openapi/index.js +19 -0
- package/lib/import/openapi/utilities.js +38 -0
- package/lib/index.js +1 -1
- package/lib/init/constants.js +7 -2
- package/lib/init/index.js +10 -3
- package/lib/init/template/_merging/existences.js +79 -19
- package/lib/init/template/approuter/files/mta.yaml.hbs +25 -11
- package/lib/init/template/approuter/files/package.json +1 -1
- package/lib/init/template/approuter/files/xs-app.json.hbs +7 -0
- package/lib/init/template/approuter/index.js +61 -54
- package/lib/init/template/auditlog/index.js +2 -2
- package/lib/init/template/data/index.js +2 -2
- package/lib/init/template/hana/files/mta.yaml.hbs +17 -17
- package/lib/init/template/hana/index.js +8 -4
- package/lib/init/template/helm/index.js +39 -0
- package/lib/init/template/helm/update/index.js +28 -0
- package/lib/init/template/java/index.js +7 -9
- package/lib/init/template/kibana-logging/index.js +5 -6
- package/lib/init/template/lint/index.js +1 -1
- package/lib/init/template/mta/index.js +4 -4
- package/lib/init/template/mtx/files/java/package.json +9 -9
- package/lib/init/template/mtx/files/mta.yaml.hbs +0 -7
- package/lib/init/template/mtx/files/xs-security.json.hbs +11 -20
- package/lib/init/template/mtx/index.js +50 -57
- package/lib/init/template/nodejs/files/package.json.hbs +2 -2
- package/lib/init/template/notebook/index.js +2 -0
- package/lib/init/template/templateBase.js +8 -6
- package/lib/init/template/xsuaa/index.js +9 -5
- package/lib/init/util/fsUtil.js +25 -10
- package/lib/init/util/logger.js +1 -1
- package/lib/init/util/mvnArchetypeUtil.js +4 -10
- package/lib/init/util/projectReader.js +17 -9
- package/lib/init/util/templateUtil.js +30 -34
- package/lib/k8s/ChartAdder.js +65 -0
- package/lib/k8s/ChartBuilder.js +186 -0
- package/lib/k8s/Context.js +71 -0
- package/lib/k8s/ImageUtil.js +21 -0
- package/lib/k8s/Model.d.ts +53 -0
- package/lib/k8s/auditlog/index.js +29 -0
- package/lib/k8s/auditlog/templates/auditlog.yaml +1 -0
- package/lib/k8s/buildModel.js +70 -0
- package/lib/k8s/connectivity/index.js +80 -0
- package/lib/k8s/connectivity/templates/connectivity-binding.yaml +9 -0
- package/lib/k8s/connectivity/templates/connectivity-proxy-info.yaml +20 -0
- package/lib/k8s/connectivity/templates/connectivity.yaml +1 -0
- package/lib/k8s/deployment/index.js +81 -0
- package/lib/k8s/deployment/subchart/Chart.yaml +6 -0
- package/lib/k8s/deployment/subchart/templates/_helpers.tpl +156 -0
- package/lib/k8s/deployment/subchart/templates/api-rule.yaml +24 -0
- package/lib/k8s/deployment/subchart/templates/deployment.yaml +110 -0
- package/lib/k8s/deployment/subchart/templates/network-policy.yaml +16 -0
- package/lib/k8s/deployment/subchart/templates/pod-disruption-budget.yaml +11 -0
- package/lib/k8s/deployment/subchart/templates/secret.yaml +10 -0
- package/lib/k8s/deployment/subchart/templates/service-binding.yaml +27 -0
- package/lib/k8s/deployment/subchart/templates/service.yaml +11 -0
- package/lib/k8s/deployment/subchart/values-lint.yaml +8 -0
- package/lib/k8s/deployment/subchart/values.schema.json +449 -0
- package/lib/k8s/deployment/subchart/values.yaml +76 -0
- package/lib/k8s/deployment/subchart-override/templates/_web_application_helpers.tpl +81 -0
- package/lib/k8s/destinations/index.js +40 -0
- package/lib/k8s/destinations/lib.js +16 -0
- package/lib/k8s/destinations/templates/destinations.yaml +1 -0
- package/lib/k8s/docker/push.js +8 -0
- package/lib/k8s/event-mesh/index.js +53 -0
- package/lib/k8s/event-mesh/lib.js +9 -0
- package/lib/k8s/event-mesh/templates/event-mesh.yaml +1 -0
- package/lib/k8s/hana-deployer/index.js +38 -0
- package/lib/k8s/hana-deployer/templates/hana-deployer-job.yaml +41 -0
- package/lib/k8s/helm/Release.js +80 -0
- package/lib/k8s/html5-apps-deployer/index.js +43 -0
- package/lib/k8s/html5-apps-deployer/templates/_html5_deployment_helpers.tpl +16 -0
- package/lib/k8s/html5-apps-deployer/templates/html5-apps-deployer-job.yaml +53 -0
- package/lib/k8s/html5-apps-repo-host/index.js +26 -0
- package/lib/k8s/html5-apps-repo-host/lib.js +16 -0
- package/lib/k8s/html5-apps-repo-host/templates/html5-apps-repo-host.yaml +1 -0
- package/lib/k8s/index.js +153 -0
- package/lib/k8s/modules.js +36 -0
- package/lib/k8s/multitenancy/index.js +24 -0
- package/lib/k8s/multitenancy/lib.js +25 -0
- package/lib/k8s/multitenancy/templates/saas-registry.yaml +19 -0
- package/lib/k8s/readProject.js +14 -0
- package/lib/k8s/resources/helm/chart/templates/NOTES.txt +11 -0
- package/lib/k8s/resources/helm/chart/templates/_deployment_helpers.tpl +221 -0
- package/lib/k8s/resources/helm/chart/templates/_helpers.tpl +167 -0
- package/lib/k8s/resources/helm/chart/templates/_sapcp_helpers.tpl +103 -0
- package/lib/k8s/util.js +186 -0
- package/lib/k8s/wrapFeature.js +55 -0
- package/lib/k8s/xsuaa/index.js +64 -0
- package/lib/k8s/xsuaa/lib.js +17 -0
- package/lib/k8s/xsuaa/templates/xsuaa.yaml +1 -0
- package/lib/lint/generators.js +1 -1
- package/lib/util/exec.js +1 -1
- package/lib/util/write.js +1 -1
- package/lib/watch/node-watch.js +43 -14
- package/npm-shrinkwrap.json +923 -2705
- package/package.json +5 -5
- package/lib/import/index.js +0 -235
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
function wrapFeature(name, impl) {
|
|
2
|
+
return async function (context) {
|
|
3
|
+
|
|
4
|
+
const isRequired = once(async function () {
|
|
5
|
+
const features = await context.get('features');
|
|
6
|
+
const isRequired = impl.isRequired ? (context => impl.isRequired(context)) : (() => false);
|
|
7
|
+
|
|
8
|
+
return features.has(name) || await isRequired(context);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const init = once(async function () {
|
|
12
|
+
const enabled = await isRequired();
|
|
13
|
+
if (enabled && impl.init) await impl.init(context);
|
|
14
|
+
return enabled;
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const handler = {
|
|
18
|
+
get(target, prop) {
|
|
19
|
+
if (typeof impl[prop] !== 'function') return undefined;
|
|
20
|
+
|
|
21
|
+
switch (prop) {
|
|
22
|
+
case 'addToChart':
|
|
23
|
+
return async (builder, values) => {
|
|
24
|
+
if (impl.addToChart && values[name] && values[name].enabled !== false)
|
|
25
|
+
return impl.addToChart(builder, values);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
default:
|
|
29
|
+
return async (...args) => {
|
|
30
|
+
if (await init()) {
|
|
31
|
+
return impl[prop](...args);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return new Proxy(impl, handler);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function once(func) {
|
|
43
|
+
let result;
|
|
44
|
+
let called;
|
|
45
|
+
|
|
46
|
+
return function () {
|
|
47
|
+
if (!called) {
|
|
48
|
+
result = func();
|
|
49
|
+
called = true;
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
module.exports = wrapFeature;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const { renderXsSecurityJson } = require('./lib');
|
|
2
|
+
const wrapFeature = require('../wrapFeature');
|
|
3
|
+
|
|
4
|
+
module.exports = wrapFeature('xsuaa', {
|
|
5
|
+
async getXsuaaRequiresServiceName(context) {
|
|
6
|
+
const env = await context.get('env');
|
|
7
|
+
if (env.requires.auth && env.requires.auth.kind === 'xsuaa') return 'auth';
|
|
8
|
+
else if (env.requires.uaa && env.requires.uaa.kind === 'xsuaa') return 'uaa';
|
|
9
|
+
else undefined;
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
async isRequired(context) {
|
|
13
|
+
return !!await this.getXsuaaRequiresServiceName(context)
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
async init(context) {
|
|
17
|
+
const model = await context.get('model');
|
|
18
|
+
const { services } = model;
|
|
19
|
+
delete services.auth;
|
|
20
|
+
delete services.xsuaa;
|
|
21
|
+
delete services.uaa;
|
|
22
|
+
// remove database bindings as they need a workaround
|
|
23
|
+
delete services.db;
|
|
24
|
+
delete services['db-mt'];
|
|
25
|
+
|
|
26
|
+
this.bindingName = await this.getXsuaaRequiresServiceName(context)
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
async getChartCapabilities(context) {
|
|
30
|
+
const model = await context.get('model');
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
xsuaa: {
|
|
34
|
+
serviceOfferingName: 'xsuaa',
|
|
35
|
+
servicePlanName: 'application',
|
|
36
|
+
parameters: {
|
|
37
|
+
xsappname: model.app.name
|
|
38
|
+
},
|
|
39
|
+
config: 'xs-security.json'
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
// eslint-disable-next-line no-unused-vars
|
|
45
|
+
async getServiceBindings(context) {
|
|
46
|
+
return {
|
|
47
|
+
[this.bindingName || 'auth']: {
|
|
48
|
+
serviceInstanceName: 'xsuaa'
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
async addToChart(builder, { xsuaa }) {
|
|
54
|
+
await builder.addAllTemplates(__dirname);
|
|
55
|
+
|
|
56
|
+
const { config } = xsuaa;
|
|
57
|
+
if (config) {
|
|
58
|
+
if (!await builder.addChartFile(config, { optional: true })) {
|
|
59
|
+
const xsSecurityJson = await renderXsSecurityJson(builder.rootPath, config);
|
|
60
|
+
await builder.writeChartFile(config, xsSecurityJson);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const cds = require('../../compile')
|
|
2
|
+
const Path = require('path');
|
|
3
|
+
|
|
4
|
+
async function renderXsSecurityJson(projectPath) {
|
|
5
|
+
const xsSecurityJson = await(async () => {
|
|
6
|
+
try {
|
|
7
|
+
const models = await cds.load(Path.join(projectPath, cds.env.folders.srv))
|
|
8
|
+
return cds.compile.to.xsuaa(models)
|
|
9
|
+
} catch (error) { /* ignore */ }
|
|
10
|
+
})() || { scopes: [], attributes: [], 'role-templates': [], 'authorities-inheritance': false }
|
|
11
|
+
|
|
12
|
+
return JSON.stringify(xsSecurityJson, null, 2);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = {
|
|
16
|
+
renderXsSecurityJson
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{{- include "cap.service-instance" . }}
|
package/lib/lint/generators.js
CHANGED
|
@@ -2,7 +2,7 @@ const fs = require("fs");
|
|
|
2
2
|
const os = require("os");
|
|
3
3
|
const cp = require("child_process");
|
|
4
4
|
const path = require("path");
|
|
5
|
-
const { mkdirp } = require("@sap/cds
|
|
5
|
+
const { mkdirp } = require("@sap/cds").utils;
|
|
6
6
|
const term = require("../util/term");
|
|
7
7
|
|
|
8
8
|
const IS_WIN = os.platform() === "win32";
|
package/lib/util/exec.js
CHANGED
package/lib/util/write.js
CHANGED
package/lib/watch/node-watch.js
CHANGED
|
@@ -9,9 +9,8 @@ module.exports = ({ cwd, script, ext, ignore=RegExp(), env={}, delay=200, option
|
|
|
9
9
|
const emitter = new EventEmitter
|
|
10
10
|
|
|
11
11
|
const killAndExit = (sig) => {
|
|
12
|
-
DEBUG && DEBUG('
|
|
13
|
-
|
|
14
|
-
_kill (child, () => process.exit())
|
|
12
|
+
DEBUG && DEBUG('\nreceived signal:', sig)
|
|
13
|
+
_kill (child, process.exit)
|
|
15
14
|
}
|
|
16
15
|
process.on('SIGTERM', killAndExit)
|
|
17
16
|
process.on('SIGINT', killAndExit)
|
|
@@ -21,6 +20,7 @@ module.exports = ({ cwd, script, ext, ignore=RegExp(), env={}, delay=200, option
|
|
|
21
20
|
const restart = _coalesceEvents(delay, (events) => {
|
|
22
21
|
DEBUG && DEBUG('>> Events:', events)
|
|
23
22
|
_kill (child, () => {
|
|
23
|
+
DEBUG && console.trace('Restart')
|
|
24
24
|
const execArgv = [...process.execArgv]
|
|
25
25
|
events.forEach(evt => {
|
|
26
26
|
if (evt.type && evt.type.startsWith('--')) execArgv.push(evt.type)
|
|
@@ -32,7 +32,7 @@ module.exports = ({ cwd, script, ext, ignore=RegExp(), env={}, delay=200, option
|
|
|
32
32
|
const updated = events.filter(evt => evt.type && evt.type === 'update').map(evt => evt.name)
|
|
33
33
|
emitter.emit ('restart', updated)
|
|
34
34
|
child = fork (script, { cwd, env, stdio:'inherit', execArgv }, (err)=>{
|
|
35
|
-
if (err)
|
|
35
|
+
if (err) console.error (err)
|
|
36
36
|
})
|
|
37
37
|
child.on('message', msg => {
|
|
38
38
|
if (msg === 'restart') return restart()
|
|
@@ -48,7 +48,7 @@ module.exports = ({ cwd, script, ext, ignore=RegExp(), env={}, delay=200, option
|
|
|
48
48
|
const watch = require('node-watch')
|
|
49
49
|
const include = RegExp(`\\.(${ext.replace(/,/g,'|')})$`)
|
|
50
50
|
const filter = f => !ignore.test(f) && include.test(f)
|
|
51
|
-
watch (process.cwd(),{ recursive:true, filter, delay:0 }, restart)
|
|
51
|
+
watch (cwd||process.cwd(),{ recursive:true, filter, delay:0 }, restart)
|
|
52
52
|
|
|
53
53
|
// Live commands...
|
|
54
54
|
const readline = require('readline')
|
|
@@ -64,8 +64,8 @@ module.exports = ({ cwd, script, ext, ignore=RegExp(), env={}, delay=200, option
|
|
|
64
64
|
})
|
|
65
65
|
|
|
66
66
|
emitter.restart = restart
|
|
67
|
-
emitter.stop = () =>
|
|
68
|
-
emitter.setEnv
|
|
67
|
+
emitter.stop = () => _kill(child, () => false)
|
|
68
|
+
emitter.setEnv = (name, value) => {
|
|
69
69
|
if (typeof value === "undefined") {
|
|
70
70
|
delete env[name]
|
|
71
71
|
} else {
|
|
@@ -98,16 +98,45 @@ function _coalesceEvents(delay, fn) {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
/*
|
|
102
|
+
* Ensures the given child process gets killed in different environments
|
|
103
|
+
*/
|
|
104
|
+
function _kill (proc, cb=()=>{}) {
|
|
105
|
+
if (!proc) return cb()
|
|
106
|
+
if (proc[_pending]) return // safeguard against repeated calls for the same process
|
|
107
|
+
proc[_pending] = true
|
|
108
|
+
const fn = () => { delete proc[_pending]; return cb(); }
|
|
103
109
|
|
|
110
|
+
const waitTime = parseInt(process.env.CDS_WATCH_KILL_DELAY) || 500
|
|
104
111
|
// On Windows, child_process.kill() abruptly kills the process (https://nodejs.org/api/child_process.html#subprocesskillsignal)
|
|
105
112
|
// Server has cleanup code to run, so send a custom message and give it a bit time.
|
|
106
113
|
if (process.platform === 'win32') {
|
|
107
|
-
proc.send({
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
114
|
+
proc.send({ close: true }, () => {}) // see @sap/cds/bin/serve.js
|
|
115
|
+
setTimeout(()=> {
|
|
116
|
+
proc.kill()
|
|
117
|
+
DEBUG && DEBUG('Killed process', proc.pid)
|
|
118
|
+
fn()
|
|
119
|
+
}, waitTime)
|
|
120
|
+
return
|
|
112
121
|
}
|
|
122
|
+
|
|
123
|
+
// first kill normally (using SIGTERM)
|
|
124
|
+
let killed = false
|
|
125
|
+
proc.on('exit',() => {
|
|
126
|
+
if (!killed) { killed = true
|
|
127
|
+
DEBUG && DEBUG('Killed process', proc.pid)
|
|
128
|
+
fn()
|
|
129
|
+
}
|
|
130
|
+
}).kill()
|
|
131
|
+
|
|
132
|
+
// fallback for misbehaving processes: SIGKILL it after some time
|
|
133
|
+
setTimeout(()=> {
|
|
134
|
+
if (!killed) { killed = true
|
|
135
|
+
proc.kill('SIGKILL')
|
|
136
|
+
DEBUG && DEBUG('Killed process (forcefully)', proc.pid)
|
|
137
|
+
fn()
|
|
138
|
+
}
|
|
139
|
+
}, waitTime)
|
|
113
140
|
}
|
|
141
|
+
|
|
142
|
+
const _pending = Symbol.for('sap.cds.watch.pendingKill')
|