@sap/cds-dk 6.1.1 → 6.1.4
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 +26 -0
- package/bin/build/all.js +10 -4
- package/bin/compile/index.js +1 -1
- package/bin/login.js +15 -5
- package/bin/subscribe.js +1 -1
- package/lib/cds.js +2 -3
- package/lib/client/activate.js +16 -15
- package/lib/client/auth_manager.js +3 -2
- package/lib/client/base_command.js +4 -6
- package/lib/client/extend.js +2 -1
- package/lib/client/helper/errors.js +11 -0
- package/lib/client/helper/logging.js +3 -10
- package/lib/client/params.js +5 -4
- package/lib/client/pull.js +6 -9
- package/lib/client/push.js +10 -14
- package/lib/client/settings_manager.js +9 -8
- package/lib/import/odata/v2parser.js +50 -25
- package/lib/import/odata/v4parser.js +7 -0
- package/lib/init/constants.js +1 -1
- package/lib/init/template/_merging/registry-mta.js +2 -8
- package/lib/init/template/approuter/files/xs-app.json.hbs +7 -7
- package/lib/init/template/approuter/index.js +2 -2
- package/lib/init/template/data/index.js +2 -4
- package/lib/init/template/nodejs/files/package.json.hbs +1 -1
- package/lib/init/util/templateUtil.js +8 -8
- package/lib/k8s/ChartAdder.js +4 -2
- package/lib/k8s/ChartBuilder.js +1 -1
- package/lib/k8s/resources/helm/chart/schemas/values.root.schema.json +11 -0
- package/lib/k8s/resources/helm/chart/{values.schema.json → schemas/values.schema.json} +30 -0
- package/lib/lint/io.js +0 -1
- package/npm-shrinkwrap.json +114 -398
- package/package.json +1 -1
|
@@ -448,38 +448,63 @@ function _getServiceEntityProperty(
|
|
|
448
448
|
propertyJson = propertyJson + '"key": true,\n';
|
|
449
449
|
}
|
|
450
450
|
if (isCollection === 1) {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
451
|
+
//if annotations to be added
|
|
452
|
+
if (edmxncdsdatatype[dataType + "_a"] && cdsDataType != "cds.Date") {
|
|
453
|
+
if (dataType === 'Edm.Stream')
|
|
454
|
+
propertyJson = propertyJson + '"@Core.MediaType": "application/octet-stream",\n';
|
|
455
|
+
else
|
|
456
|
+
propertyJson = propertyJson + '"@odata.Type": "' + dataType + '",\n';
|
|
457
|
+
}
|
|
454
458
|
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
propertyJson = propertyJson + '
|
|
459
|
-
|
|
460
|
-
propertyJson = propertyJson + ',\n"@odata.Type": "' + dataType + '"';
|
|
461
|
-
}
|
|
459
|
+
//adding precision in case of DateTime datatypes
|
|
460
|
+
if ((dataType === "Edm.DateTimeOffset" || dataType === "Edm.DateTime") && cdsDataType != "cds.Date") {
|
|
461
|
+
if (!precision || precision === -1) precision = 0;
|
|
462
|
+
propertyJson = propertyJson + '"@odata.Precision": ' + precision + ',\n';
|
|
463
|
+
}
|
|
462
464
|
|
|
463
|
-
|
|
464
|
-
propertyJson = propertyJson + '
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
465
|
+
propertyJson = propertyJson + '"items": { \n'
|
|
466
|
+
propertyJson = propertyJson + '"type":"' + cdsDataType + '"';
|
|
467
|
+
|
|
468
|
+
if (length && length > 0) {
|
|
469
|
+
propertyJson = propertyJson + ',\n"length":' + length;
|
|
470
|
+
} else if (precision && precision > 0 && hasInvalidPrecision === false) {
|
|
471
|
+
propertyJson = propertyJson + ',\n"precision":' + precision;
|
|
472
|
+
if (scale && scale > 0) {
|
|
473
|
+
propertyJson = propertyJson + ',\n"scale":' + scale;
|
|
474
|
+
} else {
|
|
475
|
+
propertyJson = propertyJson + ',\n"scale":' + 0;
|
|
476
|
+
}
|
|
471
477
|
}
|
|
478
|
+
propertyJson = propertyJson + '\n}'
|
|
472
479
|
}
|
|
480
|
+
else{
|
|
481
|
+
propertyJson = propertyJson + '"type":"' + cdsDataType + '"';
|
|
482
|
+
//if annotations to be added
|
|
483
|
+
if (edmxncdsdatatype[dataType + "_a"] && cdsDataType != "cds.Date") {
|
|
484
|
+
if (dataType === 'Edm.Stream')
|
|
485
|
+
propertyJson = propertyJson + ',\n"@Core.MediaType": "application/octet-stream"';
|
|
486
|
+
else
|
|
487
|
+
propertyJson = propertyJson + ',\n"@odata.Type": "' + dataType + '"';
|
|
488
|
+
}
|
|
473
489
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
if (
|
|
477
|
-
|
|
478
|
-
|
|
490
|
+
if (length && length > 0) {
|
|
491
|
+
propertyJson = propertyJson + ',\n"length":' + length;
|
|
492
|
+
} else if (precision && precision > 0 && hasInvalidPrecision === false) {
|
|
493
|
+
propertyJson = propertyJson + ',\n"precision":' + precision;
|
|
494
|
+
if (scale && scale > 0) {
|
|
495
|
+
propertyJson = propertyJson + ',\n"scale":' + scale;
|
|
496
|
+
} else {
|
|
497
|
+
propertyJson = propertyJson + ',\n"scale":' + 0;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
479
500
|
|
|
480
|
-
|
|
481
|
-
|
|
501
|
+
//adding precision in case of DateTime datatypes
|
|
502
|
+
if ((dataType === "Edm.DateTimeOffset" || dataType === "Edm.DateTime") && cdsDataType != "cds.Date") {
|
|
503
|
+
if (!precision || precision === -1) precision = 0;
|
|
504
|
+
propertyJson = propertyJson + ',\n"@odata.Precision": ' + precision;
|
|
505
|
+
}
|
|
482
506
|
}
|
|
507
|
+
|
|
483
508
|
if (documentation != -1 && documentation) {
|
|
484
509
|
propertyJson = propertyJson + ',\n"doc":"' + documentation + '"';
|
|
485
510
|
}
|
|
@@ -138,6 +138,13 @@ function _includeExternalNamespaceAnnotation(source, target) {
|
|
|
138
138
|
|
|
139
139
|
function _typeWithCollections(property, type, isCollection) {
|
|
140
140
|
if (isCollection === true) {
|
|
141
|
+
let typeKeys = Object.keys(type);
|
|
142
|
+
for (let i = 0; i < typeKeys.length; i++) {
|
|
143
|
+
if(typeKeys[i].startsWith("@")){
|
|
144
|
+
property[typeKeys[i]] = type[typeKeys[i]];
|
|
145
|
+
delete type[typeKeys[i]];
|
|
146
|
+
}
|
|
147
|
+
}
|
|
141
148
|
property.items = type;
|
|
142
149
|
} else {
|
|
143
150
|
Object.assign(property, type);
|
package/lib/init/constants.js
CHANGED
|
@@ -233,13 +233,10 @@ const approuterExtensibility = {
|
|
|
233
233
|
in: 'routes',
|
|
234
234
|
where: [{
|
|
235
235
|
property: 'source',
|
|
236
|
-
isEqualTo: '
|
|
236
|
+
isEqualTo: '^/-/cds/.*'
|
|
237
237
|
}, {
|
|
238
238
|
property: 'destination',
|
|
239
239
|
isEqualTo: 'mtx-api',
|
|
240
|
-
}, {
|
|
241
|
-
property: 'target',
|
|
242
|
-
isEqualTo: '$1',
|
|
243
240
|
}, {
|
|
244
241
|
property: 'authenticationType',
|
|
245
242
|
isEqualTo: 'none',
|
|
@@ -251,13 +248,10 @@ const approuterExtensibilityJava = {
|
|
|
251
248
|
in: 'routes',
|
|
252
249
|
where: [{
|
|
253
250
|
property: 'source',
|
|
254
|
-
isEqualTo: '
|
|
251
|
+
isEqualTo: '^/-/cds/.*'
|
|
255
252
|
}, {
|
|
256
253
|
property: 'destination',
|
|
257
254
|
isEqualTo: 'mtx-api',
|
|
258
|
-
}, {
|
|
259
|
-
property: 'target',
|
|
260
|
-
isEqualTo: '$1',
|
|
261
255
|
}, {
|
|
262
256
|
property: 'authenticationType',
|
|
263
257
|
isEqualTo: 'none',
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"authenticationMethod": "route",
|
|
3
3
|
"routes": [
|
|
4
|
+
{{#cap.isMultitenant}}
|
|
5
|
+
{
|
|
6
|
+
"source": "^/-/cds/.*",
|
|
7
|
+
"destination": "mtx-api",
|
|
8
|
+
"authenticationType": "none"
|
|
9
|
+
},
|
|
10
|
+
{{/cap.isMultitenant}}
|
|
4
11
|
{
|
|
5
12
|
"source": "^/app/(.*)$",
|
|
6
13
|
"target": "$1",
|
|
@@ -14,13 +21,6 @@
|
|
|
14
21
|
"destination": "srv-api",
|
|
15
22
|
"authenticationType": "xsuaa",
|
|
16
23
|
"csrfProtection": true
|
|
17
|
-
}{{#cap.isMultitenant}},
|
|
18
|
-
{
|
|
19
|
-
"source": "^/extend/(.*)",
|
|
20
|
-
"destination": "mtx-api",
|
|
21
|
-
"target": "$1",
|
|
22
|
-
"authenticationType": "none"
|
|
23
24
|
}
|
|
24
|
-
{{/cap.isMultitenant}}
|
|
25
25
|
]
|
|
26
26
|
}
|
|
@@ -45,8 +45,8 @@ module.exports = class ApprouterTemplate extends TemplateBase {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
const appPath = join(this.projectPath, projectDescriptor.ui.appPath || 'app')
|
|
48
|
-
const additions = isExtensible && isJava ? [approuterExtensibilityJava] :
|
|
49
|
-
isExtensible && isNodejs ? [approuterExtensibility] : []
|
|
48
|
+
const additions = isExtensible && isJava ? [{ ...approuterExtensibilityJava, at: 0 }] :
|
|
49
|
+
isExtensible && isNodejs ? [{ ...approuterExtensibility, at: 0 }] : []
|
|
50
50
|
await this.templateUtil.mergeJSON(
|
|
51
51
|
`${appPath}/xs-app.json`,
|
|
52
52
|
`${__dirname}/files/xs-app.json.hbs`,
|
|
@@ -148,9 +148,8 @@ function getNamespace(csn, artifactName) {
|
|
|
148
148
|
|
|
149
149
|
// First step is not a namespace (we faked those in the CSN)
|
|
150
150
|
// No subsequent step can be a namespace then
|
|
151
|
-
if (art && art.kind !== 'namespace')
|
|
151
|
+
if (art && art.kind !== 'namespace' && art.kind !== 'context')
|
|
152
152
|
return null;
|
|
153
|
-
}
|
|
154
153
|
|
|
155
154
|
|
|
156
155
|
for (let i = 1; i < parts.length; i++) {
|
|
@@ -159,9 +158,8 @@ function getNamespace(csn, artifactName) {
|
|
|
159
158
|
seen = `${seen}.${parts[i]}`;
|
|
160
159
|
// This might not be - if it isn't, return the result.
|
|
161
160
|
const currentArtifact = csn.definitions[seen];
|
|
162
|
-
if (currentArtifact && currentArtifact.kind !== 'namespace')
|
|
161
|
+
if (currentArtifact && currentArtifact.kind !== 'namespace' && currentArtifact.kind !== 'context')
|
|
163
162
|
return previousArtifactName;
|
|
164
|
-
}
|
|
165
163
|
}
|
|
166
164
|
// We came till here - so the full artifactName is a namespace
|
|
167
165
|
return artifactName;
|
|
@@ -174,7 +174,7 @@ module.exports = class TemplateUtil {
|
|
|
174
174
|
} else if (YAML.isPair(node) && node.value?.items) {
|
|
175
175
|
collectionStack.unshift(node.value)
|
|
176
176
|
} else if (YAML.isScalar(node) && semantics.forceOverwrite && templateNode) {
|
|
177
|
-
node.value = templateNode.value
|
|
177
|
+
node.value = templateNode.value ?? templateNode.items?.[0]?.value?.value
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
if (node.items) {
|
|
@@ -293,13 +293,13 @@ module.exports = class TemplateUtil {
|
|
|
293
293
|
mergeCollection: (targetNode, templateNode) => {
|
|
294
294
|
if (YAML.isSeq(templateNode)) {
|
|
295
295
|
let [,parent] = collectionStack
|
|
296
|
-
additions?.filter(
|
|
297
|
-
if (typeof
|
|
298
|
-
const inExistence = Array.isArray(
|
|
296
|
+
additions?.filter(addition => {
|
|
297
|
+
if (typeof addition.in === 'string' || Array.isArray(addition.in) && typeof addition.in[0] === 'string') return true
|
|
298
|
+
const inExistence = Array.isArray(addition.in) ? existenceMap.get(addition.in[0].ref) : existenceMap.get(addition.in.ref)
|
|
299
299
|
return inExistence?.node === parent
|
|
300
300
|
})
|
|
301
|
-
.filter(
|
|
302
|
-
const keyPath = typeof
|
|
301
|
+
.filter(addition => {
|
|
302
|
+
const keyPath = typeof addition.in === 'string' ? addition.in : Array.isArray(addition.in) && typeof addition.in[0] === 'string' ? addition.in[0] : addition.in[1]
|
|
303
303
|
const keys = keyPath.split('.')
|
|
304
304
|
if (keys.length > collectionStack.length + 1) return
|
|
305
305
|
if (keys.length > 1) parent = collectionStack[keys.length]
|
|
@@ -308,9 +308,9 @@ module.exports = class TemplateUtil {
|
|
|
308
308
|
.filter(({ ref }) => {
|
|
309
309
|
return !existenceMap.get(ref)
|
|
310
310
|
})
|
|
311
|
-
.forEach(({ ref }) => {
|
|
311
|
+
.forEach(({ ref, at }) => {
|
|
312
312
|
const templateNode = templateExistenceMap.get(ref).node
|
|
313
|
-
targetNode.add(templateNode)
|
|
313
|
+
at !== undefined ? targetNode.items.splice(at, 0, templateNode) : targetNode.add(templateNode)
|
|
314
314
|
})
|
|
315
315
|
}
|
|
316
316
|
},
|
package/lib/k8s/ChartAdder.js
CHANGED
|
@@ -33,9 +33,11 @@ class ChartAdder {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
async copySchema() {
|
|
36
|
-
let
|
|
36
|
+
let valuesSchema = JSON.parse(await fs.readFile(path.join(this.resources, 'schemas', 'values.schema.json'), { encoding: 'utf8' }))
|
|
37
|
+
let valuesRootSchema = JSON.parse(await fs.readFile(path.join(this.resources, 'schemas', 'values.root.schema.json'), { encoding: 'utf8' }))
|
|
37
38
|
|
|
38
|
-
await this.builder.writeChartFile('values.schema.json', JSON.stringify(
|
|
39
|
+
await this.builder.writeChartFile('values.schema.json', JSON.stringify(valuesSchema, null, 4));
|
|
40
|
+
await this.builder.writeChartFile('values.root.schema.json', JSON.stringify(valuesRootSchema, null, 4));
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
async addChartValues() {
|
package/lib/k8s/ChartBuilder.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"allOf": [{ "$ref": "./values.schema.json" }],
|
|
4
|
+
"properties": {
|
|
5
|
+
"srv": {
|
|
6
|
+
"$id": "#/properties/srv",
|
|
7
|
+
"description": "Deployment",
|
|
8
|
+
"$ref": "./charts/web-application/values.schema.json"
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -124,6 +124,21 @@
|
|
|
124
124
|
"resources": {
|
|
125
125
|
"$id": "#/properties/hana_deployer/resources",
|
|
126
126
|
"$ref": "#/definitions/Resources"
|
|
127
|
+
},
|
|
128
|
+
"env": {
|
|
129
|
+
"$id": "#/properties/hana_deployer/env",
|
|
130
|
+
"description": "Key-value map of environment variables, which should be added to the Pod spec.",
|
|
131
|
+
"type": "object",
|
|
132
|
+
"patternProperties": {
|
|
133
|
+
"^[-._a-zA-Z][-._a-zA-Z0-9]*$": {
|
|
134
|
+
"$comment": "regex above copied from https://github.com/kubernetes/kubernetes/blob/ea0764452222146c47ec826977f49d7001b0ea8c/staging/src/k8s.io/apimachinery/pkg/util/validation/validation.go#L402",
|
|
135
|
+
"not": {
|
|
136
|
+
"type": ["null", "object", "array"]
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
"additionalProperties": false,
|
|
141
|
+
"default": {}
|
|
127
142
|
}
|
|
128
143
|
}
|
|
129
144
|
},
|
|
@@ -150,6 +165,21 @@
|
|
|
150
165
|
"$id": "#/properties/html5_apps_deployer/resources",
|
|
151
166
|
"$ref": "#/definitions/Resources"
|
|
152
167
|
},
|
|
168
|
+
"env": {
|
|
169
|
+
"$id": "#/properties/html5_apps_deployer/env",
|
|
170
|
+
"description": "Key-value map of environment variables, which should be added to the Pod spec.",
|
|
171
|
+
"type": "object",
|
|
172
|
+
"patternProperties": {
|
|
173
|
+
"^[-._a-zA-Z][-._a-zA-Z0-9]*$": {
|
|
174
|
+
"$comment": "regex above copied from https://github.com/kubernetes/kubernetes/blob/ea0764452222146c47ec826977f49d7001b0ea8c/staging/src/k8s.io/apimachinery/pkg/util/validation/validation.go#L402",
|
|
175
|
+
"not": {
|
|
176
|
+
"type": ["null", "object", "array"]
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
"additionalProperties": false,
|
|
181
|
+
"default": {}
|
|
182
|
+
},
|
|
153
183
|
"backendDestinations": {
|
|
154
184
|
"$id": "#/properties/html5_apps_deployer/backendDestinations",
|
|
155
185
|
"title": "Backend Destinations for HTML5 Application",
|
package/lib/lint/io.js
CHANGED