@cap-js/cds-typer 0.21.2 → 0.22.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 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.22.0 - TBD
7
+ ## Version 0.23.0 - TBD
8
+
9
+ ## Version 0.22.0 - 2024-06-20
10
+ ### Fixed
11
+ - Fixed a bug where keys would sometimes inconsistently become nullable
8
12
 
9
13
  ## Version 0.21.2 - 2024-06-06
10
14
  ### Fixed
package/lib/visitor.js CHANGED
@@ -157,13 +157,15 @@ class Visitor {
157
157
  // lookup in cds.definitions can fail for inline structs.
158
158
  // We don't really have to care for this case, as keys from such structs are _not_ propagated to
159
159
  // the containing entity.
160
- for (const [kname, kelement] of this.#keys(element.target)) {
161
- if (this.resolver.getMaxCardinality(element) === 1) { // FIXME: kelement?
160
+ for (const [kname, originalKeyElement] of this.#keys(element.target)) {
161
+ if (this.resolver.getMaxCardinality(element) === 1 && typeof element.on !== 'object') { // FIXME: kelement?
162
162
  const foreignKey = `${ename}_${kname}`
163
163
  if (Object.hasOwn(entity.elements, foreignKey)) {
164
164
  this.logger.error(`Attempting to generate a foreign key reference called '${foreignKey}' in type definition for entity ${name}. But a property of that name is already defined explicitly. Consider renaming that property.`)
165
165
  } else {
166
- kelement.isRefNotNull = !!element.notNull || !!element.key
166
+ const kelement = Object.assign(Object.create(originalKeyElement), {
167
+ isRefNotNull: !!element.notNull || !!element.key
168
+ })
167
169
  this.visitElement(foreignKey, kelement, file, buffer)
168
170
  }
169
171
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cap-js/cds-typer",
3
- "version": "0.21.2",
3
+ "version": "0.22.0",
4
4
  "description": "Generates .ts files for a CDS model to receive code completion in VS Code",
5
5
  "main": "index.js",
6
6
  "repository": "github:cap-js/cds-typer",