@sap/cds-dk 7.9.1 → 7.9.2

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.
@@ -26,7 +26,10 @@ class BindingResolver {
26
26
 
27
27
  const resolvedBindings = {}
28
28
 
29
- await Promise.all(Object.keys(bindings).map(async name => {
29
+ // Serialized because of parallelization issues in the cf CLI,
30
+ // see https://github.com/cloudfoundry/cli/issues/2232
31
+ // await Promise.all(Object.keys(bindings).map(async name => {
32
+ for (const name of Object.keys(bindings)) {
30
33
  const binding = bindings[name]
31
34
  const cacheKey = JSON.stringify(binding)
32
35
  let resolvedBinding
@@ -37,7 +40,7 @@ class BindingResolver {
37
40
  resolvedBinding = cache[cacheKey]
38
41
  }
39
42
  resolvedBindings[name] = resolvedBinding
40
- }))
43
+ }
41
44
  return Object.keys(resolvedBindings).length > 0 ? resolvedBindings : undefined
42
45
  }
43
46
 
package/lib/bind/index.js CHANGED
@@ -31,10 +31,13 @@ async function bind(options) {
31
31
 
32
32
  const onText = { 'cf': 'Cloud Foundry', 'k8s': 'Kubernetes' }[on];
33
33
  if (!options['to-app-services']) logger.log(`Retrieving data from ${bold(onText)}...`);
34
- let resolvedServices
35
34
 
36
35
  const targets = options.to.split(/,/g);
37
- resolvedServices = await Promise.all(targets.map(async target => {
36
+ // Serialized because of parallelization issues in the cf CLI,
37
+ // see https://github.com/cloudfoundry/cli/issues/2232
38
+ // resolvedServices = await Promise.all(targets.map(async target => {
39
+ const resolvedServices = [];
40
+ for (const target of targets) {
38
41
  let binding;
39
42
  if (on === 'k8s') {
40
43
  binding = { type: on, name: target };
@@ -48,8 +51,8 @@ async function bind(options) {
48
51
  resolvedService._target = target;
49
52
  delete resolvedService.credentials;
50
53
  resolvedService.binding.resolved = false;
51
- return resolvedService;
52
- }));
54
+ resolvedServices.push(resolvedService);
55
+ }
53
56
 
54
57
  if (options.kind) {
55
58
  resolvedServices.forEach(service => service.kind = options.kind);
@@ -289,32 +289,44 @@ function randomFromReferenceData (entity, csn, referenceData) {
289
289
  .map(([file]) => file)
290
290
  if (files.length === 0) return
291
291
 
292
- if (files[0].endsWith('.csv')) {
293
- const content = cds.utils.fs.readFileSync(files[0]).toString()
292
+ const toCSV = (content) => {
294
293
  const records = cds.parse.csv(content)
295
294
  if (records?.length > 1) {
296
295
  const header = records[0] // 0 is header line
297
296
  const randomRecord = records.length === 2 ? records[1] : records[randomIntInRange({from: 1, to: records.length-1} )]
298
297
  let result = {}
299
298
  for (let i = 0; i < records[0].length; i++) {
300
- result[header[i]] = randomRecord[i]
299
+ // For csv, which is all strings, convert to correct JSON type.
300
+ // For simplicity, try to convert the value instead of dispatching on the type.
301
+ const val = toNum(randomRecord[i]) ?? randomRecord[i] // boolean is already covered by CSV parser
302
+ result[header[i]] = val
301
303
  }
302
304
  return result
303
305
  }
304
306
  }
307
+ const toJSON = (records) => {
308
+ if (records.length === 1)
309
+ return records[0]
310
+ else if (records.length > 1)
311
+ return records[randomIntInRange({from: 0, to: records.length-1} )]
312
+ }
313
+
314
+ if (files[0].endsWith('.csv')) {
315
+ const content = cds.utils.fs.readFileSync(files[0]).toString()
316
+ return toCSV(content)
317
+ }
318
+ else if (files[0].endsWith('.json')) {
319
+ const content = cds.utils.fs.readFileSync(files[0]).toString()
320
+ const records = JSON.parse(content)
321
+ return toJSON(records)
322
+ }
305
323
  else {
306
- let content
307
- if (files[0].endsWith('.json')) {
308
- content = cds.utils.fs.readFileSync(files[0]).toString()
309
- } else {
310
- content = files[0] // for tests, assuming the content is given inline
311
- }
312
- if (content) {
324
+ const content = files[0] // for tests, assuming the content is given inline
325
+ try {
313
326
  const records = JSON.parse(content)
314
- if (records.length === 1)
315
- return records[0]
316
- else if (records.length > 1)
317
- return records[randomIntInRange({from: 0, to: records.length-1} )]
327
+ return toJSON(records)
328
+ } catch {
329
+ return toCSV(content)
318
330
  }
319
331
  }
320
332
  }
@@ -524,3 +536,10 @@ function randomNumber() {
524
536
  counter = (counter * counter) % M
525
537
  return counter;
526
538
  }
539
+
540
+ function toNum(str){
541
+ if (typeof(str) === 'number')
542
+ return str
543
+ if (typeof(str) === 'string')
544
+ return +str
545
+ }
@@ -27,13 +27,13 @@ modules:
27
27
  {{/isNodejs}}
28
28
  {{#isJava}}
29
29
  parameters:
30
- buildpack: sap_java_buildpack
30
+ buildpack: sap_java_buildpack_jakarta
31
31
  readiness-health-check-type: http
32
32
  readiness-health-check-http-endpoint: /
33
33
  properties:
34
34
  SPRING_PROFILES_ACTIVE: cloud,sandbox
35
35
  JBP_CONFIG_COMPONENTS: "jres: ['com.sap.xs.java.buildpack.jre.SAPMachineJRE']"
36
- JBP_CONFIG_SAP_MACHINE_JRE: '{ use_offline_repository: false, version: {{jdkVersion}}.+ }'
36
+ JBP_CONFIG_SAP_MACHINE_JRE: '{ version: {{jdkVersion}}.+ }'
37
37
  build-parameters:
38
38
  builder: custom
39
39
  commands:
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@sap/cds-dk",
3
- "version": "7.9.1",
3
+ "version": "7.9.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@sap/cds-dk",
9
- "version": "7.9.1",
9
+ "version": "7.9.2",
10
10
  "license": "SEE LICENSE IN LICENSE",
11
11
  "dependencies": {
12
12
  "@sap/cds": "^7",
@@ -208,7 +208,7 @@
208
208
  }
209
209
  },
210
210
  "node_modules/@sap/cds": {
211
- "version": "7.9.0",
211
+ "version": "7.9.1",
212
212
  "license": "SEE LICENSE IN LICENSE",
213
213
  "dependencies": {
214
214
  "@cap-js/cds-types": "<1",
@@ -225,7 +225,7 @@
225
225
  }
226
226
  },
227
227
  "node_modules/@sap/cds-compiler": {
228
- "version": "4.9.0",
228
+ "version": "4.9.2",
229
229
  "license": "SEE LICENSE IN LICENSE",
230
230
  "dependencies": {
231
231
  "antlr4": "4.9.3"
@@ -273,7 +273,7 @@
273
273
  }
274
274
  },
275
275
  "node_modules/@sap/eslint-plugin-cds": {
276
- "version": "3.0.2",
276
+ "version": "3.0.3",
277
277
  "license": "See LICENSE file",
278
278
  "dependencies": {
279
279
  "@sap/cds": ">=5.6.0",
@@ -2688,11 +2688,8 @@
2688
2688
  "license": "ISC"
2689
2689
  },
2690
2690
  "node_modules/semver": {
2691
- "version": "7.6.0",
2691
+ "version": "7.6.2",
2692
2692
  "license": "ISC",
2693
- "dependencies": {
2694
- "lru-cache": "^6.0.0"
2695
- },
2696
2693
  "bin": {
2697
2694
  "semver": "bin/semver.js"
2698
2695
  },
@@ -2700,20 +2697,6 @@
2700
2697
  "node": ">=10"
2701
2698
  }
2702
2699
  },
2703
- "node_modules/semver/node_modules/lru-cache": {
2704
- "version": "6.0.0",
2705
- "license": "ISC",
2706
- "dependencies": {
2707
- "yallist": "^4.0.0"
2708
- },
2709
- "engines": {
2710
- "node": ">=10"
2711
- }
2712
- },
2713
- "node_modules/semver/node_modules/yallist": {
2714
- "version": "4.0.0",
2715
- "license": "ISC"
2716
- },
2717
2700
  "node_modules/send": {
2718
2701
  "version": "0.18.0",
2719
2702
  "license": "MIT",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/cds-dk",
3
- "version": "7.9.1",
3
+ "version": "7.9.2",
4
4
  "description": "Command line client and development toolkit for the SAP Cloud Application Programming Model",
5
5
  "homepage": "https://cap.cloud.sap/",
6
6
  "keywords": [