Skip to content

Commit

Permalink
Merge branch 'main' into java-sidecar-health-indicators
Browse files Browse the repository at this point in the history
  • Loading branch information
vmikhailenko authored Sep 5, 2024
2 parents d2dfa06 + 6ed041a commit 4501e3d
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 44 deletions.
17 changes: 11 additions & 6 deletions .vitepress/theme/components/ScrollToTop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,20 @@ export default {
},
methods: {
scrollToTop() {
window.scrollTo({ top: 0, behavior: 'auto' });
window.scrollTo({ top: 0, behavior: 'smooth' });
},
},
mounted() {
window.addEventListener('scroll', () => {
const isVisible = window.scrollY > 240;
this.enableFadeInClass = isVisible;
this.enableFadeOutClass = !isVisible;
});
const isIOS = /iPad|iPhone|iPod/i.test(window.navigator.userAgent);
if (isIOS) { // iOS already has a system-wide scroll-to-top button at the top
this.visible = false;
} else {
window.addEventListener('scroll', () => {
const isVisible = window.scrollY > 240;
this.enableFadeInClass = isVisible;
this.enableFadeOutClass = !isVisible;
});
}
},
};
</script>
Expand Down
4 changes: 2 additions & 2 deletions guides/databases-postgres.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This guide focuses on the new PostgreSQL Service provided through *[@cap-js/post

<div markdown="1" class="impl java">

CAP Java SDK is tested on [PostgreSQL](https://www.postgresql.org/) 15. Most CAP features are supported on PostgreSQL.
CAP Java 3 is tested on [PostgreSQL](https://www.postgresql.org/) 16 and most CAP features are supported on PostgreSQL.

[Learn more about features and limitations of using CAP with PostgreSQL](../java/cqn-services/persistence-services#postgresql){.learn-more}

Expand Down Expand Up @@ -314,7 +314,7 @@ cds deploy --profile pg
When deploying to Cloud Foundry, this can be accomplished by providing a simple deployer app. Similar to SAP HANA deployer apps, it is auto-generated for PostgreSQL-enabled projects by running

```sh
cds build
cds build --production
```

::: details What `cds build` does…
Expand Down
9 changes: 3 additions & 6 deletions guides/providing-services.md
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,8 @@ service Sue {
entity Foo { key ID:Integer } actions {
function getStock() returns Integer;
action order (x:Integer) returns Integer;
//bound to the collection and not a specific instance of Foo
action customCreate (in: many $self, x: String) returns Foo;
}
}
```
Expand All @@ -1046,12 +1048,7 @@ The differentiation between *Actions* and *Functions* as well as *bound* and *un
- **Actions** modify data in the server
- **Functions** retrieve data
- **Unbound** actions/functions are like plain unbound functions in JavaScript.
- **Bound** actions/functions always receive the bound entity's primary key as implicit first argument, similar to `this` pointers in Java or JavaScript.

::: tip Prefer *Unbound* Actions/Functions
From CDS perspective we recommend **preferring unbound** actions/functions, as these are much more straightforward to implement and invoke.
:::

- **Bound** actions/functions always receive the bound entity's primary key as implicit first argument, similar to `this` pointers in Java or JavaScript. The exception are bound actions to collections, which are bound against the collection and not a specific instance of the entity. An example use case are custom create actions for the SAP Fiori elements UI.


### Implementing Actions / Functions
Expand Down
36 changes: 35 additions & 1 deletion java/cds-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ book.put("ID", 97);
book.put("title", "Dracula");
```

You can now either define an accessor interface or use a [generated accessor interface](#generated-accessor-interfaces).
You can now either define an accessor interface or use a [generated accessor interface](#generated-accessor-interfaces).
If you define an interface yourself, it could look like the following example:

```java
Expand Down Expand Up @@ -525,6 +525,40 @@ interface Equity {
}
```

#### Renaming Types in Java

You might also want to rename the type of the entity. For this you can use annotation `@cds.java.this.name` to specify alternative name for the accessor interfaces and [static model](./cqn-services/persistence-services#staticmodel) interfaces. This annotation can be used only on definitions and is ignored everywhere else.

See the following example:

```cds
@cds.java.this.name: 'MyJavaClass'
entity Class {
key ID: String;
}
```

```java
@CdsName("javaNames.Class")
public interface MyJavaClass extends CdsData {
String ID = "ID";

@CdsName(ID)
String id();

@CdsName(ID)
MyJavaClass id(String id);

// rest of the interface
}
```

In contrast with the annotation `@cds.java.name`, the annotation `@cds.java.this.name` does not rename projections of the annotated entity. If you want to rename chain of entities, you must annotate each of them individually.

::: warning
This feature requires version 8.2.0 of the [CDS Command Line Interface](/tools/cds-cli).
:::

#### Entity Inheritance in Java

In CDS models it is allowed to extend a definition (for example, of an entity) with one or more named [aspects](../cds/cdl#aspects). The aspect allows to define elements or annotations that are common to all extending definitions in one place.
Expand Down
2 changes: 1 addition & 1 deletion java/cqn-services/persistence-services.md
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ See [Class JdbcTemplate](https://docs.spring.io/spring-framework/docs/current/ja
The static model and accessor interfaces can be generated using the [CDS Maven Plugin](../developing-applications/building#cds-maven-plugin).

::: warning _❗ Warning_
Currently, the generator doesn't support using reserved [Java keywords](https://docs.oracle.com/javase/specs/jls/se13/html/jls-3.html#jls-3.9) as identifiers in the CDS model. Conflicting element names can be renamed in Java using the [@cds.java.name](../cds-data#renaming-elements-in-java) annotation.
Currently, the generator doesn't support using reserved [Java keywords](https://docs.oracle.com/javase/specs/jls/se13/html/jls-3.html#jls-3.9) as identifiers in the CDS model. Conflicting element names can be renamed in Java using the [@cds.java.name](../cds-data#renaming-elements-in-java) annotation. For entities, you can use [@cds.java.this.name](../cds-data#renaming-types-in-java).
:::

#### Static Model in the Query Builder
Expand Down
36 changes: 30 additions & 6 deletions node.js/cds-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ Since `@sap/cds^7.5`, running `cds add kibana-logging` or setting `cds.env.featu
Further, there are two formatting aspects that are activated automatically, if appropriate, and add the following information to the loggable object:
1. Running on Cloud Foundry: `tenant_subdomain`, `CF_INSTANCE_IP` and information from `VCAP_APPLICATION`
1. Bound to an instance of the [SAP Application Logging Service for the Cloud Foundry Environment](https://help.sap.com/docs/application-logging-service/sap-application-logging-service/sap-application-logging-service-for-cloud-foundry-environment): `categories` and *custom fields* as described in [Custom Fields](#als-custom-fields)
1. Bound to an instance of the [SAP Application Logging Service](https://help.sap.com/docs/application-logging-service/sap-application-logging-service/sap-application-logging-service-for-cloud-foundry-environment) or [SAP Cloud Logging](https://help.sap.com/docs/cloud-logging/sap-cloud-logging/what-is-sap-cloud-logging): `categories` and *custom fields* as described in [Custom Fields](#custom-fields)
The following screenshot shows the log output for the rejection in the previous example with the JSON log formatter including the two aspects.
Expand All @@ -403,19 +403,20 @@ In case your application shares any sensitive data (for example, secrets) via he
:::
### Custom Fields { #als-custom-fields }
### Custom Fields { #custom-fields }
Information that is not included in the [list of supported fields](https://help.sap.com/docs/application-logging-service/sap-application-logging-service/supported-fields) of the SAP Application Logging Service can be shown as additional information. This information needs to be provided as custom fields.
By default, the JSON formatter uses the following custom fields configuration, which is configurable using [cds.env](cds-env#cds-env):
By default, the JSON formatter uses the following custom fields configuration for SAP Application Logging Service:
```jsonc
{
"log": {
"als_custom_fields": {
// <key>: <index>
"query": 0, //> sql
"target": 1, "details": 2 //> generic validations
"query": 0, //> sql
"target": 1, "details": 2, //> generic validations
"reason": 3 //> errors
}
}
}
Expand Down Expand Up @@ -467,6 +468,22 @@ Without the additional custom field `query` and it's respective value, it would
Before `@sap/cds^7.5`, the configuration property was called `kibana_custom_fields`. As Kibana is the dashboard technology and the custom fields are actually a feature of the SAP Application Logging Service, we changed the name to `als_custom_fields`. `kibana_custom_fields` is supported until `@sap/cds^8`.
:::
For SAP Cloud Logging, the JSON formatter uses the following default configuration:
```jsonc
{
"log": {
"cls_custom_fields": [
"query", //> sql
"target", "details", //> generic validations
"reason" //> errors
]
}
}
```
As always, both defaults are overridable via [cds.env](cds-env#cds-env).
## Request Correlation { #node-observability-correlation }
Expand All @@ -483,6 +500,13 @@ if (!cds.context) cds.context = { id }
req.headers['x-correlation-id'] = cds.context.id
```
The following screenshot shows an example for log correlation in a log analytic dashboard of the [SAP BTP Application Logging Service for Cloud Foundry Environment](https://help.sap.com/docs/application-logging-service).
Subsequently, the JSON log formatter (see [Logging in Production](#logging-in-production)) sets the following fields:
- `cds.context.id` &rarr; `correlation_id`
- Request header `x_vcap_request_id` &rarr; `request_id`
- Request header `traceparent` (cf. [W3C Trace Context](https://www.w3.org/TR/trace-context/)) &rarr; `w3c_traceparent`
Specifically field `w3c_traceparent` is then used by both SAP Application Logging Service and SAP Cloud Logging to determine field `trace_id` in order to correlate requests, logs, and traces across multiple applications.
The following screenshot shows an example for log correlation based on field `correlation_id` in a log analytic dashboard of the [SAP Application Logging Service for SAP BTP](https://help.sap.com/docs/application-logging-service).
![Default Formatter Output](assets/correlation.png)
14 changes: 0 additions & 14 deletions node.js/fiori.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,6 @@ See [Cookbook > Serving UIs > Draft Support](../advanced/fiori#draft-support) fo

Lean draft is a new approach which makes it easier to differentiate between drafts and active instances in your code. This new architecture drastically reduces the complexity and enables more features like storing active instances in remote systems while keeping the corresponding drafts in the local persistence.

### Enablement

Lean draft is enabled by default. Add this to your `cds` configuration to disable the feature:

```json
{
"cds": {
"fiori": {
"lean_draft": false
}
}
}
```

### Handlers Registration {#draft-support}

Class `ApplicationService` provides built-in support for Fiori Draft. All CRUD events are supported for both, active and draft entities.
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions tools/cds-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ Use `cds version` to get information about your installed package version:
<span class="cwd">$</span> <span class="cmd">cds</span> <span class="args">version</span>

<em>@capire/samples:</em> 2.0.0
<em>@sap/cds:</em> 8.1.1
<em>@sap/cds:</em> 8.2.1
<em>@sap/cds-compiler:</em> 5.2.0
<em>@sap/cds-dk:</em> 8.1.2
<em>@sap/cds-dk:</em> 8.2.0
<em>@sap/cds-dk (global):</em> 7.9.3
<em>@sap/cds-mtxs:</em> 2.1.0
<em>@sap/eslint-plugin-cds:</em> 3.0.4
Expand All @@ -58,9 +58,9 @@ Use `cds version` to get information about your installed package version:
| @capire/samples | https://github.com/sap-samples/cloud-cap-samples.git |
|------------------------|------------------------------------------------------|
| Node.js | v18.13.0 |
| @sap/cds | 8.1.1 |
| @sap/cds | 8.2.1 |
| @sap/cds-compiler | 5.2.0 |
| @sap/cds-dk | 8.1.2 |
| @sap/cds-dk | 8.2.0 |
| @sap/eslint-plugin-cds | 3.0.4 |
</pre>

Expand Down

0 comments on commit 4501e3d

Please sign in to comment.