feat: move custom data parser to CatalogModel extension point
Signed-off-by: secustor <sebastian@poxhofer.at>
This commit is contained in:
@@ -3,4 +3,4 @@
|
||||
'@backstage/plugin-catalog-node': minor
|
||||
---
|
||||
|
||||
Allow setting EntityDataParser using CatalogProcessingExtensionPoint
|
||||
Allow setting EntityDataParser using CatalogModelExtensionPoint
|
||||
|
||||
@@ -49,7 +49,6 @@ class CatalogProcessingExtensionPointImpl
|
||||
unprocessedEntity: Entity;
|
||||
errors: Error[];
|
||||
}) => Promise<void> | void;
|
||||
#entityDataParser?: CatalogProcessorParser;
|
||||
|
||||
addProcessor(
|
||||
...processors: Array<CatalogProcessor | Array<CatalogProcessor>>
|
||||
@@ -80,15 +79,6 @@ class CatalogProcessingExtensionPointImpl
|
||||
this.#onProcessingErrorHandler = handler;
|
||||
}
|
||||
|
||||
setEntityDataParser(parser: CatalogProcessorParser): void {
|
||||
if (this.#entityDataParser) {
|
||||
throw new Error(
|
||||
'Attempted to install second EntityDataParser. Only one can be set.',
|
||||
);
|
||||
}
|
||||
this.#entityDataParser = parser;
|
||||
}
|
||||
|
||||
get processors() {
|
||||
return this.#processors;
|
||||
}
|
||||
@@ -104,10 +94,6 @@ class CatalogProcessingExtensionPointImpl
|
||||
get onProcessingErrorHandler() {
|
||||
return this.#onProcessingErrorHandler;
|
||||
}
|
||||
|
||||
get entityDataParser() {
|
||||
return this.#entityDataParser;
|
||||
}
|
||||
}
|
||||
|
||||
class CatalogAnalysisExtensionPointImpl
|
||||
@@ -152,6 +138,21 @@ class CatalogModelExtensionPointImpl implements CatalogModelExtensionPoint {
|
||||
get fieldValidators() {
|
||||
return this.#fieldValidators;
|
||||
}
|
||||
|
||||
#entityDataParser?: CatalogProcessorParser;
|
||||
|
||||
setEntityDataParser(parser: CatalogProcessorParser): void {
|
||||
if (this.#entityDataParser) {
|
||||
throw new Error(
|
||||
'Attempted to install second EntityDataParser. Only one can be set.',
|
||||
);
|
||||
}
|
||||
this.#entityDataParser = parser;
|
||||
}
|
||||
|
||||
get entityDataParser() {
|
||||
return this.#entityDataParser;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -221,8 +222,8 @@ export const catalogPlugin = createBackendPlugin({
|
||||
builder.addProcessor(...processingExtensions.processors);
|
||||
builder.addEntityProvider(...processingExtensions.entityProviders);
|
||||
|
||||
if (processingExtensions.entityDataParser) {
|
||||
builder.setEntityDataParser(processingExtensions.entityDataParser);
|
||||
if (modelExtensions.entityDataParser) {
|
||||
builder.setEntityDataParser(modelExtensions.entityDataParser);
|
||||
}
|
||||
|
||||
Object.entries(processingExtensions.placeholderResolvers).forEach(
|
||||
|
||||
Generated
+1
-2
@@ -28,6 +28,7 @@ export const catalogAnalysisExtensionPoint: ExtensionPoint<CatalogAnalysisExtens
|
||||
|
||||
// @alpha (undocumented)
|
||||
export interface CatalogModelExtensionPoint {
|
||||
setEntityDataParser(parser: CatalogProcessorParser): void;
|
||||
setFieldValidators(validators: Partial<Validators>): void;
|
||||
}
|
||||
|
||||
@@ -71,8 +72,6 @@ export interface CatalogProcessingExtensionPoint {
|
||||
errors: Error[];
|
||||
}) => Promise<void> | void,
|
||||
): void;
|
||||
// (undocumented)
|
||||
setEntityDataParser(parser: CatalogProcessorParser): void;
|
||||
}
|
||||
|
||||
// @alpha (undocumented)
|
||||
|
||||
@@ -38,7 +38,6 @@ export interface CatalogProcessingExtensionPoint {
|
||||
...providers: Array<EntityProvider | Array<EntityProvider>>
|
||||
): void;
|
||||
addPlaceholderResolver(key: string, resolver: PlaceholderResolver): void;
|
||||
setEntityDataParser(parser: CatalogProcessorParser): void;
|
||||
setOnProcessingErrorHandler(
|
||||
handler: (event: {
|
||||
unprocessedEntity: Entity;
|
||||
@@ -57,6 +56,12 @@ export interface CatalogModelExtensionPoint {
|
||||
* @param validators - The (subset of) validators to set
|
||||
*/
|
||||
setFieldValidators(validators: Partial<Validators>): void;
|
||||
|
||||
/**
|
||||
* Sets the entity data parser which is used to read raw data from locations
|
||||
* @param parser - Parser which will used to extract entities from raw data
|
||||
*/
|
||||
setEntityDataParser(parser: CatalogProcessorParser): void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user