@cap-js/cds-typer 0.13.0 → 0.14.0
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 +5 -1
- package/lib/csn.js +15 -1
- package/lib/visitor.js +6 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,7 +4,11 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/).
|
|
6
6
|
|
|
7
|
-
## Version 0.
|
|
7
|
+
## Version 0.15.0 - TBD
|
|
8
|
+
|
|
9
|
+
## Version 0.14.0 - 2023-12-13
|
|
10
|
+
### Added
|
|
11
|
+
- Entities that are database views now also receive typings
|
|
8
12
|
|
|
9
13
|
## Version 0.13.0 - 2023-12-06
|
|
10
14
|
### Changes
|
package/lib/csn.js
CHANGED
|
@@ -226,4 +226,18 @@ function amendCSN(csn) {
|
|
|
226
226
|
propagateForeignKeys(csn)
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
|
|
229
|
+
/**
|
|
230
|
+
* FIXME: this is pretty handwavey: we are looking for view-entities,
|
|
231
|
+
* i.e. ones that have a query, but are not a cds level projection.
|
|
232
|
+
* Those are still not expanded and we have to retrieve their definition
|
|
233
|
+
* with all properties from the inferred model.
|
|
234
|
+
*/
|
|
235
|
+
const isView = entity => entity.query && !entity.projection
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* @see isView
|
|
239
|
+
* Unresolved entities have to be looked up from inferred csn.
|
|
240
|
+
*/
|
|
241
|
+
const isUnresolved = entity => entity._unresolved === true
|
|
242
|
+
|
|
243
|
+
module.exports = { amendCSN, isView, isUnresolved }
|
package/lib/visitor.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const util = require('./util')
|
|
4
4
|
|
|
5
|
-
const { amendCSN } = require('./csn')
|
|
5
|
+
const { amendCSN, isView, isUnresolved } = require('./csn')
|
|
6
6
|
// eslint-disable-next-line no-unused-vars
|
|
7
7
|
const { SourceFile, baseDefinitions, Buffer } = require('./file')
|
|
8
8
|
const { FlatInlineDeclarationResolver, StructuredInlineDeclarationResolver } = require('./components/inline')
|
|
@@ -99,10 +99,12 @@ class Visitor {
|
|
|
99
99
|
*/
|
|
100
100
|
visitDefinitions() {
|
|
101
101
|
for (const [name, entity] of Object.entries(this.csn.xtended.definitions)) {
|
|
102
|
-
if (entity
|
|
103
|
-
this.
|
|
104
|
-
} else {
|
|
102
|
+
if (isView(entity)) {
|
|
103
|
+
this.visitEntity(name, this.csn.inferred.definitions[name])
|
|
104
|
+
} else if (!isUnresolved(entity)) {
|
|
105
105
|
this.visitEntity(name, entity)
|
|
106
|
+
} else {
|
|
107
|
+
this.logger.warning(`Skipping unresolved entity: ${name}`)
|
|
106
108
|
}
|
|
107
109
|
}
|
|
108
110
|
// FIXME: optimise
|