Skip to content

Commit

Permalink
catalog-model: Deprecate EntityRefContext
Browse files Browse the repository at this point in the history
and instead inline type where needed as the type isn't used much.

Signed-off-by: Johan Haals <johan.haals@gmail.com>
  • Loading branch information
jhaals committed Feb 15, 2022
1 parent 1c9891e commit e8c6f9d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/hungry-apples-sparkle.md
@@ -0,0 +1,5 @@
---
'@backstage/catalog-model': patch
---

Deprecates the `EntityRefContext` type which had limited use.
12 changes: 9 additions & 3 deletions packages/catalog-model/api-report.md
Expand Up @@ -70,7 +70,10 @@ export class CommonValidatorFunctions {
export function compareEntityToRef(
entity: Entity,
ref: EntityRef | EntityName,
context?: EntityRefContext,
context?: {
defaultKind?: string;
defaultNamespace?: string;
},
): boolean;

// @public
Expand Down Expand Up @@ -215,7 +218,7 @@ export type EntityRef =
name: string;
};

// @public
// @public @deprecated
export type EntityRefContext = {
defaultKind?: string;
defaultNamespace?: string;
Expand Down Expand Up @@ -388,7 +391,10 @@ export const ORIGIN_LOCATION_ANNOTATION =
// @public
export function parseEntityName(
ref: EntityRef,
context?: EntityRefContext,
context?: {
defaultKind?: string;
defaultNamespace?: string;
},
): EntityName;

// @public
Expand Down
22 changes: 19 additions & 3 deletions packages/catalog-model/src/entity/ref.ts
Expand Up @@ -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 */
Expand All @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e8c6f9d

Please sign in to comment.