From 7010349c9a427f72ef780f716c9bb036fb4f1c29 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 18 Feb 2022 13:41:28 +0100 Subject: [PATCH] catalog-model: move EntityRelationSpec to catalog-backend Signed-off-by: Patrik Oldsberg --- .changeset/lovely-chairs-confess.md | 5 ++++ .changeset/lovely-falcons-hang.md | 5 ++++ packages/catalog-model/api-report.md | 7 ------ packages/catalog-model/src/entity/Entity.ts | 22 ----------------- packages/catalog-model/src/entity/index.ts | 1 - plugins/catalog-backend/api-report.md | 9 ++++++- plugins/catalog-backend/src/database/types.ts | 4 ++-- .../src/ingestion/processors/results.ts | 7 ++---- .../src/ingestion/processors/types.ts | 7 ++---- .../processing/ProcessorOutputCollector.ts | 3 +-- .../catalog-backend/src/processing/index.ts | 1 + .../catalog-backend/src/processing/types.ts | 24 ++++++++++++++++++- 12 files changed, 49 insertions(+), 46 deletions(-) create mode 100644 .changeset/lovely-chairs-confess.md create mode 100644 .changeset/lovely-falcons-hang.md diff --git a/.changeset/lovely-chairs-confess.md b/.changeset/lovely-chairs-confess.md new file mode 100644 index 0000000000..5c785e89d2 --- /dev/null +++ b/.changeset/lovely-chairs-confess.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend': patch +--- + +Added `EntityRelationSpec`, which was moved over from `@backstage/catalog-model`. diff --git a/.changeset/lovely-falcons-hang.md b/.changeset/lovely-falcons-hang.md new file mode 100644 index 0000000000..5a849f11f5 --- /dev/null +++ b/.changeset/lovely-falcons-hang.md @@ -0,0 +1,5 @@ +--- +'@backstage/catalog-model': minor +--- + +**BREAKING**: Removed `EntityRelationSpec` as it is only used during the catalog during the catalog processing. diff --git a/packages/catalog-model/api-report.md b/packages/catalog-model/api-report.md index 1171d0c0f5..0afe87e709 100644 --- a/packages/catalog-model/api-report.md +++ b/packages/catalog-model/api-report.md @@ -233,13 +233,6 @@ export type EntityRelation = { target: EntityName; }; -// @public -export type EntityRelationSpec = { - source: EntityName; - type: string; - target: EntityName; -}; - // @public export function entitySchemaValidator( schema?: unknown, diff --git a/packages/catalog-model/src/entity/Entity.ts b/packages/catalog-model/src/entity/Entity.ts index f56774025c..7199334e51 100644 --- a/packages/catalog-model/src/entity/Entity.ts +++ b/packages/catalog-model/src/entity/Entity.ts @@ -201,28 +201,6 @@ export type EntityRelation = { target: EntityName; }; -/** - * Holds the relation data for entities. - * - * @public - */ -export type EntityRelationSpec = { - /** - * The source entity of this relation. - */ - source: EntityName; - - /** - * The type of the relation. - */ - type: string; - - /** - * The target entity of this relation. - */ - target: EntityName; -}; - /** * A link to external information that is related to the entity. * diff --git a/packages/catalog-model/src/entity/index.ts b/packages/catalog-model/src/entity/index.ts index 938bdb2b9b..f619d0f39e 100644 --- a/packages/catalog-model/src/entity/index.ts +++ b/packages/catalog-model/src/entity/index.ts @@ -29,7 +29,6 @@ export type { EntityLink, EntityMeta, EntityRelation, - EntityRelationSpec, } from './Entity'; export type { EntityEnvelope } from './EntityEnvelope'; export type { diff --git a/plugins/catalog-backend/api-report.md b/plugins/catalog-backend/api-report.md index f52bbdc22e..116ee2da56 100644 --- a/plugins/catalog-backend/api-report.md +++ b/plugins/catalog-backend/api-report.md @@ -13,8 +13,8 @@ import { Conditions } from '@backstage/plugin-permission-node'; import { Config } from '@backstage/config'; import { DocumentCollator } from '@backstage/search-common'; import { Entity } from '@backstage/catalog-model'; +import { EntityName } from '@backstage/catalog-model'; import { EntityPolicy } from '@backstage/catalog-model'; -import { EntityRelationSpec } from '@backstage/catalog-model'; import express from 'express'; import { GetEntitiesRequest } from '@backstage/catalog-client'; import { GithubCredentialsProvider } from '@backstage/integration'; @@ -737,6 +737,13 @@ export type EntityProviderMutation = removed: DeferredEntity[]; }; +// @public +export type EntityRelationSpec = { + source: EntityName; + type: string; + target: EntityName; +}; + // Warning: (ae-missing-release-tag) "FileReaderProcessor" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) diff --git a/plugins/catalog-backend/src/database/types.ts b/plugins/catalog-backend/src/database/types.ts index ac2ff07498..08201323ea 100644 --- a/plugins/catalog-backend/src/database/types.ts +++ b/plugins/catalog-backend/src/database/types.ts @@ -14,10 +14,10 @@ * limitations under the License. */ -import { Entity, EntityRelationSpec } from '@backstage/catalog-model'; +import { Entity } from '@backstage/catalog-model'; import { JsonObject } from '@backstage/types'; import { DateTime } from 'luxon'; -import { DeferredEntity } from '../processing/types'; +import { DeferredEntity, EntityRelationSpec } from '../processing/types'; /** * An abstraction for transactions of the underlying database technology. diff --git a/plugins/catalog-backend/src/ingestion/processors/results.ts b/plugins/catalog-backend/src/ingestion/processors/results.ts index 5b6f07bae4..3d4f491adc 100644 --- a/plugins/catalog-backend/src/ingestion/processors/results.ts +++ b/plugins/catalog-backend/src/ingestion/processors/results.ts @@ -15,12 +15,9 @@ */ import { InputError, NotFoundError } from '@backstage/errors'; -import { - Entity, - EntityRelationSpec, - LocationSpec, -} from '@backstage/catalog-model'; +import { Entity, LocationSpec } from '@backstage/catalog-model'; import { CatalogProcessorResult } from './types'; +import { EntityRelationSpec } from '../../processing/types'; export function notFoundError( atLocation: LocationSpec, diff --git a/plugins/catalog-backend/src/ingestion/processors/types.ts b/plugins/catalog-backend/src/ingestion/processors/types.ts index b011281d55..2587110e04 100644 --- a/plugins/catalog-backend/src/ingestion/processors/types.ts +++ b/plugins/catalog-backend/src/ingestion/processors/types.ts @@ -14,12 +14,9 @@ * limitations under the License. */ -import { - Entity, - EntityRelationSpec, - LocationSpec, -} from '@backstage/catalog-model'; +import { Entity, LocationSpec } from '@backstage/catalog-model'; import { JsonValue } from '@backstage/types'; +import { EntityRelationSpec } from '../../processing/types'; export type CatalogProcessor = { /** diff --git a/plugins/catalog-backend/src/processing/ProcessorOutputCollector.ts b/plugins/catalog-backend/src/processing/ProcessorOutputCollector.ts index 832c5b41bf..351e68882b 100644 --- a/plugins/catalog-backend/src/processing/ProcessorOutputCollector.ts +++ b/plugins/catalog-backend/src/processing/ProcessorOutputCollector.ts @@ -16,7 +16,6 @@ import { Entity, - EntityRelationSpec, ANNOTATION_LOCATION, ANNOTATION_ORIGIN_LOCATION, stringifyLocationRef, @@ -25,7 +24,7 @@ import { assertError } from '@backstage/errors'; import { Logger } from 'winston'; import { CatalogProcessorResult } from '../ingestion'; import { locationSpecToLocationEntity } from '../util/conversion'; -import { DeferredEntity } from './types'; +import { DeferredEntity, EntityRelationSpec } from './types'; import { getEntityLocationRef, getEntityOriginLocationRef, diff --git a/plugins/catalog-backend/src/processing/index.ts b/plugins/catalog-backend/src/processing/index.ts index dc8b07eceb..83f8a9f566 100644 --- a/plugins/catalog-backend/src/processing/index.ts +++ b/plugins/catalog-backend/src/processing/index.ts @@ -19,6 +19,7 @@ export type { CatalogProcessingEngine, EntityProcessingRequest, EntityProcessingResult, + EntityRelationSpec, DeferredEntity, } from './types'; export { DefaultCatalogProcessingOrchestrator } from './DefaultCatalogProcessingOrchestrator'; diff --git a/plugins/catalog-backend/src/processing/types.ts b/plugins/catalog-backend/src/processing/types.ts index 7fb1157d3b..33d8ed8771 100644 --- a/plugins/catalog-backend/src/processing/types.ts +++ b/plugins/catalog-backend/src/processing/types.ts @@ -14,9 +14,31 @@ * limitations under the License. */ -import { Entity, EntityRelationSpec } from '@backstage/catalog-model'; +import { Entity, EntityName } from '@backstage/catalog-model'; import { JsonObject } from '@backstage/types'; +/** + * Holds the relation data for entities. + * + * @public + */ +export type EntityRelationSpec = { + /** + * The source entity of this relation. + */ + source: EntityName; + + /** + * The type of the relation. + */ + type: string; + + /** + * The target entity of this relation. + */ + target: EntityName; +}; + export type EntityProcessingRequest = { entity: Entity; state?: JsonObject; // Versions for multiple deployments etc