@cap-js/ord 1.6.0 → 1.8.0
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/build.js +4 -3
- package/lib/common/register-compile-targets.js +1 -1
- package/lib/configuration.js +161 -0
- package/lib/constants.js +11 -10
- package/lib/defaults.js +73 -53
- package/lib/integration-dependency.js +3 -4
- package/lib/interop-csn.js +1 -1
- package/lib/ord.js +65 -308
- package/lib/protocol-resolver.js +3 -16
- package/lib/services/mtx-ord-provider-service.js +13 -9
- package/lib/services/ord-service.js +73 -21
- package/lib/templates.js +123 -120
- package/package.json +5 -4
- package/lib/utils.js +0 -12
package/lib/templates.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { hasSAPPolicyLevel } = require("./utils");
|
|
2
1
|
const defaults = require("./defaults");
|
|
3
2
|
const _ = require("lodash");
|
|
4
3
|
const {
|
|
@@ -33,11 +32,11 @@ function unflatten(flattedObject) {
|
|
|
33
32
|
return result;
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
function readORDExtensions(model) {
|
|
35
|
+
function readORDExtensions(model, prefix = ORD_EXTENSIONS_PREFIX) {
|
|
37
36
|
const ordExtensions = {};
|
|
38
37
|
for (const key in model) {
|
|
39
|
-
if (key.startsWith(
|
|
40
|
-
const ordKey = key.replace(
|
|
38
|
+
if (key.startsWith(prefix)) {
|
|
39
|
+
const ordKey = key.replace(prefix, "");
|
|
41
40
|
ordExtensions[ordKey] = model[key];
|
|
42
41
|
}
|
|
43
42
|
}
|
|
@@ -64,9 +63,9 @@ const createEntityTypeMappingsItemTemplate = (entity) => {
|
|
|
64
63
|
const ordIdParts = entity[ENTITY_RELATIONSHIP_ANNOTATION].split(":");
|
|
65
64
|
const namespace = ordIdParts[0];
|
|
66
65
|
const entityName = ordIdParts[1];
|
|
67
|
-
const version = ordIdParts[2] || "
|
|
66
|
+
const version = entity[`${ORD_EXTENSIONS_PREFIX}version`] || ordIdParts[2]?.substring(1) || "1";
|
|
68
67
|
results.push({
|
|
69
|
-
ordId: `${namespace}:entityType:${entityName}
|
|
68
|
+
ordId: `${namespace}:entityType:${entityName}:v${version.split(".")[0]}`,
|
|
70
69
|
entityName,
|
|
71
70
|
...entity,
|
|
72
71
|
});
|
|
@@ -75,15 +74,23 @@ const createEntityTypeMappingsItemTemplate = (entity) => {
|
|
|
75
74
|
return results;
|
|
76
75
|
};
|
|
77
76
|
|
|
78
|
-
function _getGroupID(
|
|
79
|
-
return `${groupTypeId}:${appConfig.ordNamespace}:${
|
|
77
|
+
function _getGroupID(appConfig, srvDefinition) {
|
|
78
|
+
return `${defaults.groupTypeId}:${appConfig.ordNamespace}:${_getCleanServiceName(srvDefinition.name, appConfig)}`;
|
|
80
79
|
}
|
|
81
80
|
|
|
82
|
-
function
|
|
83
|
-
if (!name.startsWith(
|
|
84
|
-
|
|
81
|
+
function _startsWithNamespace(name, namespace) {
|
|
82
|
+
if (!name.startsWith(namespace)) return false;
|
|
83
|
+
const rest = name.substring(namespace.length);
|
|
84
|
+
return rest === "" || rest.startsWith(".");
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function _getCleanServiceName(name, appConfig) {
|
|
88
|
+
let sortedName = name;
|
|
89
|
+
if (appConfig.internalNamespace && _startsWithNamespace(name, appConfig.internalNamespace)) {
|
|
90
|
+
sortedName = name.substring(appConfig.internalNamespace.length);
|
|
91
|
+
} else if (_startsWithNamespace(name, appConfig.ordNamespace)) {
|
|
92
|
+
sortedName = name.substring(appConfig.ordNamespace.length);
|
|
85
93
|
}
|
|
86
|
-
let sortedName = name.substring(appConfig.ordNamespace.length);
|
|
87
94
|
if (sortedName.startsWith(".")) {
|
|
88
95
|
sortedName = sortedName.substring(1);
|
|
89
96
|
}
|
|
@@ -115,7 +122,7 @@ function _getTitleFromServiceName(srv) {
|
|
|
115
122
|
*/
|
|
116
123
|
function _getEntityVersion(entity) {
|
|
117
124
|
const entityVersion = entity.ordId.split(":").pop();
|
|
118
|
-
const version = entityVersion.replace("v", "") + ".0.0";
|
|
125
|
+
const version = entityVersion.replace("v", "") + ".0.0";
|
|
119
126
|
if (!SEM_VERSION_REGEX.test(version)) {
|
|
120
127
|
Logger.warn("Entity version", version, "is not a valid semantic version.");
|
|
121
128
|
}
|
|
@@ -155,31 +162,24 @@ function _getResourceDefinition(resourceType, mediaType, ordId, serviceName, fil
|
|
|
155
162
|
/**
|
|
156
163
|
* This is a template function to create group object of a service for groups array in ORD doc.
|
|
157
164
|
*
|
|
158
|
-
* @param {
|
|
159
|
-
* @param {object}
|
|
160
|
-
* @param {Set} groupIds A set of group ids.
|
|
165
|
+
* @param {object} srvDefinition The definition of the service
|
|
166
|
+
* @param {object} appConfig - The application configuration.
|
|
161
167
|
* @returns {Object} A group object.
|
|
162
168
|
*/
|
|
163
|
-
const createGroupsTemplateForService = (
|
|
164
|
-
const ordExtensions = readORDExtensions(
|
|
165
|
-
|
|
166
|
-
if (!serviceDefinition) {
|
|
167
|
-
Logger.warn("Unable to find service definition:", serviceName);
|
|
168
|
-
return undefined;
|
|
169
|
-
}
|
|
169
|
+
const createGroupsTemplateForService = (srvDefinition, appConfig) => {
|
|
170
|
+
const ordExtensions = readORDExtensions(srvDefinition);
|
|
171
|
+
const visibility = _handleVisibility(ordExtensions, srvDefinition, appConfig.env?.defaultVisibility);
|
|
170
172
|
|
|
171
|
-
const visibility = _handleVisibility(ordExtensions, serviceDefinition, appConfig.env?.defaultVisibility);
|
|
172
173
|
if (visibility === RESOURCE_VISIBILITY.private) {
|
|
173
174
|
// If the visibility of the service is private, do not create a group
|
|
174
|
-
Logger.info("Skipping group creation for private service:",
|
|
175
|
+
Logger.info("Skipping group creation for private service:", srvDefinition.name);
|
|
175
176
|
return undefined;
|
|
176
177
|
}
|
|
177
178
|
|
|
178
|
-
const groupId = _getGroupID(serviceDefinition, defaults.groupTypeId, appConfig);
|
|
179
179
|
return {
|
|
180
|
-
groupId:
|
|
180
|
+
groupId: _getGroupID(appConfig, srvDefinition),
|
|
181
181
|
groupTypeId: defaults.groupTypeId,
|
|
182
|
-
title: ordExtensions.title ?? _getTitleFromServiceName(
|
|
182
|
+
title: ordExtensions.title ?? _getTitleFromServiceName(srvDefinition.name),
|
|
183
183
|
};
|
|
184
184
|
};
|
|
185
185
|
|
|
@@ -197,7 +197,7 @@ const createEntityTypeTemplate = (appConfig, packageIds, entity) => {
|
|
|
197
197
|
// ODM mappings are not created as entity types, they are only used in entityTypeMappings
|
|
198
198
|
return [];
|
|
199
199
|
}
|
|
200
|
-
if (
|
|
200
|
+
if (appConfig.hasSAPPolicyLevel) {
|
|
201
201
|
// If SAP policy level is present, don't create entity type, they must be in the central repository
|
|
202
202
|
return [];
|
|
203
203
|
}
|
|
@@ -214,7 +214,7 @@ const createEntityTypeTemplate = (appConfig, packageIds, entity) => {
|
|
|
214
214
|
return {
|
|
215
215
|
ordId: entity.ordId,
|
|
216
216
|
localId: entity.entityName,
|
|
217
|
-
title: entity["@title"] ?? entity["@Common.Label"] ?? entity.entityName,
|
|
217
|
+
title: entity["@title"] ?? entity["@Common.Label"] ?? entity["@EndUserText.label"] ?? entity.entityName,
|
|
218
218
|
shortDescription: SHORT_DESCRIPTION_PREFIX + entity.entityName,
|
|
219
219
|
description: DESCRIPTION_PREFIX + entity.entityName,
|
|
220
220
|
version: _getEntityVersion(entity),
|
|
@@ -273,26 +273,24 @@ function _handleVisibility(ordExtensions, definition, defaultVisibility = RESOUR
|
|
|
273
273
|
* This is a template function to create API Resource object for API Resource Array.
|
|
274
274
|
* Properties of an API resource can be overwritten by the ORD extensions. Example: visibility.
|
|
275
275
|
* Ensures proper visibility compliance by checking associated EntityTypes.
|
|
276
|
-
* @param {
|
|
277
|
-
* @param {object} serviceDefinition The definition of the service
|
|
276
|
+
* @param {object} srvDefinition The definition of the service
|
|
278
277
|
* @param {object} appConfig - The application configuration.
|
|
279
278
|
* @param {Array} packageIds - The available package identifiers.
|
|
280
279
|
* @param {Array} accessStrategies The array of accessStrategies objects
|
|
281
280
|
* @returns {Array} An array of objects for the API Resources.
|
|
282
281
|
*/
|
|
283
|
-
const createAPIResourceTemplate = (
|
|
284
|
-
const ordExtensions = readORDExtensions(
|
|
285
|
-
const visibility = _handleVisibility(ordExtensions,
|
|
282
|
+
const createAPIResourceTemplate = (srvDefinition, appConfig, packageIds, accessStrategies) => {
|
|
283
|
+
const ordExtensions = readORDExtensions(srvDefinition);
|
|
284
|
+
const visibility = _handleVisibility(ordExtensions, srvDefinition, appConfig.env?.defaultVisibility);
|
|
286
285
|
const packageId = _getPackageID(appConfig.ordNamespace, packageIds, ORD_RESOURCE_TYPE.api, visibility);
|
|
287
|
-
|
|
288
|
-
const protocolResults = resolveApiResourceProtocol(serviceName, serviceDefinition, {
|
|
286
|
+
const protocolResults = resolveApiResourceProtocol(srvDefinition, {
|
|
289
287
|
isPrimaryDataProduct: isPrimaryDataProductService,
|
|
290
288
|
});
|
|
291
289
|
const apiResources = [];
|
|
292
290
|
|
|
293
291
|
// If no protocols were generated, skip this service
|
|
294
292
|
if (protocolResults.length === 0) {
|
|
295
|
-
Logger.info(`No supported protocols for service '${
|
|
293
|
+
Logger.info(`No supported protocols for service '${srvDefinition.name}', skipping API resource generation.`);
|
|
296
294
|
return apiResources;
|
|
297
295
|
}
|
|
298
296
|
|
|
@@ -301,31 +299,26 @@ const createAPIResourceTemplate = (serviceName, serviceDefinition, appConfig, pa
|
|
|
301
299
|
version,
|
|
302
300
|
semanticVersion,
|
|
303
301
|
extracted = null;
|
|
304
|
-
if (isPrimaryDataProductService(
|
|
305
|
-
extracted = _extractVersionFromServiceName(
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
version = extracted.version;
|
|
311
|
-
semanticVersion = extracted.semanticVersion;
|
|
312
|
-
} else {
|
|
313
|
-
// Invalid pattern - use current behavior
|
|
314
|
-
cleanServiceName = _getGroupNameWithNestedNamespace(serviceDefinition, appConfig);
|
|
315
|
-
version = "v1";
|
|
316
|
-
semanticVersion = "1.0.0";
|
|
317
|
-
}
|
|
302
|
+
if (isPrimaryDataProductService(srvDefinition)) {
|
|
303
|
+
extracted = _extractVersionFromServiceName(srvDefinition.name);
|
|
304
|
+
|
|
305
|
+
cleanServiceName = _getCleanServiceName(extracted?.cleanName || srvDefinition.name, appConfig);
|
|
306
|
+
semanticVersion = ordExtensions.version || extracted?.semanticVersion || "1.0.0";
|
|
307
|
+
version = `v${semanticVersion.split(".")[0]}`;
|
|
318
308
|
} else {
|
|
319
309
|
// Non-data product - use current behavior
|
|
320
|
-
cleanServiceName =
|
|
321
|
-
|
|
322
|
-
|
|
310
|
+
cleanServiceName = _getCleanServiceName(srvDefinition.name, appConfig);
|
|
311
|
+
semanticVersion = ordExtensions.version || "1.0.0";
|
|
312
|
+
version = `v${semanticVersion.split(".")[0]}`;
|
|
323
313
|
}
|
|
324
314
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
protocolResults.forEach((protocolResult) => {
|
|
315
|
+
protocolResults.forEach((protocolResult, index) => {
|
|
328
316
|
const { apiProtocol, entryPoints, hasResourceDefinitions } = protocolResult;
|
|
317
|
+
const protocolExtensions = readORDExtensions(srvDefinition, `@protocol('${apiProtocol}').ORD.Extensions.`);
|
|
318
|
+
const ordId =
|
|
319
|
+
protocolExtensions.ordId ||
|
|
320
|
+
ordExtensions.ordId ||
|
|
321
|
+
`${appConfig.ordNamespace}:apiResource:${cleanServiceName}${index === 0 ? "" : `-${apiProtocol}`}:${version}`;
|
|
329
322
|
|
|
330
323
|
// Build resource definitions based on protocol
|
|
331
324
|
let resourceDefinitions = [];
|
|
@@ -337,7 +330,7 @@ const createAPIResourceTemplate = (serviceName, serviceDefinition, appConfig, pa
|
|
|
337
330
|
"sap-csn-interop-effective-v1",
|
|
338
331
|
"json",
|
|
339
332
|
ordId,
|
|
340
|
-
|
|
333
|
+
srvDefinition.name,
|
|
341
334
|
"csn.json",
|
|
342
335
|
accessStrategies,
|
|
343
336
|
),
|
|
@@ -345,11 +338,25 @@ const createAPIResourceTemplate = (serviceName, serviceDefinition, appConfig, pa
|
|
|
345
338
|
} else if (apiProtocol === ORD_API_PROTOCOL.REST) {
|
|
346
339
|
// REST only has OpenAPI, no EDMX
|
|
347
340
|
resourceDefinitions = [
|
|
348
|
-
_getResourceDefinition(
|
|
341
|
+
_getResourceDefinition(
|
|
342
|
+
"openapi-v3",
|
|
343
|
+
"json",
|
|
344
|
+
ordId,
|
|
345
|
+
srvDefinition.name,
|
|
346
|
+
"oas3.json",
|
|
347
|
+
accessStrategies,
|
|
348
|
+
),
|
|
349
349
|
];
|
|
350
350
|
} else if (apiProtocol === ORD_API_PROTOCOL.MCP) {
|
|
351
351
|
resourceDefinitions = [
|
|
352
|
-
_getResourceDefinition(
|
|
352
|
+
_getResourceDefinition(
|
|
353
|
+
MCP_RESOURCE_DEFINITION_TYPE,
|
|
354
|
+
"json",
|
|
355
|
+
ordId,
|
|
356
|
+
srvDefinition.name,
|
|
357
|
+
"mcp.json",
|
|
358
|
+
accessStrategies,
|
|
359
|
+
),
|
|
353
360
|
];
|
|
354
361
|
} else if (apiProtocol === ORD_API_PROTOCOL.GRAPHQL) {
|
|
355
362
|
// GraphQL only has GraphQL SDL
|
|
@@ -357,34 +364,49 @@ const createAPIResourceTemplate = (serviceName, serviceDefinition, appConfig, pa
|
|
|
357
364
|
{
|
|
358
365
|
type: "graphql-sdl",
|
|
359
366
|
mediaType: "text/plain",
|
|
360
|
-
url: `/ord/v1/${ordId}/${
|
|
367
|
+
url: `/ord/v1/${ordId}/${srvDefinition.name}.graphql`,
|
|
361
368
|
accessStrategies: ensureAccessStrategies(accessStrategies, {
|
|
362
|
-
resourceName: `${
|
|
369
|
+
resourceName: `${srvDefinition.name} (graphql-sdl)`,
|
|
363
370
|
}),
|
|
364
371
|
},
|
|
365
372
|
];
|
|
373
|
+
} else if (apiProtocol === ORD_API_PROTOCOL.ODATA_V2) {
|
|
374
|
+
// openapi-v3 is not supported for OData V2, only EDMX
|
|
375
|
+
resourceDefinitions = [
|
|
376
|
+
_getResourceDefinition("edmx", "xml", ordId, srvDefinition.name, "edmx", accessStrategies),
|
|
377
|
+
];
|
|
366
378
|
} else {
|
|
367
|
-
//
|
|
379
|
+
// odata-v4 and others have both OpenAPI and EDMX
|
|
368
380
|
resourceDefinitions = [
|
|
369
|
-
_getResourceDefinition(
|
|
370
|
-
|
|
381
|
+
_getResourceDefinition(
|
|
382
|
+
"openapi-v3",
|
|
383
|
+
"json",
|
|
384
|
+
ordId,
|
|
385
|
+
srvDefinition.name,
|
|
386
|
+
"oas3.json",
|
|
387
|
+
accessStrategies,
|
|
388
|
+
),
|
|
389
|
+
_getResourceDefinition("edmx", "xml", ordId, srvDefinition.name, "edmx", accessStrategies),
|
|
371
390
|
];
|
|
372
391
|
}
|
|
373
392
|
}
|
|
374
393
|
|
|
375
|
-
const
|
|
376
|
-
const exposedEntityTypes = _getExposedEntityTypes(serviceDefinition);
|
|
394
|
+
const exposedEntityTypes = _getExposedEntityTypes(srvDefinition);
|
|
377
395
|
|
|
378
396
|
let obj = {
|
|
379
397
|
ordId,
|
|
380
|
-
title:
|
|
381
|
-
|
|
382
|
-
|
|
398
|
+
title:
|
|
399
|
+
srvDefinition["@title"] ??
|
|
400
|
+
srvDefinition["@Common.Label"] ??
|
|
401
|
+
srvDefinition["@EndUserText.label"] ??
|
|
402
|
+
srvDefinition.name,
|
|
403
|
+
shortDescription: SHORT_DESCRIPTION_PREFIX + srvDefinition.name,
|
|
404
|
+
description: srvDefinition["@Core.Description"] ?? DESCRIPTION_PREFIX + srvDefinition.name,
|
|
383
405
|
version: semanticVersion,
|
|
384
406
|
lastUpdate: appConfig.lastUpdate,
|
|
385
407
|
visibility,
|
|
386
408
|
partOfPackage: packageId,
|
|
387
|
-
partOfGroups: [_getGroupID(
|
|
409
|
+
partOfGroups: [_getGroupID(appConfig, srvDefinition)],
|
|
388
410
|
releaseStatus: "active",
|
|
389
411
|
apiProtocol,
|
|
390
412
|
resourceDefinitions,
|
|
@@ -392,13 +414,13 @@ const createAPIResourceTemplate = (serviceName, serviceDefinition, appConfig, pa
|
|
|
392
414
|
extensible: {
|
|
393
415
|
supported: "no",
|
|
394
416
|
},
|
|
395
|
-
...(entityTypeMappings ? { entityTypeMappings } : {}),
|
|
396
417
|
...(exposedEntityTypes ? { exposedEntityTypes } : []),
|
|
397
418
|
...ordExtensions,
|
|
419
|
+
...protocolExtensions,
|
|
398
420
|
};
|
|
399
421
|
|
|
400
422
|
// Special handling for data product services
|
|
401
|
-
if (isPrimaryDataProductService(
|
|
423
|
+
if (isPrimaryDataProductService(srvDefinition)) {
|
|
402
424
|
obj.direction = "outbound";
|
|
403
425
|
if (extracted) {
|
|
404
426
|
// Overwrite partOfGroups
|
|
@@ -420,43 +442,49 @@ const createAPIResourceTemplate = (serviceName, serviceDefinition, appConfig, pa
|
|
|
420
442
|
* Properties of an event resource can be overwritten by the ORD extensions. Example: visibility.
|
|
421
443
|
* Ensures proper visibility compliance by checking associated EntityTypes.
|
|
422
444
|
*
|
|
423
|
-
* @param {
|
|
424
|
-
* @param {object} serviceDefinition The definition of the service
|
|
445
|
+
* @param {object} srvDefinition The definition of the service
|
|
425
446
|
* @param {object} appConfig - The application configuration.
|
|
426
447
|
* @param {Array} packageIds - The available package identifiers.
|
|
427
448
|
* @param {Array} accessStrategies The array of accessStrategies objects
|
|
428
449
|
* @returns {Array} An single-item array of objects for the Event Resources.
|
|
429
450
|
*/
|
|
430
|
-
const createEventResourceTemplate = (
|
|
431
|
-
const ordExtensions = readORDExtensions(
|
|
432
|
-
const visibility = _handleVisibility(ordExtensions,
|
|
451
|
+
const createEventResourceTemplate = (srvDefinition, appConfig, packageIds, accessStrategies) => {
|
|
452
|
+
const ordExtensions = readORDExtensions(srvDefinition);
|
|
453
|
+
const visibility = _handleVisibility(ordExtensions, srvDefinition, appConfig.env?.defaultVisibility);
|
|
454
|
+
const version = ordExtensions.version || "1.0.0";
|
|
433
455
|
const packageId = _getPackageID(appConfig.ordNamespace, packageIds, ORD_RESOURCE_TYPE.event, visibility);
|
|
434
|
-
const ordId = `${appConfig.ordNamespace}:eventResource:${
|
|
435
|
-
const
|
|
436
|
-
const exposedEntityTypes = _getExposedEntityTypes(serviceDefinition);
|
|
456
|
+
const ordId = `${appConfig.ordNamespace}:eventResource:${_getCleanServiceName(srvDefinition.name, appConfig)}:v${version.split(".")[0]}`;
|
|
457
|
+
const exposedEntityTypes = _getExposedEntityTypes(srvDefinition);
|
|
437
458
|
|
|
438
459
|
let obj = {
|
|
439
460
|
ordId,
|
|
440
461
|
title:
|
|
441
|
-
|
|
442
|
-
|
|
462
|
+
srvDefinition["@title"] ??
|
|
463
|
+
srvDefinition["@Common.Label"] ??
|
|
464
|
+
srvDefinition["@EndUserText.label"] ??
|
|
443
465
|
`ODM ${appConfig.appName.replace(/[^a-zA-Z0-9]/g, "")} Events`,
|
|
444
|
-
shortDescription: `${
|
|
466
|
+
shortDescription: `${srvDefinition.name} event resource`,
|
|
445
467
|
description:
|
|
446
|
-
|
|
447
|
-
|
|
468
|
+
srvDefinition["@description"] ??
|
|
469
|
+
srvDefinition["@Core.Description"] ??
|
|
448
470
|
"CAP Event resource describing events / messages.",
|
|
449
|
-
version:
|
|
471
|
+
version: version,
|
|
450
472
|
lastUpdate: appConfig.lastUpdate,
|
|
451
473
|
releaseStatus: "active",
|
|
452
474
|
partOfPackage: packageId,
|
|
453
|
-
partOfGroups: [_getGroupID(
|
|
475
|
+
partOfGroups: [_getGroupID(appConfig, srvDefinition)],
|
|
454
476
|
visibility,
|
|
455
477
|
resourceDefinitions: [
|
|
456
|
-
_getResourceDefinition(
|
|
478
|
+
_getResourceDefinition(
|
|
479
|
+
"asyncapi-v2",
|
|
480
|
+
"json",
|
|
481
|
+
ordId,
|
|
482
|
+
srvDefinition.name,
|
|
483
|
+
"asyncapi2.json",
|
|
484
|
+
accessStrategies,
|
|
485
|
+
),
|
|
457
486
|
],
|
|
458
487
|
extensible: { supported: "no" },
|
|
459
|
-
...(entityTypeMappings ? { entityTypeMappings } : {}),
|
|
460
488
|
...(exposedEntityTypes ? { exposedEntityTypes } : []),
|
|
461
489
|
...ordExtensions,
|
|
462
490
|
};
|
|
@@ -473,28 +501,6 @@ function isPrimaryDataProductService(serviceDefinition) {
|
|
|
473
501
|
);
|
|
474
502
|
}
|
|
475
503
|
|
|
476
|
-
function _getEntityTypeMappings(definitionObj) {
|
|
477
|
-
if (!definitionObj.entities) {
|
|
478
|
-
return;
|
|
479
|
-
}
|
|
480
|
-
const entities = Object.values(definitionObj.entities).flatMap((entity) => {
|
|
481
|
-
const entityData = _flattenEntityGraph(entity)
|
|
482
|
-
.flatMap(createEntityTypeMappingsItemTemplate) // now returns arrays
|
|
483
|
-
.filter(Boolean);
|
|
484
|
-
return _.uniqBy(entityData, CONTENT_MERGE_KEY);
|
|
485
|
-
});
|
|
486
|
-
const entityTypeTargets = _.uniqBy(entities, CONTENT_MERGE_KEY)
|
|
487
|
-
.filter((entity) => entity !== undefined)
|
|
488
|
-
.map(({ ordId }) => ({
|
|
489
|
-
ordId,
|
|
490
|
-
}));
|
|
491
|
-
if (entityTypeTargets.length > 0) {
|
|
492
|
-
return [{ entityTypeTargets }];
|
|
493
|
-
} else {
|
|
494
|
-
return;
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
|
|
498
504
|
function _getExposedEntityTypes(definitionObj) {
|
|
499
505
|
if (!definitionObj.entities) {
|
|
500
506
|
return;
|
|
@@ -504,14 +510,13 @@ function _getExposedEntityTypes(definitionObj) {
|
|
|
504
510
|
return _.uniqBy(entityData, CONTENT_MERGE_KEY);
|
|
505
511
|
});
|
|
506
512
|
const exposedEntityTypes = _.uniqBy(entities, CONTENT_MERGE_KEY)
|
|
507
|
-
.filter((entity) => entity
|
|
508
|
-
.map((
|
|
509
|
-
ordId,
|
|
513
|
+
.filter((entity) => !!entity)
|
|
514
|
+
.map((entity) => ({
|
|
515
|
+
ordId: entity.isODMMapping ? entity.ordId : entity[`${ORD_EXTENSIONS_PREFIX}ordId`] || entity.ordId,
|
|
510
516
|
}));
|
|
517
|
+
|
|
511
518
|
if (exposedEntityTypes.length > 0) {
|
|
512
519
|
return exposedEntityTypes;
|
|
513
|
-
} else {
|
|
514
|
-
return;
|
|
515
520
|
}
|
|
516
521
|
}
|
|
517
522
|
|
|
@@ -564,7 +569,6 @@ function _extractVersionFromServiceName(serviceName) {
|
|
|
564
569
|
|
|
565
570
|
return {
|
|
566
571
|
cleanName: serviceName.replace(versionPattern, ""),
|
|
567
|
-
version: `v${versionNumber}`,
|
|
568
572
|
semanticVersion: `${versionNumber}.0.0`,
|
|
569
573
|
};
|
|
570
574
|
}
|
|
@@ -614,7 +618,6 @@ module.exports = {
|
|
|
614
618
|
createEventResourceTemplate,
|
|
615
619
|
readORDExtensions,
|
|
616
620
|
_getPackageID,
|
|
617
|
-
_getEntityTypeMappings,
|
|
618
621
|
_getExposedEntityTypes,
|
|
619
622
|
_propagateORDVisibility,
|
|
620
623
|
_handleVisibility,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cap-js/ord",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "CAP Plugin for generating ORD document.",
|
|
5
5
|
"repository": "cap-js/ord",
|
|
6
6
|
"author": "SAP SE (https://www.sap.com)",
|
|
@@ -25,14 +25,15 @@
|
|
|
25
25
|
"test:integration:mtls": "jest __tests__/integration/mtls-auth.test.js --testPathIgnorePatterns=/node_modules/ --forceExit",
|
|
26
26
|
"test:integration:build": "jest __tests__/integration/cds-build.test.js --testPathIgnorePatterns=/node_modules/ --forceExit",
|
|
27
27
|
"update-snapshot": "jest --ci --updateSnapshot",
|
|
28
|
-
"cds:version": "cds v -i"
|
|
28
|
+
"cds:version": "cds v -i",
|
|
29
|
+
"test:all": "npm run test && npm run test:integration:basic && npm run test:integration:mtls && npm run test:integration:build"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@cap-js/graphql": "^0.14.0",
|
|
32
33
|
"@cap-js/sqlite": "^2",
|
|
33
34
|
"@sap/cds-dk": ">=8.9.5",
|
|
34
35
|
"eslint": "^10.0.0",
|
|
35
|
-
"express": "^
|
|
36
|
+
"express": "^5.0.0",
|
|
36
37
|
"jest": "^30.0.0",
|
|
37
38
|
"prettier": "3.8.3",
|
|
38
39
|
"supertest": "^7.0.0"
|
|
@@ -52,7 +53,7 @@
|
|
|
52
53
|
"node": ">=20 <25"
|
|
53
54
|
},
|
|
54
55
|
"overrides": {
|
|
55
|
-
"@sap/cds-compiler": "6.9.
|
|
56
|
+
"@sap/cds-compiler": "6.9.2"
|
|
56
57
|
},
|
|
57
58
|
"cds": {
|
|
58
59
|
"requires": {
|
package/lib/utils.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if at least one policy level in the array is SAP.
|
|
3
|
-
*
|
|
4
|
-
* @param {string[]} policyLevels - Array of policy levels.
|
|
5
|
-
*/
|
|
6
|
-
function hasSAPPolicyLevel(policyLevels) {
|
|
7
|
-
return policyLevels.some((policyLevel) => policyLevel.split(":")[0].toLowerCase() === "sap");
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
module.exports = {
|
|
11
|
-
hasSAPPolicyLevel,
|
|
12
|
-
};
|