From e8c6f9d282d1f5e46eac553b7c6f2d0d3c99c184 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Tue, 15 Feb 2022 10:42:22 +0100 Subject: [PATCH] catalog-model: Deprecate EntityRefContext and instead inline type where needed as the type isn't used much. Signed-off-by: Johan Haals --- .changeset/hungry-apples-sparkle.md | 5 +++++ packages/catalog-model/api-report.md | 12 +++++++++--- packages/catalog-model/src/entity/ref.ts | 22 +++++++++++++++++++--- 3 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 .changeset/hungry-apples-sparkle.md diff --git a/.changeset/hungry-apples-sparkle.md b/.changeset/hungry-apples-sparkle.md new file mode 100644 index 0000000000..aa098abbe8 --- /dev/null +++ b/.changeset/hungry-apples-sparkle.md @@ -0,0 +1,5 @@ +--- +'@backstage/catalog-model': patch +--- + +Deprecates the `EntityRefContext` type which had limited use. diff --git a/packages/catalog-model/api-report.md b/packages/catalog-model/api-report.md index 655d01fef1..65c52d1af0 100644 --- a/packages/catalog-model/api-report.md +++ b/packages/catalog-model/api-report.md @@ -70,7 +70,10 @@ export class CommonValidatorFunctions { export function compareEntityToRef( entity: Entity, ref: EntityRef | EntityName, - context?: EntityRefContext, + context?: { + defaultKind?: string; + defaultNamespace?: string; + }, ): boolean; // @public @@ -215,7 +218,7 @@ export type EntityRef = name: string; }; -// @public +// @public @deprecated export type EntityRefContext = { defaultKind?: string; defaultNamespace?: string; @@ -388,7 +391,10 @@ export const ORIGIN_LOCATION_ANNOTATION = // @public export function parseEntityName( ref: EntityRef, - context?: EntityRefContext, + context?: { + defaultKind?: string; + defaultNamespace?: string; + }, ): EntityName; // @public diff --git a/packages/catalog-model/src/entity/ref.ts b/packages/catalog-model/src/entity/ref.ts index 1996616077..0cc1c21f90 100644 --- a/packages/catalog-model/src/entity/ref.ts +++ b/packages/catalog-model/src/entity/ref.ts @@ -57,6 +57,7 @@ export function getEntityName(entity: Entity): EntityName { * The context of defaults that entity reference parsing happens within. * * @public + * @deprecated type inlined, will be removed in a future release. */ export type EntityRefContext = { /** The default kind, if none is given in the reference */ @@ -82,7 +83,12 @@ export type EntityRefContext = { */ export function parseEntityName( ref: EntityRef, - context: EntityRefContext = {}, + context: { + /** The default kind, if none is given in the reference */ + defaultKind?: string; + /** The default namespace, if none is given in the reference */ + defaultNamespace?: string; + } = {}, ): EntityName { const { kind, namespace, name } = parseEntityRef(ref, { defaultNamespace: ENTITY_DEFAULT_NAMESPACE, @@ -149,7 +155,12 @@ export function parseEntityRef( */ export function parseEntityRef( ref: EntityRef, - context: EntityRefContext = {}, + context: { + /** The default kind, if none is given in the reference */ + defaultKind?: string; + /** The default namespace, if none is given in the reference */ + defaultNamespace?: string; + } = {}, ): { kind?: string; namespace?: string; @@ -238,7 +249,12 @@ export function stringifyEntityRef( export function compareEntityToRef( entity: Entity, ref: EntityRef | EntityName, - context?: EntityRefContext, + context?: { + /** The default kind, if none is given in the reference */ + defaultKind?: string; + /** The default namespace, if none is given in the reference */ + defaultNamespace?: string; + }, ): boolean { const entityKind = entity.kind; const entityNamespace = entity.metadata.namespace || ENTITY_DEFAULT_NAMESPACE;