@cap-js/cds-typer 0.11.0 → 0.11.1
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 +8 -0
- package/lib/file.js +6 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
|
|
|
11
11
|
### Added
|
|
12
12
|
### Fixed
|
|
13
13
|
|
|
14
|
+
## Version 0.11.1 - 2023-10-12
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
### Fixed
|
|
20
|
+
Fixed how service names are exported as default export
|
|
21
|
+
|
|
14
22
|
## Version 0.11.0 - 2023-10-10
|
|
15
23
|
|
|
16
24
|
### Changed
|
package/lib/file.js
CHANGED
|
@@ -335,6 +335,7 @@ class SourceFile extends File {
|
|
|
335
335
|
* @param {string} fq the fully qualified name of the service
|
|
336
336
|
*/
|
|
337
337
|
addService(fq) {
|
|
338
|
+
// FIXME: warn the user when they're trying to add an entity/ type/ enum called "name", which will override our name export
|
|
338
339
|
if (this.services.names.length) {
|
|
339
340
|
throw new Error(`trying to add more than one service to file ${this.path.asDirectory()}. Existing service is ${this.services.names[0]}, trying to add ${fq}`)
|
|
340
341
|
}
|
|
@@ -369,6 +370,7 @@ class SourceFile extends File {
|
|
|
369
370
|
AUTO_GEN_NOTE,
|
|
370
371
|
this.getImports().join(),
|
|
371
372
|
this.preamble.join(),
|
|
373
|
+
this.services.buffer.join(), // must be the very first
|
|
372
374
|
this.types.join(),
|
|
373
375
|
this.enums.buffer.join(),
|
|
374
376
|
this.inlineEnums.buffer.join(), // needs to be before classes
|
|
@@ -376,15 +378,16 @@ class SourceFile extends File {
|
|
|
376
378
|
this.aspects.join(), // needs to be before classes
|
|
377
379
|
this.classes.join(),
|
|
378
380
|
this.events.buffer.join(),
|
|
379
|
-
this.actions.buffer.join()
|
|
380
|
-
this.services.buffer.join() // should be at the end
|
|
381
|
+
this.actions.buffer.join()
|
|
381
382
|
].filter(Boolean).join('\n')
|
|
382
383
|
}
|
|
383
384
|
|
|
384
385
|
toJSExports() {
|
|
385
386
|
return [AUTO_GEN_NOTE, "const cds = require('@sap/cds')", `const csn = cds.entities('${this.path.asNamespace()}')`] // boilerplate
|
|
386
387
|
.concat(
|
|
387
|
-
|
|
388
|
+
// FIXME: move stringification of service into own module
|
|
389
|
+
this.services.names.map(name => `module.exports = { name: '${name}' }`)) // there should be only one
|
|
390
|
+
.concat(this.inflections
|
|
388
391
|
// sorting the entries based on the number of dots in their singular.
|
|
389
392
|
// that makes sure we have defined all parent namespaces before adding subclasses to them e.g.:
|
|
390
393
|
// "module.exports.Books" is defined before "module.exports.Books.text"
|
|
@@ -410,8 +413,6 @@ class SourceFile extends File {
|
|
|
410
413
|
.concat(this.enums.fqs.map(({name, fq, property}) => property
|
|
411
414
|
? stringifyAnonymousEnum(name, fq, property)
|
|
412
415
|
: stringifyNamedEnum(name, fq)))
|
|
413
|
-
// FIXME: move stringification of service into own module
|
|
414
|
-
.concat(this.services.names.map(name => `module.exports.default = { name: '${name}' }`)) // there should be only one
|
|
415
416
|
.join('\n') + '\n'
|
|
416
417
|
}
|
|
417
418
|
}
|