@sap/cds 5.9.7 → 5.9.8

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,6 +4,14 @@
4
4
  - The format is based on [Keep a Changelog](http://keepachangelog.com/).
5
5
  - This project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
+ ## Version 5.9.8 - 2022-06-24
8
+
9
+ ### Fixed
10
+
11
+ - Application model is now again properly updated after extension activation
12
+ - Avoid crashes during `cds version` when `folders.db` or `folders.srv` are array-valued instead of strings
13
+ - `cds build` correctly validates MTX extension allow lists and doesn't log false positive warning messages
14
+
7
15
  ## Version 5.9.7 - 2022-06-13
8
16
 
9
17
  ### Fixed
@@ -127,26 +127,21 @@ class MtxModuleBuilder extends BuildTaskHandlerEdmx {
127
127
  }
128
128
  }
129
129
 
130
+ function isValid(e, pattern, nsPattern, kind) {
131
+ return e && e.name && (e.name === pattern || (nsPattern && e.name.startsWith(nsPattern))) && (!kind || e.kind === kind)
132
+ }
133
+
130
134
  if (extensionAllowlist || entityWhitelist || serviceWhitelist) {
131
135
  const invalidEntries = new Set()
132
136
  const reflected = this.cds.reflect(model)
133
- const services = reflected.services
134
- const entities = Object.values(reflected.entities)
135
137
 
136
138
  if (Array.isArray(extensionAllowlist)) {
137
139
  extensionAllowlist.forEach(allowListEntry => {
138
140
  if (Array.isArray(allowListEntry.for)) {
139
141
  allowListEntry.for.forEach(pattern => {
140
142
  if (pattern !== '*') {
141
- const nsPattern = pattern + '.'
142
- if (allowListEntry.kind === 'service') {
143
- if (!services.some(service => service.name === pattern || service.name.startsWith(nsPattern))) {
144
- invalidEntries.add(pattern)
145
- }
146
- } else {
147
- if (!entities.some(entity => entity.name === pattern || entity.name.startsWith(nsPattern))) {
148
- invalidEntries.add(pattern)
149
- }
143
+ if (!reflected.find(e => isValid(e, pattern, pattern + '.', allowListEntry.kind))) {
144
+ invalidEntries.add(pattern)
150
145
  }
151
146
  }
152
147
  })
@@ -159,14 +154,14 @@ class MtxModuleBuilder extends BuildTaskHandlerEdmx {
159
154
  // validate whitelist entries
160
155
  if (Array.isArray(entityWhitelist)) {
161
156
  entityWhitelist.forEach(name => {
162
- if (!entities.some(entity => entity.name === name && entity.kind === 'entity')) {
157
+ if (!reflected.find(e => isValid(e, name, null, "entity"))) {
163
158
  invalidEntries.add(name)
164
159
  }
165
160
  })
166
161
  }
167
162
  if (Array.isArray(serviceWhitelist)) {
168
163
  serviceWhitelist.forEach(name => {
169
- if (!services.some(service => service.name === name && service.kind === 'service')) {
164
+ if (!reflected.find(e => isValid(e, name, null, "service"))) {
170
165
  invalidEntries.add(name)
171
166
  }
172
167
  })
package/bin/version.js CHANGED
@@ -159,7 +159,7 @@ function _findMTX() {
159
159
 
160
160
  // mtx still not found via cds.env? Try looking in well-known subdirectories
161
161
  const folders = cds.env.folders
162
- ? [cds.env.folders.db, cds.env.folders.srv].filter(d => d)
162
+ ? [cds.env.folders.db, cds.env.folders.srv].flat().filter(d => d)
163
163
  : []
164
164
  let i = 0
165
165
  while(res[cdsmtx] === undefined && i < folders.length) {
@@ -33,8 +33,8 @@ class Dispatcher {
33
33
  }
34
34
 
35
35
  if (cds._mtxEnabled) {
36
- cds.mtx.eventEmitter.on(cds.mtx.events.TENANT_UPDATED, async hash => {
37
- this._extMap.delete(hash)
36
+ cds.mtx.eventEmitter.on(cds.mtx.events.TENANT_UPDATED, async tenant => {
37
+ this._extMap.delete(getModelHash(tenant))
38
38
  })
39
39
  }
40
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/cds",
3
- "version": "5.9.7",
3
+ "version": "5.9.8",
4
4
  "description": "SAP Cloud Application Programming Model - CDS for Node.js",
5
5
  "homepage": "https://cap.cloud.sap/",
6
6
  "keywords": [