@sap-ux/annotation-converter
Advanced tools
Comparing version 0.5.18 to 0.5.19
# @sap-ux/annotation-converter | ||
## 0.5.19 | ||
### Patch Changes | ||
- fe8374c: feat: add support for ActionImport and FunctionImport | ||
## 0.5.18 | ||
@@ -4,0 +10,0 @@ |
@@ -59,2 +59,5 @@ "use strict"; | ||
}); | ||
rawMetadata.schema.actionImports.forEach((actionImport) => { | ||
objectMap[actionImport.fullyQualifiedName] = actionImport; | ||
}); | ||
rawMetadata.schema.complexTypes.forEach((complexType) => { | ||
@@ -490,2 +493,3 @@ objectMap[complexType.fullyQualifiedName] = complexType; | ||
recordDefinition.propertyValues.forEach((propertyValue) => { | ||
var _a, _b; | ||
annotationContent[propertyValue.name] = parseValue(propertyValue.value, `${currentFQN}/${propertyValue.name}`, objectMap, context); | ||
@@ -501,6 +505,9 @@ if (Array.isArray(propertyValue.annotations)) { | ||
if (isDataFieldWithForAction(annotationContent, annotationTerm)) { | ||
annotationContent.ActionTarget = | ||
(context.currentTarget.actions && context.currentTarget.actions[annotationContent.Action]) || | ||
objectMap[annotationContent.Action]; | ||
// try to resolve to a bound action | ||
annotationContent.ActionTarget = (_a = context.currentTarget.actions) === null || _a === void 0 ? void 0 : _a[annotationContent.Action]; | ||
// try to resolve to an unbound action (annotation must point to an ActionImport) | ||
if (!annotationContent.ActionTarget) { | ||
annotationContent.ActionTarget = (_b = objectMap[annotationContent.Action]) === null || _b === void 0 ? void 0 : _b.action; | ||
} | ||
if (!annotationContent.ActionTarget) { | ||
// Add to diagnostics debugger; | ||
@@ -751,3 +758,2 @@ ANNOTATION_ERRORS.push({ | ||
} | ||
sourceEntityType.actions[action.name] = action; | ||
sourceEntityType.actions[`${namespace}.${action.name}`] = action; | ||
@@ -759,2 +765,7 @@ } | ||
} | ||
function linkActionImportsToActions(actionImports, objectMap) { | ||
actionImports.forEach((actionImport) => { | ||
actionImport.action = objectMap[actionImport.actionName]; | ||
}); | ||
} | ||
/** | ||
@@ -1117,2 +1128,3 @@ * @param entitySets | ||
linkActionsToEntityType(rawMetadata.schema.namespace, rawMetadata.schema.actions, objectMap); | ||
linkActionImportsToActions(rawMetadata.schema.actionImports, objectMap); | ||
linkEntityTypeToEntitySet(rawMetadata.schema.entitySets, objectMap, rawMetadata.references); | ||
@@ -1191,2 +1203,3 @@ linkEntityTypeToSingleton(rawMetadata.schema.singletons, objectMap, rawMetadata.references); | ||
actions: rawMetadata.schema.actions, | ||
actionImports: rawMetadata.schema.actionImports, | ||
entitySets: rawMetadata.schema.entitySets, | ||
@@ -1193,0 +1206,0 @@ singletons: rawMetadata.schema.singletons, |
{ | ||
"name": "@sap-ux/annotation-converter", | ||
"version": "0.5.18", | ||
"version": "0.5.19", | ||
"description": "SAP Fiori OData - Annotation converter", | ||
@@ -17,4 +17,4 @@ "repository": { | ||
"devDependencies": { | ||
"@sap-ux/vocabularies-types": "0.6.4", | ||
"@sap-ux/edmx-parser": "0.5.10" | ||
"@sap-ux/vocabularies-types": "0.6.5", | ||
"@sap-ux/edmx-parser": "0.5.11" | ||
}, | ||
@@ -21,0 +21,0 @@ "scripts": { |
@@ -29,3 +29,4 @@ import type { | ||
EntityContainer, | ||
RawAnnotation | ||
RawAnnotation, | ||
ActionImport | ||
} from '@sap-ux/vocabularies-types'; | ||
@@ -97,2 +98,5 @@ import type { ReferencesWithMap } from './utils'; | ||
}); | ||
rawMetadata.schema.actionImports.forEach((actionImport) => { | ||
objectMap[actionImport.fullyQualifiedName] = actionImport; | ||
}); | ||
rawMetadata.schema.complexTypes.forEach((complexType) => { | ||
@@ -599,6 +603,11 @@ objectMap[complexType.fullyQualifiedName] = complexType; | ||
if (isDataFieldWithForAction(annotationContent, annotationTerm)) { | ||
annotationContent.ActionTarget = | ||
(context.currentTarget.actions && context.currentTarget.actions[annotationContent.Action]) || | ||
objectMap[annotationContent.Action]; | ||
// try to resolve to a bound action | ||
annotationContent.ActionTarget = context.currentTarget.actions?.[annotationContent.Action]; | ||
// try to resolve to an unbound action (annotation must point to an ActionImport) | ||
if (!annotationContent.ActionTarget) { | ||
annotationContent.ActionTarget = objectMap[annotationContent.Action]?.action; | ||
} | ||
if (!annotationContent.ActionTarget) { | ||
// Add to diagnostics debugger; | ||
@@ -940,3 +949,2 @@ ANNOTATION_ERRORS.push({ | ||
} | ||
sourceEntityType.actions[action.name] = action; | ||
sourceEntityType.actions[`${namespace}.${action.name}`] = action; | ||
@@ -949,2 +957,8 @@ } | ||
function linkActionImportsToActions(actionImports: ActionImport[], objectMap: Record<string, any>): void { | ||
actionImports.forEach((actionImport) => { | ||
actionImport.action = objectMap[actionImport.actionName]; | ||
}); | ||
} | ||
/** | ||
@@ -1383,2 +1397,3 @@ * @param entitySets | ||
linkActionsToEntityType(rawMetadata.schema.namespace, rawMetadata.schema.actions as Action[], objectMap); | ||
linkActionImportsToActions(rawMetadata.schema.actionImports, objectMap); | ||
linkEntityTypeToEntitySet(rawMetadata.schema.entitySets as EntitySet[], objectMap, rawMetadata.references); | ||
@@ -1456,2 +1471,3 @@ linkEntityTypeToSingleton(rawMetadata.schema.singletons as Singleton[], objectMap, rawMetadata.references); | ||
actions: rawMetadata.schema.actions as Action[], | ||
actionImports: rawMetadata.schema.actionImports, | ||
entitySets: rawMetadata.schema.entitySets as EntitySet[], | ||
@@ -1458,0 +1474,0 @@ singletons: rawMetadata.schema.singletons as Singleton[], |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
278795
4184