@cap-js/ord 1.3.2 → 1.3.3

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/lib/ord.js CHANGED
@@ -34,14 +34,15 @@ const initializeAppConfig = (csn) => {
34
34
 
35
35
  _validateNamespaces(ordNamespace, eventApplicationNamespace);
36
36
 
37
- const { serviceNames, apiResourceNames, apiEndpoints, eventNames, entityTypeTargets } = _triageCsnDefinitions(csn);
37
+ const { serviceNames, apiResourceNames, apiEndpoints, eventServiceNames, entityTypeTargets } =
38
+ _triageCsnDefinitions(csn);
38
39
 
39
40
  return {
40
41
  env: cds.env["ord"],
41
42
  lastUpdate,
42
43
  appName,
43
44
  apiEndpoints: Array.from(apiEndpoints),
44
- eventNames,
45
+ eventServiceNames,
45
46
  serviceNames,
46
47
  apiResourceNames,
47
48
  entityTypeTargets: _.uniqBy(entityTypeTargets, CONTENT_MERGE_KEY),
@@ -77,9 +78,12 @@ function _validateNamespaces(ordNamespace, eventApplicationNamespace) {
77
78
  function _triageCsnDefinitions(csn) {
78
79
  const pendingApiResourceNames = [];
79
80
  const apiEndpoints = new Set();
80
- const pendingEventNames = [];
81
+ const pendingEventServiceNames = new Set();
81
82
  const entityTypeTargets = [];
82
83
  const pendingServiceNames = [];
84
+ const serviceNames = Object.keys(csn.definitions).filter(
85
+ (key) => csn.definitions[key].kind === CDS_ELEMENT_KIND.service,
86
+ );
83
87
 
84
88
  for (const definitionKey of Object.keys(csn.definitions)) {
85
89
  const definitionObj = csn.definitions[definitionKey];
@@ -103,8 +107,8 @@ function _triageCsnDefinitions(csn) {
103
107
  break;
104
108
  }
105
109
  case CDS_ELEMENT_KIND.event: {
106
- const event = _handleEvent(definitionKey);
107
- if (event) pendingEventNames.push(event);
110
+ const event = _handleEvent(serviceNames, definitionKey);
111
+ if (event) pendingEventServiceNames.add(event);
108
112
  break;
109
113
  }
110
114
  case CDS_ELEMENT_KIND.action:
@@ -120,7 +124,7 @@ function _triageCsnDefinitions(csn) {
120
124
  serviceNames: pendingServiceNames,
121
125
  apiResourceNames: pendingApiResourceNames,
122
126
  apiEndpoints: Array.from(apiEndpoints),
123
- eventNames: pendingEventNames,
127
+ eventServiceNames: [...pendingEventServiceNames],
124
128
  entityTypeTargets,
125
129
  };
126
130
  }
@@ -156,8 +160,12 @@ function _handleEntity(key, keyDefinition) {
156
160
  return null;
157
161
  }
158
162
 
159
- function _handleEvent(key) {
160
- return key;
163
+ function _handleEvent(serviceNames, key) {
164
+ for (const serviceName of serviceNames) {
165
+ if (key.startsWith(serviceName + ".")) {
166
+ return serviceName;
167
+ }
168
+ }
161
169
  }
162
170
 
163
171
  function _handleActionOrFunction(key) {
@@ -200,7 +208,7 @@ const _getAPIResources = (csn, appConfig, packageIds, accessStrategies) => {
200
208
  };
201
209
 
202
210
  const _getEventResources = (csn, appConfig, packageIds, accessStrategies) => {
203
- return appConfig.serviceNames.flatMap((serviceName) =>
211
+ return appConfig.eventServiceNames.flatMap((serviceName) =>
204
212
  createEventResourceTemplate(serviceName, csn.definitions[serviceName], appConfig, packageIds, accessStrategies),
205
213
  );
206
214
  };
@@ -295,7 +303,7 @@ module.exports = (csn) => {
295
303
  ordDocument.apiResources = apiResources;
296
304
  }
297
305
  }
298
- if (appConfig.eventNames.length) {
306
+ if (appConfig.eventServiceNames.length) {
299
307
  const eventResources = _getEventResources(linkedCsn, appConfig, packageIds, accessStrategies);
300
308
  if (eventResources.length) {
301
309
  ordDocument.eventResources = eventResources;
package/lib/templates.js CHANGED
@@ -301,8 +301,6 @@ const createAPIResourceTemplate = (serviceName, serviceDefinition, appConfig, pa
301
301
  accessStrategies,
302
302
  ),
303
303
  ];
304
-
305
- apiResources.push(obj);
306
304
  }
307
305
 
308
306
  if (obj.visibility !== RESOURCE_VISIBILITY.private) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cap-js/ord",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "CAP Plugin for generating ORD document.",
5
5
  "repository": "cap-js/ord",
6
6
  "author": "SAP SE (https://www.sap.com)",