Skip to content

Commit

Permalink
Merge branch 'main' into srv-send-query-headers
Browse files Browse the repository at this point in the history
  • Loading branch information
mariayord authored Jan 17, 2024
2 parents fba003a + ed78d08 commit af7a6ba
Show file tree
Hide file tree
Showing 66 changed files with 2,040 additions and 1,509 deletions.
2 changes: 1 addition & 1 deletion .github/cds-snippet-checker/check-cds-snippets.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function printErrorForSnippet(snippet, messages) {
* @param {object} snippet
*/
function compileSnippet(snippet) {
const options = { messages: snippet.messages };
const options = { messages: snippet.messages, betaMode: true };

const compile = () => {
try {
Expand Down
2 changes: 1 addition & 1 deletion .github/cds-snippet-checker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"check": "node check-cds-snippets.js"
},
"dependencies": {
"@sap/cds-compiler": "^4.2.0"
"@sap/cds-compiler": "^4.4"
}
}
46 changes: 29 additions & 17 deletions .github/etc/create-review.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ module.exports = async ({ github, require, exec, core }) => {
linterErrors.push(...(review.body.match(/\*(.*) <!--Linter Error-->/g) || []))
})

const { data } = await github.request('GET /repos/{owner}/{repo}/pulls/{pull_number}/files', {
owner: REPO_OWNER,
repo: REPO,
pull_number: PULL_NUMBER,
headers: {
accept: 'application/vnd.github.diff'
}
})

const diffs = {}
data.forEach(obj => {
diffs[obj.filename.replace('./', '')] = obj.patch.split('\n')
})

if (existsSync(markdownlintLogFile)) {
const matches = readFileSync(markdownlintLogFile, 'utf-8')
.split('\n')
Expand All @@ -87,6 +101,8 @@ module.exports = async ({ github, require, exec, core }) => {
let contextText = ''
let comment;

if (!fileIsInDiff(path)) continue

if (rule === 'MD011/no-reversed-links') {
const detailValue = details.slice(1, -1)

Expand Down Expand Up @@ -197,6 +213,7 @@ module.exports = async ({ github, require, exec, core }) => {
const wordsWithoutSuggestions = []

for (const [error, path, pointer, word, context, suggestionString] of matches) {
if (!fileIsInDiff(path)) continue

const text = `* **${path}**${pointer} Unknown word "**${word}**" <!--Spelling Mistake-->`

Expand All @@ -209,6 +226,7 @@ module.exports = async ({ github, require, exec, core }) => {
.split(',')
.filter(Boolean) // remove empty strings


const { line, position } = await findPositionInDiff(context, path)

if (!line || position < 0) {
Expand Down Expand Up @@ -266,29 +284,21 @@ module.exports = async ({ github, require, exec, core }) => {
})
}

async function getDiff(file) {
let diff = ''
const opts = {
listeners: {

stdout: (data) => {
diff += data.toString();
}
},
cwd: BASE_DIR
}

await exec.exec(`git diff ${BASE_SHA} ${SHA} -- ${file}`, [], opts)
function fileIsInDiff(file) {
return typeof getDiff(file) !== 'undefined'
}

return diff.split('\n')
function getDiff(file) {
return diffs[file.replace('./', '')]
}

async function findPositionInDiff(context, file) {
const diff = await getDiff(file)
const diff = getDiff(file)

if (!diff) return { position: -1 }

const idxToStartingCoutingFrom = diff.findIndex(line => line.startsWith('@@') && !line.includes('<!--'))
const idxOfLineToSearch = diff.findIndex(line => line.trim().startsWith('+') && line.replace(/ /g, '').includes(context.replace(/ /g, '')) && !line.includes('<!--'))

// context does not exist in diff --> errors is in file with diff, but errors was not introduced with current PR
if (idxToStartingCoutingFrom === -1 || idxOfLineToSearch === -1) {
return { position: -1 }
Expand All @@ -300,7 +310,9 @@ module.exports = async ({ github, require, exec, core }) => {
}

async function findCodeBlockInDiff(lines, file) {
const diff = await getDiff(file)
const diff = getDiff(file)

if (!diff) return { position: -1 }

let start = -1
let end = -1
Expand Down
8 changes: 4 additions & 4 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ if (!siteURL.pathname.endsWith('/')) siteURL.pathname += '/'
const redirectLinks: Record<string, string> = {}

const latestVersions = {
java_services: '2.4.1',
java_cds4j: '2.4.1'
java_services: '2.5.0',
java_cds4j: '2.5.0'
}

const localSearchOptions = {
Expand Down Expand Up @@ -85,7 +85,7 @@ const config:UserConfig<CapireThemeConfig> = {
title: 'CAPire',
description: 'Documentation for SAP Cloud Application Programming Model',
base,
srcExclude: ['**/README.md', '**/LICENSE.md', '**/CONTRIBUTING.md', '**/CODE_OF_CONDUCT.md', '**/menu.md', '**/-*.md'],
srcExclude: ['**/.github/**', '**/README.md', '**/LICENSE.md', '**/CONTRIBUTING.md', '**/CODE_OF_CONDUCT.md', '**/menu.md', '**/-*.md'],
themeConfig: {
logo: '/assets/logos/cap.svg',
// IMPORTANT: Don't use getters here, as they are called again and again!
Expand Down Expand Up @@ -149,7 +149,7 @@ const config:UserConfig<CapireThemeConfig> = {
redirects.devPlugin()
],
build: {
chunkSizeWarningLimit: 4000 // chunk for local search index dominates
chunkSizeWarningLimit: 5000 // chunk for local search index dominates
}
},
transformHtml(code, id, ctx) {
Expand Down
13 changes: 10 additions & 3 deletions .vitepress/lib/md-attrs-propagate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function install(md: MarkdownRenderer, classRegex=/impl (node|java)/) {
})
})

// intercept all container open renderes, like `container_tip_open`
// intercept all container open renderers, like `container_tip_open`
// because these add additional divs, which need to be instrumented as well
const { rules } = md.renderer
// console.log('rules', rules)
Expand All @@ -60,13 +60,20 @@ export function install(md: MarkdownRenderer, classRegex=/impl (node|java)/) {
const [tokens, idx] = args
const token = tokens[idx]
if (token.meta?.classes) {
const classes = token.meta?.classes as string
// delete classes in token.attrs as these would be rendered in addition,
// leading to 'Duplicate attribute' errors
deleteAttr('class', token.attrs)

let result:string = original(...args)
if (!classes.split(' ').some(cls => result.includes(cls))) { // some of classes already set?
const hasClass = (classes: any, result: any) => {
const match = result.match(/class="([^"]*)"/)
if (!match || match.length < 2) return false
const existing = match[1].split(/\s+/)
return classes.split(' ').some((cls: any) => existing.includes(cls))
}

// Usage in your code
if (!hasClass(token.meta.classes, result)) {
if (result.includes(' class="')) { // `class` attribute existing -> augment
result = result.replace(' class="', ` class="${token.meta.classes} `)
} else { // no `class` attribute -> set one
Expand Down
1 change: 1 addition & 0 deletions .vitepress/theme/components/indexFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default (pages, basePath) => {
if (item) p.title = item.text
return !!item
})
.filter(p => !p.url.endsWith(basePath))
.sort((p1, p2) => itemLinks.indexOf(p1.url) - itemLinks.indexOf(p2.url))
.map(p => {
// this data is inlined in each index page, so sparsely construct the final object
Expand Down
4 changes: 3 additions & 1 deletion .vitepress/theme/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ main {

// Fix for copy button position
[class*='language-'] > button.copy {
top: 7px;
top: 4px;
}

pre.log {
Expand Down Expand Up @@ -283,6 +283,8 @@ kbd {
box-shadow: inset 0 -1px 0 var(--vp-c-divider);
position: relative;
top: -1px;
background: #f3f3f3;
.dark & { background: #222 }
}

.learn-more {
Expand Down
18 changes: 9 additions & 9 deletions about/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ Following is an index of the features currently covered by CAP, with status and
<br>

| Editors/IDE Support | Application Studio | VS Code | Eclipse |
|--------------------------|:------------------:|:-------:|:-------:|
| CDS Syntax Highlighting | <X/> | <X/> | <X/> |
| CDS Code Completion | <X/> | <X/> | <X/> |
| CDS Prettifier | <X/> | <X/> | <X/> |
| Advanced Debug/Run Tools | <X/> | | |
| Project Explorer | <X/> | | |
| ... | | | |
| Editors/IDE Support | Application Studio | VS Code |
|--------------------------|:------------------:|:-------:|
| CDS Syntax Highlighting | <X/> | <X/> |
| CDS Code Completion | <X/> | <X/> |
| CDS Prettifier | <X/> | <X/> |
| Advanced Debug/Run Tools | <X/> | |
| Project Explorer | <X/> | |
| ... | | |


### CDS Language & Compiler
Expand Down Expand Up @@ -234,7 +234,7 @@ Following is an index of the features currently covered by CAP, with status and
| [Deploy to/run on _SAP BTP, Cloud Foundry environment_](../guides/deployment/) | <X/> | <X/> |
| Deploy to/run on _Kubernetes_<sup>1</sup> | <D/> | <D/> |
| [Deploy to/run on _Kyma_](../guides/deployment/deploy-to-kyma) | <X/> | <X/> |
| [SaaS on-/offboarding](../guides/deployment/as-saas) | <X/> | <X/> |
| [SaaS on-/offboarding](../guides/multitenancy/) | <X/> | <X/> |
| [Multitenancy](../guides/multitenancy/) | <X/> | <X/> |
| Health checks | <O/> | <X/> |

Expand Down
2 changes: 1 addition & 1 deletion about/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ That might sound like a contradiction, but isn't: While CAP certainly gives *opi
| **Higher-level concepts and APIs** abstracting from and avoiding lock-ins to low-level platform features and protocols | All abstractions follow a glass-box pattern that allows unrestricted access to lower-level things, if required |
| **Best Practices served out of the box** with generic solutions for many recurring tasks | You can always handle things your way in [custom handlers](../guides/providing-services#custom-logic), decide whether to adopt [CQRS](./related#cqrs) or [Event Sourcing](./related#event-sourcing), for example ... while CAP simply tries to get the tedious tasks out of your way. |
| **Out-of-the-box support** for <br> **[SAP Fiori](https://developers.sap.com/topics/ui-development.html)** and **[SAP HANA](https://developers.sap.com/topics/hana.html)** | You can also choose other UI technologies, like [Vue.js](../get-started/in-a-nutshell#vue), or databases, by providing new database integrations. |
| **Dedicated tools support** provided in [SAP Business Application Studio](../tools/#bastudio), and [Visual Studio Code](../tools/#vscode) or [Eclipse](../java/getting-started#eclipse). | CAP doesn't depend on those tools. Everything in CAP can be done using the [`@sap/cds-dk`](../get-started/jumpstart) CLI and any editor or IDE of your choice. |
| **Dedicated tools support** provided in [SAP Business Application Studio](../tools/#bastudio) or [Visual Studio Code](../tools/#vscode). | CAP doesn't depend on those tools. Everything in CAP can be done using the [`@sap/cds-dk`](../get-started/jumpstart) CLI and any editor or IDE of your choice. |


### Key Concepts & Paradigms
Expand Down
35 changes: 22 additions & 13 deletions advanced/odata.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,22 +217,25 @@ OData defines a strict two-fold key structure composed of `@<Vocabulary>.<Term>`

```cds
@Common.Label: 'Customer'
@Common.ValueList: {
Label: 'Customers',
CollectionPath: 'Customers'
@UI.HeaderInfo: {
TypeName : 'Customer',
TypeNamePlural : 'Customers',
Title : { Value : name }
}
entity Customers { }
entity Customers { /* ... */ }
```

This is represented in CSN as follows:

```json
```jsonc
{"definitions":{
"Customers":{
"kind": "entity",
"@Common.Label": "Customer",
"@Common.ValueList.Label": "Customers",
"@Common.ValueList.CollectionPath": "Customers"
"@UI.HeaderInfo.TypeName": "Customer",
"@UI.HeaderInfo.TypeNamePlural": "Customers",
"@UI.HeaderInfo.Title.Value": {"=": "name"},
/* ... */
}
}}
```
Expand All @@ -242,17 +245,23 @@ And would render to EDMX as follows:
```xml
<Annotations Target="MyService.Customers">
<Annotation Term="Common.Label" String="Customer"/>
<Annotation Term="Common.ValueList">
<Record Type="Common.ValueListType">
<PropertyValue Property="Label" String="Customers"/>
<PropertyValue Property="CollectionPath" String="Customers"/>
<Annotation Term="UI.HeaderInfo">
<Record Type="UI.HeaderInfoType">
<PropertyValue Property="TypeName" String="Customer"/>
<PropertyValue Property="TypeNamePlural" String="Customers"/>
<PropertyValue Property="Title">
<Record Type="UI.DataField">
<PropertyValue Property="Value" Path="name"/>
</Record>
</PropertyValue>
</Record>
</Annotation>
</Annotations>
```

::: tip
The value for `@Common.ValueList` is flattened to individual key-value pairs in CSN and 'restructured' to a record for OData exposure in EDMX.
The value for `@UI.HeaderInfo` is flattened to individual key-value pairs in CSN and 'restructured'
to a record for OData exposure in EDMX.
:::

For each annotated target definition in CSN, the rules for restructuring from CSN sources are:
Expand Down Expand Up @@ -1071,7 +1080,7 @@ For Node.js projects, add the proxy as express.js middleware as follows:
::: code-group
```json [package.json]
{...
"cds" {
"cds" : {
"cov2ap" : {
"plugin" : true
}
Expand Down
Loading

0 comments on commit af7a6ba

Please sign in to comment.