@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.
@@ -448,38 +448,63 @@ function _getServiceEntityProperty(
448
448
  propertyJson = propertyJson + '"key": true,\n';
449
449
  }
450
450
  if (isCollection === 1) {
451
- propertyJson = propertyJson + '"items": { \n'
452
- }
453
- propertyJson = propertyJson + '"type":"' + cdsDataType + '"';
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
- //if annotations to be added
456
- if (edmxncdsdatatype[dataType + "_a"] && cdsDataType != "cds.Date") {
457
- if (dataType === 'Edm.Stream')
458
- propertyJson = propertyJson + ',\n"@Core.MediaType": "application/octet-stream"';
459
- else
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
- if (length && length > 0) {
464
- propertyJson = propertyJson + ',\n"length":' + length;
465
- } else if (precision && precision > 0 && hasInvalidPrecision === false) {
466
- propertyJson = propertyJson + ',\n"precision":' + precision;
467
- if (scale && scale > 0) {
468
- propertyJson = propertyJson + ',\n"scale":' + scale;
469
- } else {
470
- propertyJson = propertyJson + ',\n"scale":' + 0;
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
- //adding precision in case of DateTime datatypes
475
- if ((dataType === "Edm.DateTimeOffset" || dataType === "Edm.DateTime") && cdsDataType != "cds.Date") {
476
- if (!precision || precision === -1) precision = 0;
477
- propertyJson = propertyJson + ',\n"@odata.Precision": ' + precision;
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
- if (isCollection === 1) {
481
- propertyJson = propertyJson + '\n}'
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);
@@ -1,6 +1,6 @@
1
1
  const os = require('os');
2
2
 
3
- const MAVEN_ARCHETYPE_VERSION = '1.27.0';
3
+ const MAVEN_ARCHETYPE_VERSION = '1.27.1';
4
4
 
5
5
  const constants = {
6
6
  IS_WIN: (os.platform() === 'win32'),
@@ -233,13 +233,10 @@ const approuterExtensibility = {
233
233
  in: 'routes',
234
234
  where: [{
235
235
  property: 'source',
236
- isEqualTo: '^/extend/(.*)'
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: '^/extend/(.*)'
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;
@@ -6,7 +6,7 @@
6
6
  "license": "UNLICENSED",
7
7
  "private": true,
8
8
  "dependencies": {
9
- "@sap/cds": ">=5",
9
+ "@sap/cds": "^6",
10
10
  "express": "^4"
11
11
  },
12
12
  "devDependencies": {
@@ -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(existence => {
297
- if (typeof existence.in === 'string' || Array.isArray(existence.in) && typeof existence.in[0] === 'string') return true
298
- const inExistence = Array.isArray(existence.in) ? existenceMap.get(existence.in[0].ref) : existenceMap.get(existence.in.ref)
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(existence => {
302
- const keyPath = typeof existence.in === 'string' ? existence.in : Array.isArray(existence.in) && typeof existence.in[0] === 'string' ? existence.in[0] : existence.in[1]
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
  },
@@ -33,9 +33,11 @@ class ChartAdder {
33
33
  }
34
34
 
35
35
  async copySchema() {
36
- let schema = JSON.parse(await fs.readFile(path.join(this.resources, 'values.schema.json'), { encoding: 'utf8' }))
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(schema, null, 4));
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() {
@@ -53,7 +53,7 @@ class ChartBuilder {
53
53
  } else {
54
54
 
55
55
  const header = `
56
- # yaml-language-server: $schema=./values.schema.json
56
+ # yaml-language-server: $schema=./values.root.schema.json
57
57
 
58
58
  `
59
59
  data = header + data;
@@ -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
@@ -63,7 +63,6 @@ module.exports = {
63
63
  const isFilePath = typeof configIn === "string";
64
64
  if (isFilePath) {
65
65
  if (await fsUtil.pathExists(configIn)) {
66
- console.log('+++', configIn)
67
66
  configContents = (await this.readEslintConfig(configIn)) || {};
68
67
  }
69
68
  } else {