Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sap-ux/annotation-converter

Package Overview
Dependencies
Maintainers
3
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sap-ux/annotation-converter - npm Package Compare versions

Comparing version 0.6.13 to 0.6.14

6

CHANGELOG.md
# @sap-ux/annotation-converter
## 0.6.14
### Patch Changes
- 1fc2286: The annotation converter now ensures that references (aliases and namespaces) are unique
## 0.6.13

@@ -4,0 +10,0 @@

31

dist/converter.js

@@ -1018,2 +1018,27 @@ "use strict";

}
function getReferences(converter, rawMetadataReferences) {
if (rawMetadataReferences.length === 0) {
return VocabularyReferences_1.VocabularyReferences;
}
const references = [];
const duplicates = new Set();
const collides = (a, b) => a.namespace === b.namespace || a.alias === b.alias;
// process the raw references, making sure they are unique (first one wins)
for (const reference of rawMetadataReferences) {
const collisions = references.filter((existingReference) => collides(existingReference, reference));
if (collisions.length > 0) {
collisions.forEach((reference) => duplicates.add(reference));
duplicates.add(reference);
}
else {
references.push(reference);
}
}
// add default vocabulary references (if not there already). Do not report conflicts as errors.
references.push(...VocabularyReferences_1.VocabularyReferences.filter((reference) => references.every((existingReference) => !collides(existingReference, reference))));
if (duplicates.size > 0) {
converter.logError(`The following references are not unique. Check if they are imported multiple times.\n${JSON.stringify(Array.from(duplicates), null, 2)}`);
}
return references;
}
/**

@@ -1031,11 +1056,7 @@ * Convert a RawMetadata into an object representation to be used to easily navigate a metadata object and its annotation.

annotations: rawMetadata.schema.annotations,
references: VocabularyReferences_1.VocabularyReferences.concat(rawMetadata.references),
diagnostics: []
};
// fall back on the default references if the caller does not specify any
if (rawMetadata.references.length === 0) {
rawMetadata.references = VocabularyReferences_1.VocabularyReferences;
}
// Converter
const converter = new Converter(rawMetadata, convertedOutput);
(0, utils_1.lazy)(convertedOutput, 'references', () => getReferences(converter, rawMetadata.references));
(0, utils_1.lazy)(convertedOutput, 'entityContainer', converter.convert(converter.rawSchema.entityContainer, convertEntityContainer));

@@ -1042,0 +1063,0 @@ (0, utils_1.lazy)(convertedOutput, 'entitySets', converter.convert(converter.rawSchema.entitySets, convertEntitySet));

4

package.json
{
"name": "@sap-ux/annotation-converter",
"version": "0.6.13",
"version": "0.6.14",
"description": "SAP Fiori OData - Annotation converter",

@@ -20,3 +20,3 @@ "repository": {

"devDependencies": {
"@sap-ux/edmx-parser": "0.5.14"
"@sap-ux/edmx-parser": "0.5.15"
},

@@ -23,0 +23,0 @@ "scripts": {

@@ -36,2 +36,3 @@ import type {

RawV4NavigationProperty,
Reference,
RemoveAnnotationAndType,

@@ -1545,2 +1546,44 @@ ResolutionTarget,

function getReferences(converter: Converter, rawMetadataReferences: Reference[]) {
if (rawMetadataReferences.length === 0) {
return VocabularyReferences;
}
const references: Reference[] = [];
const duplicates = new Set<Reference>();
const collides = (a: Reference, b: Reference) => a.namespace === b.namespace || a.alias === b.alias;
// process the raw references, making sure they are unique (first one wins)
for (const reference of rawMetadataReferences) {
const collisions = references.filter((existingReference) => collides(existingReference, reference));
if (collisions.length > 0) {
collisions.forEach((reference) => duplicates.add(reference));
duplicates.add(reference);
} else {
references.push(reference);
}
}
// add default vocabulary references (if not there already). Do not report conflicts as errors.
references.push(
...VocabularyReferences.filter((reference) =>
references.every((existingReference) => !collides(existingReference, reference))
)
);
if (duplicates.size > 0) {
converter.logError(
`The following references are not unique. Check if they are imported multiple times.\n${JSON.stringify(
Array.from(duplicates),
null,
2
)}`
);
}
return references;
}
/**

@@ -1558,14 +1601,10 @@ * Convert a RawMetadata into an object representation to be used to easily navigate a metadata object and its annotation.

annotations: rawMetadata.schema.annotations,
references: VocabularyReferences.concat(rawMetadata.references),
diagnostics: []
} as any;
// fall back on the default references if the caller does not specify any
if (rawMetadata.references.length === 0) {
rawMetadata.references = VocabularyReferences;
}
// Converter
const converter = new Converter(rawMetadata, convertedOutput);
lazy(convertedOutput, 'references', () => getReferences(converter, rawMetadata.references));
lazy(

@@ -1572,0 +1611,0 @@ convertedOutput,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc