feat: throw error if extensions point tries to set data parser multiple times
Signed-off-by: secustor <sebastian@poxhofer.at>
This commit is contained in:
@@ -42,7 +42,7 @@ class CatalogProcessingExtensionPointImpl
|
||||
#processors = new Array<CatalogProcessor>();
|
||||
#entityProviders = new Array<EntityProvider>();
|
||||
#placeholderResolvers: Record<string, PlaceholderResolver> = {};
|
||||
entityDataParser: CatalogProcessorParser = defaultEntityDataParser;
|
||||
entityDataParser?: CatalogProcessorParser;
|
||||
|
||||
addProcessor(
|
||||
...processors: Array<CatalogProcessor | Array<CatalogProcessor>>
|
||||
@@ -65,6 +65,11 @@ class CatalogProcessingExtensionPointImpl
|
||||
}
|
||||
|
||||
setEntityDataParser(parser: CatalogProcessorParser): void {
|
||||
if (this.entityDataParser) {
|
||||
throw new Error(
|
||||
'Attempted to install second EntityDataParser. Only one can be set.',
|
||||
);
|
||||
}
|
||||
this.entityDataParser = parser;
|
||||
}
|
||||
|
||||
@@ -171,7 +176,9 @@ export const catalogPlugin = createBackendPlugin({
|
||||
});
|
||||
builder.addProcessor(...processingExtensions.processors);
|
||||
builder.addEntityProvider(...processingExtensions.entityProviders);
|
||||
builder.setEntityDataParser(processingExtensions.entityDataParser);
|
||||
builder.setEntityDataParser(
|
||||
processingExtensions.entityDataParser ?? defaultEntityDataParser,
|
||||
);
|
||||
|
||||
Object.entries(processingExtensions.placeholderResolvers).forEach(
|
||||
([key, resolver]) => builder.setPlaceholderResolver(key, resolver),
|
||||
|
||||
Reference in New Issue
Block a user