New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@cap-js/cds-typer

Package Overview
Dependencies
Maintainers
0
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cap-js/cds-typer - npm Package Compare versions

Comparing version

to
0.24.0

11

cds-plugin.js

@@ -13,5 +13,10 @@ const { readdir, stat } = require('node:fs/promises')

/**
* Check if a tsconfig file exists.
* Check if the project is a TypeScript project by looking for a dependency on TypeScript.
* @returns {boolean}
*/
const tsConfigExists = () => fs.existsSync('tsconfig.json')
const isTypeScriptProject = () => {
if (!fs.existsSync('package.json')) return false
const pkg = require(path.resolve('package.json'))
return Boolean(pkg.devDependencies?.typescript || pkg.dependencies?.typescript)
}

@@ -60,3 +65,3 @@ /**

static taskDefaults = { src: '.' }
static hasTask() { return tsConfigExists() }
static hasTask() { return isTypeScriptProject() }

@@ -63,0 +68,0 @@ // lower priority than the nodejs task

@@ -7,4 +7,13 @@ # Change Log

## Version 0.24.0 - TBD
## Version 0.25.0 - TBD
## Version 0.24.0 - 2024-07-18
### Fixed
- Suppressed an error that would incorrectly point out naming clashes when an entity was named in singular inflection in the model
- CDS aspects now also generate a aspect-function in singular inflection, similar to how entities do
### Changed
- Aspects generate named classes again so that tooltips will show more meaningful provenance for properties
- The TypeScript task for `cds build` no longer looks for tsconfig.json to determine if the project has TS nature and instead checks the dependencies in the project's package.json for an occurrence of `typescript`
## Version 0.23.0 - 2024-07-04

@@ -11,0 +20,0 @@ ### Fixed

@@ -169,3 +169,3 @@ 'use strict'

buffer.addIndentedBlock(`export function ${identAspect(clean)}<TBase extends new (...args: any[]) => object>(Base: TBase) {`, () => {
buffer.addIndentedBlock(`return class extends ${ancestors} {`, () => {
buffer.addIndentedBlock(`return class ${clean} extends ${ancestors} {`, () => {
const enums = []

@@ -254,3 +254,5 @@ for (let [ename, element] of Object.entries(entity.elements ?? {})) {

// as types are not inflected, their singular will always clash and there is also no plural for them anyway -> skip
if (!isType(entity) && `${ns.asNamespace()}.${singular}` in this.csn.xtended.definitions) {
// if the user defined their entities in singular form we would also have a false positive here -> skip
const namespacedSingular = `${ns.asNamespace()}.${singular}`
if (!isType(entity) && namespacedSingular !== fq && namespacedSingular in this.csn.xtended.definitions) {
LOG.error(

@@ -377,3 +379,3 @@ `Derived singular '${singular}' for your entity '${fq}', already exists. The resulting types will be erronous. Consider using '@singular:'/ '@plural:' annotations in your model or move the offending declarations into different namespaces to resolve this collision.`

LOG.debug(`Printing aspect ${fq}`)
const { namespace, entityName } = this.entityRepository.getByFq(fq)
const { namespace, entityName, inflection } = this.entityRepository.getByFq(fq)
const file = this.fileRepository.getNamespaceFile(namespace)

@@ -385,3 +387,3 @@ // aspects are technically classes and can therefore be added to the list of defined classes.

file.aspects.add(`// the following represents the CDS aspect '${entityName}'`)
this.#aspectify(fq, aspect, file.aspects, { cleanName: entityName })
this.#aspectify(fq, aspect, file.aspects, { cleanName: inflection.singular })
}

@@ -388,0 +390,0 @@

{
"name": "@cap-js/cds-typer",
"version": "0.23.0",
"version": "0.24.0",
"description": "Generates .ts files for a CDS model to receive code completion in VS Code",

@@ -5,0 +5,0 @@ "main": "index.js",