@sap/cds-dk 7.9.4 → 7.9.6
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/bin/watch.js +1 -1
- package/lib/build/provider/hana/template/.hdiconfig-all +3 -0
- package/lib/build/provider/hana/template/.hdiconfig-cloud +3 -0
- package/lib/init/index.js +2 -0
- package/lib/init/template/data/as-json.js +25 -11
- package/lib/init/template/hana/files/src/.hdiconfig +3 -0
- package/npm-shrinkwrap.json +19 -19
- package/package.json +1 -1
package/bin/watch.js
CHANGED
|
@@ -65,7 +65,7 @@ const t = module.exports.codes = {
|
|
|
65
65
|
}
|
|
66
66
|
const extDefaults = 'cds,csn,csv,ts,mjs,cjs,js,json,properties,edmx,xml,env'
|
|
67
67
|
const ignore = RegExp(
|
|
68
|
-
`(node_modules|_out|@types|@cds-models)\\${sep}` +
|
|
68
|
+
`(.git|node_modules|_out|@types|@cds-models)\\${sep}` +
|
|
69
69
|
`|app(\\${sep}.+)?\\${sep}(` +
|
|
70
70
|
`(webapp|dist|target)\\${sep}|` +
|
|
71
71
|
`tsconfig\\.json$|` +
|
package/lib/init/index.js
CHANGED
|
@@ -245,6 +245,8 @@ module.exports = class CDSGenerator {
|
|
|
245
245
|
templates.set(plugin, template)
|
|
246
246
|
const dependencies = await template.requires()
|
|
247
247
|
dependencies?.forEach(d => plugins.add(d))
|
|
248
|
+
} else {
|
|
249
|
+
throw 'cannot run plugin \'' + plugin + '\'' + (DEBUG ? 'Does not satisfy the canRun() function:\n ' + template.canRun : '')
|
|
248
250
|
}
|
|
249
251
|
}
|
|
250
252
|
}
|
|
@@ -3,7 +3,7 @@ const { dirname } = require('node:path')
|
|
|
3
3
|
const cds = require('../../../cds')
|
|
4
4
|
|
|
5
5
|
let counter = Math.round(Math.random() * 10000) // Default random seed // Non-deterministic behaviour
|
|
6
|
-
const MAX_ASSOC_DEPTH =
|
|
6
|
+
const MAX_ASSOC_DEPTH = 5
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Creates JSON test data for the given entities
|
|
@@ -40,25 +40,35 @@ const asJson = module.exports = async (data, csn, numRecords=1, options={}) => {
|
|
|
40
40
|
|
|
41
41
|
for (const name of entityNames) {
|
|
42
42
|
if (!data[name] // removed on purpose because records are created inline through compositions
|
|
43
|
-
|| data[name].length >= numRecords) { // already created by following associations
|
|
43
|
+
|| data[name].length >= numRecords) { // numRecords already created by following associations
|
|
44
44
|
continue
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
let numRecordsToGenerate // numRecords might be reduced if some records were created by following associations
|
|
48
|
+
let records = []
|
|
49
|
+
if (data[name].length > 0) {
|
|
50
|
+
numRecordsToGenerate = numRecords - data[name].length
|
|
51
|
+
records = Array(numRecordsToGenerate).fill({}).map(() => ({}))
|
|
52
|
+
} else {
|
|
53
|
+
numRecordsToGenerate = numRecords
|
|
54
|
+
records = data[name] = Array(numRecordsToGenerate).fill({}).map(() => ({}))
|
|
55
|
+
}
|
|
48
56
|
const entity = defs[name]
|
|
49
57
|
|
|
50
58
|
const idNum = randomNumber()
|
|
51
|
-
for (let i = 0; i <
|
|
59
|
+
for (let i = 0; i < numRecordsToGenerate; i++) {
|
|
52
60
|
fillRecord(records[i], idNum+i, entity, csn, data, null, 0, referenceData)
|
|
53
61
|
}
|
|
54
|
-
|
|
55
|
-
|
|
62
|
+
data[name] = data[name].concat(records) // append the new records to the possibly existingand referenced records
|
|
63
|
+
// remove records w/ duplicate keys. This can happen if the key is an enum (and we have less enum values than requested records).
|
|
64
|
+
data[name] = uniqRecords(data[name], entity)
|
|
56
65
|
}
|
|
57
66
|
return data
|
|
58
67
|
}
|
|
59
68
|
|
|
60
69
|
function fillRecord(record, recordID, entity, csn, data, parentEntity, depth, referenceData) {
|
|
61
70
|
Object.defineProperty(record, '$id', {value: recordID, enumerable: false})
|
|
71
|
+
if (data[entity.name]) data[entity.name].push(record) // add id to data, to be referenced by associations to prevent circular dependencies
|
|
62
72
|
|
|
63
73
|
const { elements } = entity
|
|
64
74
|
Object.values(elements).sort(asJson.elementsSorter(csn)).forEach(el => {
|
|
@@ -242,7 +252,7 @@ function dataForField(element, entity, csn, record, data, parentEntity, depth, r
|
|
|
242
252
|
if (element.is2many)
|
|
243
253
|
return
|
|
244
254
|
const target = csn.definitions[element.target]
|
|
245
|
-
if (!target ||
|
|
255
|
+
if (!target || depth > MAX_ASSOC_DEPTH)
|
|
246
256
|
return
|
|
247
257
|
|
|
248
258
|
let targetRecord = randomFromReferenceData(target, csn, referenceData)
|
|
@@ -256,10 +266,14 @@ function dataForField(element, entity, csn, record, data, parentEntity, depth, r
|
|
|
256
266
|
targetRecords = data[target.name] = []
|
|
257
267
|
else if (!targetRecords) // target entity is not in the list of entities to be created
|
|
258
268
|
return
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
269
|
+
|
|
270
|
+
if (targetRecords.length > 0) { // use record generated by following asociation
|
|
271
|
+
targetRecord = targetRecords[0]
|
|
272
|
+
} else {
|
|
273
|
+
targetRecord = fillRecord({}, randomNumber(), target, csn, data, entity, depth+1, referenceData)
|
|
274
|
+
targetRecords.push(targetRecord)
|
|
275
|
+
uniqRecords(targetRecords, target)
|
|
276
|
+
}
|
|
263
277
|
}
|
|
264
278
|
|
|
265
279
|
// TODO: handle foreign keys correctly
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap/cds-dk",
|
|
3
|
-
"version": "7.9.
|
|
3
|
+
"version": "7.9.6",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@sap/cds-dk",
|
|
9
|
-
"version": "7.9.
|
|
9
|
+
"version": "7.9.6",
|
|
10
10
|
"license": "SEE LICENSE IN LICENSE",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@sap/cds": "^7",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
"node_modules/@eslint-community/regexpp": {
|
|
56
|
-
"version": "4.
|
|
56
|
+
"version": "4.11.0",
|
|
57
57
|
"license": "MIT",
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": "^12.0.0 || ^14.0.0 || >=16.0.0"
|
|
@@ -208,10 +208,10 @@
|
|
|
208
208
|
}
|
|
209
209
|
},
|
|
210
210
|
"node_modules/@sap/cds": {
|
|
211
|
-
"version": "7.9.
|
|
211
|
+
"version": "7.9.4",
|
|
212
212
|
"license": "SEE LICENSE IN LICENSE",
|
|
213
213
|
"dependencies": {
|
|
214
|
-
"@cap-js/cds-types": "
|
|
214
|
+
"@cap-js/cds-types": "<=0.2.0",
|
|
215
215
|
"@sap/cds-compiler": "^4",
|
|
216
216
|
"@sap/cds-fiori": "^1",
|
|
217
217
|
"@sap/cds-foss": "^5.0.0"
|
|
@@ -225,7 +225,7 @@
|
|
|
225
225
|
}
|
|
226
226
|
},
|
|
227
227
|
"node_modules/@sap/cds-compiler": {
|
|
228
|
-
"version": "4.9.
|
|
228
|
+
"version": "4.9.6",
|
|
229
229
|
"license": "SEE LICENSE IN LICENSE",
|
|
230
230
|
"dependencies": {
|
|
231
231
|
"antlr4": "4.9.3"
|
|
@@ -240,7 +240,7 @@
|
|
|
240
240
|
}
|
|
241
241
|
},
|
|
242
242
|
"node_modules/@sap/cds-fiori": {
|
|
243
|
-
"version": "1.2.
|
|
243
|
+
"version": "1.2.7",
|
|
244
244
|
"license": "SEE LICENSE IN LICENSE",
|
|
245
245
|
"peerDependencies": {
|
|
246
246
|
"@sap/cds": ">=7.6",
|
|
@@ -261,7 +261,7 @@
|
|
|
261
261
|
}
|
|
262
262
|
},
|
|
263
263
|
"node_modules/@sap/cds-mtxs": {
|
|
264
|
-
"version": "1.18.
|
|
264
|
+
"version": "1.18.2",
|
|
265
265
|
"license": "SEE LICENSE IN LICENSE",
|
|
266
266
|
"dependencies": {
|
|
267
267
|
"@sap/hdi-deploy": "^4",
|
|
@@ -396,7 +396,7 @@
|
|
|
396
396
|
}
|
|
397
397
|
},
|
|
398
398
|
"node_modules/acorn": {
|
|
399
|
-
"version": "8.12.
|
|
399
|
+
"version": "8.12.1",
|
|
400
400
|
"license": "MIT",
|
|
401
401
|
"bin": {
|
|
402
402
|
"acorn": "bin/acorn"
|
|
@@ -1175,7 +1175,7 @@
|
|
|
1175
1175
|
}
|
|
1176
1176
|
},
|
|
1177
1177
|
"node_modules/esquery": {
|
|
1178
|
-
"version": "1.
|
|
1178
|
+
"version": "1.6.0",
|
|
1179
1179
|
"license": "BSD-3-Clause",
|
|
1180
1180
|
"dependencies": {
|
|
1181
1181
|
"estraverse": "^5.1.0"
|
|
@@ -2225,12 +2225,9 @@
|
|
|
2225
2225
|
}
|
|
2226
2226
|
},
|
|
2227
2227
|
"node_modules/node-addon-api": {
|
|
2228
|
-
"version": "7.1.
|
|
2228
|
+
"version": "7.1.1",
|
|
2229
2229
|
"license": "MIT",
|
|
2230
|
-
"optional": true
|
|
2231
|
-
"engines": {
|
|
2232
|
-
"node": "^16 || ^18 || >= 20"
|
|
2233
|
-
}
|
|
2230
|
+
"optional": true
|
|
2234
2231
|
},
|
|
2235
2232
|
"node_modules/node-cache": {
|
|
2236
2233
|
"version": "5.1.2",
|
|
@@ -2301,8 +2298,11 @@
|
|
|
2301
2298
|
}
|
|
2302
2299
|
},
|
|
2303
2300
|
"node_modules/object-inspect": {
|
|
2304
|
-
"version": "1.13.
|
|
2301
|
+
"version": "1.13.2",
|
|
2305
2302
|
"license": "MIT",
|
|
2303
|
+
"engines": {
|
|
2304
|
+
"node": ">= 0.4"
|
|
2305
|
+
},
|
|
2306
2306
|
"funding": {
|
|
2307
2307
|
"url": "https://github.com/sponsors/ljharb"
|
|
2308
2308
|
}
|
|
@@ -2688,7 +2688,7 @@
|
|
|
2688
2688
|
"license": "ISC"
|
|
2689
2689
|
},
|
|
2690
2690
|
"node_modules/semver": {
|
|
2691
|
-
"version": "7.6.
|
|
2691
|
+
"version": "7.6.3",
|
|
2692
2692
|
"license": "ISC",
|
|
2693
2693
|
"bin": {
|
|
2694
2694
|
"semver": "bin/semver.js"
|
|
@@ -3136,7 +3136,7 @@
|
|
|
3136
3136
|
}
|
|
3137
3137
|
},
|
|
3138
3138
|
"node_modules/uglify-js": {
|
|
3139
|
-
"version": "3.
|
|
3139
|
+
"version": "3.19.0",
|
|
3140
3140
|
"license": "BSD-2-Clause",
|
|
3141
3141
|
"optional": true,
|
|
3142
3142
|
"bin": {
|
|
@@ -3244,7 +3244,7 @@
|
|
|
3244
3244
|
"license": "ISC"
|
|
3245
3245
|
},
|
|
3246
3246
|
"node_modules/ws": {
|
|
3247
|
-
"version": "8.
|
|
3247
|
+
"version": "8.18.0",
|
|
3248
3248
|
"license": "MIT",
|
|
3249
3249
|
"engines": {
|
|
3250
3250
|
"node": ">=10.0.0"
|