---
title: September 2024
versions:
  cdsjs: 8.3.1
  cdsdk: 8.3.0
  cdsc: 5.3.2
  cdsmtxs: 2.2.0
  java: 3.3.1
typedModels:
  bookshop: '../../@external/tools/assets/bookshop'

---

# September 2024

<ReleaseBadges />

[[toc]]

## Analytics for cap≽ire

With this release, we start using [Matomo](https://matomo.org/) to collect anonymized usage data for cap≽ire. This helps us understand, for example, key topics and prioritize areas for improvement. If you want to change your decision, visit our [Cookie Statement](/resources/cookies) page.

![This screenshot shows the box and it's radio buttons that you find following the previous link to the cookie statement.](assets/sep24/cookie-statement.png){style="width:450px; box-shadow: 1px 1px 5px #888888"}

## Node.js {#cds-js}

### Top Level Imports of Typed Models <Beta />

You can now import type definitions generated by [cds-typer](/@external/tools/cds-typer) on top-level, even in test code:

```ts
import { Books } from '#cds-models/sap/capire/bookshop' // static import // [!code ++]

describe("My Tests", () => {
  cds.test(...)

  test ("first test", () => {
    const { Books } = await import('#cds-models/sap/capire/bookshop') // [!code --]
    await SELECT.from(Books)
  })
})
```

Use option <Config>cds.typer.use_entities_proxy:true</Config> in `package.json` to opt-in to this behavior. Version 0.26.0 of `cds-typer` is required at the minimum.

We would like to thank user [stockbal](https://github.com/stockbal) for this contribution to `cds-typer`.

### Richer JS/TS Snippets

In cap≽ire, JavaScript and Typescript documentation snippets can now carry type information, allowing you to get better insights in the APIs used there.

The example from [cds-typer](/@external/tools/cds-typer) highlights the generated model-specific types in a popover and a code completion box:

```ts{2,4} twoslash
// @noErrors
// @paths: {"#cds-models/*": ["%typedModels:bookshop:resolved%"], "@sap/cds": ["%sap_cds:resolved%"]}
const service = new cds.ApplicationService
import cds from '@sap/cds'
// ---cut---
import { Books } from '#cds-models/sap/capire/bookshop'
service.before('CREATE', Books, ({ data }) => {
//                                 ^?
  /* data is of type Books */
  data.t
//      ^|
})
```

In this example from [cds-server](/@external/node.js/cds-server), hover over `express` or `app` objects to explore `express` APIs:

```js twoslash
const cds = require('@sap/cds')
const express = require('express')
cds.on('bootstrap', app => {
  // serve static resources incl. index.html
  app.use(express.static(__dirname+'/srv/public'))
})
```

[Let us know](https://github.com/capire/docs/issues) which snippets you think would benefit from type information.

### Instance-based Restrictions for Bound Actions and Functions

Instance-based restrictions for bound actions and functions are now enforced.

```cds
@restrict : [
  {grant: 'approve', to: 'Employee', where: ($user.role = 'manager') },
  {grant: 'revoke', to: 'Employee', where: (createdBy = $user) },
]
entity Travel {
  key ID: UUID;
  createdBy: String;
} actions {
  action approve();
  action revoke();
}
```

In this example, `revoke` can only be called by the employee who created it and `approve` when the user attribute 'role' equals 'manager'.
If the action or function is bound against the collection and includes any property reference, like `createdBy = $user`, it is not being enforced.

[Learn more about Authorization](/@external/guides/security/authorization){.learn-more}

### SAP Cloud Application Event Hub for Stand-alone Apps <Beta />

[SAP Cloud Application Event Hub](https://help.sap.com/docs/event-broker) is the new default offering for messaging in SAP Business Technology Platform (SAP BTP).
Integration with SAP Cloud Application Event Hub is provided via CDS plugin [`@cap-js/event-broker`](https://github.com/cap-js/event-broker).
See [Using SAP Cloud Application Event Hub in Cloud Foundry](/@external/guides/events/event-hub) for how to consume events emitted by SAP S/4 HANA Cloud in your CAP application.

[Learn more about Messaging](/@external/node.js/messaging){.learn-more}

## Java {#cds-java}

### Enhancements to Code Generator

#### Stricter Setters in Accessor Interfaces

The [generate](../../java/assets/cds-maven-plugin-site/generate-mojo.html){target="_blank"} goal of the [CDS Maven Plugin](/@external/java/developing-applications/building#cds-maven-plugin) got a new parameter `strictSetters`, which controls wether to generate strict type-safe setter methods for associations in the accessor interfaces. Strict type-safe setters accept only collections of accessor interfaces corresponding to the target type of the association.

Let's have a look at the following model:

```cds
entity Books : cuid {
  title  : String;
  author : Association to Authors;
}

entity Authors : cuid {
  name  : String;
  books : Association to many Books on books.author = $self;
}
```

The following table shows generated accessors, based on the `strictSetters` parameter.

|mode|`false`|`true`|
|---|---|---|
|to one|`setAuthor(Map<String, ?> a)`|`setAuthor(Author a)`|
|to many|`setBooks(List<? extends Map<String, ?>> bs)`|`setBooks(List<Books> bs)`|

#### New Factory Method

Accessor interfaces now offer the new factory method `of(Map<String, Object> map)` to access the data in a given map. The method statement `Books.of(map)` is a shortcut for `Struct.access(map).as(Books.class)`.

```java
var map = Map.of("title", "CAP Rules", "year", 2024);

Books book = Books.of(map);
book.getTitle(); // CAP Rules
book.getYear(); // 2024
```

[Learn more about Working with Data](/@external/java/cds-data#cds-data){.learn-more}

### Monitor Health Status of MTX Sidecar

A new health indicator `modelProvider` includes the health status of the [MTX sidecar](/@external/guides/multitenancy/mtxs#sidecars), which serves the [Model Provider Service](/@external/java/reflection-api#the-model-provider-service), into the application's [actuator/health](/@external/java/operating-applications/observability#spring-health-checks) endpoint.
### Parameters Aliases in OData v4

In OData v4, you may now use [parameter aliases](https://docs.oasis-open.org/odata/odata/v4.01/os/part1-protocol/odata-v4.01-os-part1-protocol.html#sec_ParameterAliases) for key values as well as for parameters in function calls. Parameters aliases are names beginning with an at sign (`@`).

::: tip Special characters
Using parameter aliases allows to use special characters like slash (`/`) in values, which is not possible otherwise.
:::

#### Parameter Aliases for Entity Key Values

In the URL, you may use parameter aliases in place of literal entity keys values. Examples:

```http
GET MyService/Orders(ID=@id)?@id=ec806c06-abfe-40c0-b096-c8749aa120f0
GET MyService/Orders(ID=@order, IsActiveEntity=@active)/items(@ID=@item)?@order=ec806c06-abfe-40c0-b096-c8749aa120f0&@active=true&@item=3
```

:::warning Not within system query parameters
Such aliases can't be used within system query parameters like `$filter` or `$orderby`.
:::

#### Parameter Aliases for Function Parameter Values

In function calls, you can now use parameter aliases in the [inline parameter syntax](https://docs.oasis-open.org/odata/odata/v4.01/os/part1-protocol/odata-v4.01-os-part1-protocol.html#sec_InlineParameterSyntax) as placeholders for parameter values. Examples:

```http
GET MyService/EmployeesByManager(ManagerID=@p1)?@p1=3
GET MyService/EmployeesByManager(ManagerID=@p1)?@p1=3
```

This syntax is especially useful to supply values to function parameters with structured or arrayed type.

Considering the following CDS model:

```cds
service MyService {
  function EmployeesByIDs(IDs : many Int32) returns Employee;
  function EmployeesByName(name : { first : String; last : String; })
    returns Employee;
}
```

These are parameter aliases you can use:

```http
GET MyService/EmployeesByIDs(IDS=@ids)?@ids=[1, 5, 8]
GET MyService/EmployeesByName(name=@name)?@name={ "first" : "Sam", "last" : "Smith" }
```

### Add Handler Stubs

With the new `cds add handler` CLI command, it is now possible to generate handler stubs for actions and functions in Java projects. The feature helps you get your project up and running even quicker.

```sh
cds add handler
```

The feature is currently available for Java projects only.

[Learn more about handler generation.](/@external/tools/cds-cli#handler){.learn-more}

### Miscellaneous

<span id="java-attachments-public" />

- A new [CDS property](/@external/java/developing-applications/properties) <Config java keyOnly>cds.odata-v4.fiori-preview.ui5.version:1.125.0</Config> allows to configure the UI5 version used by the [Fiori Preview](/@external/guides/uis/fiori?impl-variant=java#fiori-preview).

## Tools { #tools}

### Visualize Deployment Descriptor <Beta />

The _CDS Preview as diagram_ command in VS Code can visualize an _mta.yaml_:

![](./assets/sep24/mta-hint.png){.ignore-dark}

> This feature requires the [Markdown Preview Mermaid Support](https://marketplace.visualstudio.com/items?itemName=bierner.markdown-mermaid) extension

This helps you get a graphical overview of your microservices architecture and the interplay between applications and services.

<style scoped>
:root:not(.dark) .only-dark {
  display: none;
}

:root:is(.dark) .only-light {
  display: none;
}
</style>

![Visualization of an _mta.yaml_ file](./assets/sep24/mta-mermaid-dark.svg){.only-dark .ignore-dark}
![Visualization of an _mta.yaml_ file](./assets/sep24/mta-mermaid.svg){.only-light}

The sample rendered here was created using the following command:

```sh
cds init bookshop --add hana,xsuaa,portal,multitenancy,mta
```

::: details This also works as a visual linter...

Missing required resources or unused provided ones are highlighted in red.

This is a malformed _mta.yaml_ and its output:

```yaml{12,19}
ID: bookshop
modules:
  - name: bookshop-srv
    type: nodejs
    path: gen/srv
    requires:
      - name: my-service
    provides:
      - name: srv-api
        properties:
          srv-url: ${default-url}
      - name: unused-api # not used

resources:
  - name: my-service
    type: org.cloudfoundry.managed-service
    requires:
      - name: srv-api
      - name: incorrect-srv-api # not defined

```

![Visualization of a malformed _mta.yaml_ file](./assets/sep24/mta-mermaid-malformed.svg){.only-light}
![Visualization of a malformed _mta.yaml_ file](./assets/sep24/mta-mermaid-malformed-dark.svg){.only-dark .ignore-dark}

:::

<!-- ### Lint Check for Invalid `where` Clauses <beta />

[CDS Lint](/@external/tools/cds-lint/) has a new experimental rule `@sap/cds/auth-valid-bound-action-where` to warn if a [bound action or function](/@external/cds/cdl#bound-actions) has a [`where` clause](/@external/guides/security/authorization#instance-based-auth) with a non-static condition, which will not be enforced at runtime. Static conditions are conditions that only refer to `$user` or static values. -->

### New Checks in CDS Lint

There are two new experimental [CDS Lint checks](/@external/tools/cds-lint/rules/):

- `@sap/cds/sql-null-comparison` checks your model for comparisons against SQL's `NULL` value and proposes to use `IS NULL` and `IS NOT NULL` instead.
- `@sap/cds/no-java-keywords` helps you identify CDS identifiers that may clash with CAP Java's code generation, such as Java keywords.

Enable these rules by adding them to your `eslint.config.js` or `.eslintrc.json`.

Furthermore, authentication checks for `@restrict` have been reworked and improved and should no longer report false positives.

Last but not least, we have fixed bugs that prevented the CDS ESLint plugin from reporting issues in your model,
meaning running `eslint` on your command line will now work as expected.
