From 8eda0e7a9c1033ddeb703479a1153d5d5ef950b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Fri, 11 Feb 2022 14:08:44 +0100 Subject: [PATCH] catalog-client: api cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/honest-shrimps-clap.md | 9 +++++++++ packages/catalog-client/api-report.md | 19 ++++++++----------- packages/catalog-client/src/CatalogClient.ts | 5 ++++- packages/catalog-client/src/types/api.ts | 5 ++++- packages/catalog-client/src/types/index.ts | 2 -- 5 files changed, 25 insertions(+), 15 deletions(-) create mode 100644 .changeset/honest-shrimps-clap.md diff --git a/.changeset/honest-shrimps-clap.md b/.changeset/honest-shrimps-clap.md new file mode 100644 index 0000000000000..12ae6237045d4 --- /dev/null +++ b/.changeset/honest-shrimps-clap.md @@ -0,0 +1,9 @@ +--- +'@backstage/catalog-client': minor +--- + +**BREAKING**: Removed the explicit `DiscoveryApi` and `FetchApi` export symbols, +which were unnecessary duplicates from the well known core ones. + +The `CATALOG_FILTER_EXISTS` symbol's value has changed. However, this should not +affect any code in practice. diff --git a/packages/catalog-client/api-report.md b/packages/catalog-client/api-report.md index 13b2e6b5f0cb4..a489b321791fd 100644 --- a/packages/catalog-client/api-report.md +++ b/packages/catalog-client/api-report.md @@ -71,7 +71,14 @@ export interface CatalogApi { // @public export class CatalogClient implements CatalogApi { - constructor(options: { discoveryApi: DiscoveryApi; fetchApi?: FetchApi }); + constructor(options: { + discoveryApi: { + getBaseUrl(pluginId: string): Promise; + }; + fetchApi?: { + fetch: typeof fetch; + }; + }); addLocation( { type, target, dryRun, presence }: AddLocationRequest, options?: CatalogRequestOptions, @@ -150,17 +157,7 @@ export type CatalogRequestOptions = { token?: string; }; -// @public -export type DiscoveryApi = { - getBaseUrl(pluginId: string): Promise; -}; - // @public export const ENTITY_STATUS_CATALOG_PROCESSING_TYPE = 'backstage.io/catalog-processing'; - -// @public -export type FetchApi = { - fetch: typeof fetch; -}; ``` diff --git a/packages/catalog-client/src/CatalogClient.ts b/packages/catalog-client/src/CatalogClient.ts index a446d249c0f22..009bc9a6cb793 100644 --- a/packages/catalog-client/src/CatalogClient.ts +++ b/packages/catalog-client/src/CatalogClient.ts @@ -49,7 +49,10 @@ export class CatalogClient implements CatalogApi { private readonly discoveryApi: DiscoveryApi; private readonly fetchApi: FetchApi; - constructor(options: { discoveryApi: DiscoveryApi; fetchApi?: FetchApi }) { + constructor(options: { + discoveryApi: { getBaseUrl(pluginId: string): Promise }; + fetchApi?: { fetch: typeof fetch }; + }) { this.discoveryApi = options.discoveryApi; this.fetchApi = options.fetchApi || { fetch: crossFetch }; } diff --git a/packages/catalog-client/src/types/api.ts b/packages/catalog-client/src/types/api.ts index 0622d654fa925..2177c41aa2e85 100644 --- a/packages/catalog-client/src/types/api.ts +++ b/packages/catalog-client/src/types/api.ts @@ -21,7 +21,10 @@ import { Entity, EntityName, Location } from '@backstage/catalog-model'; * * @public */ -export const CATALOG_FILTER_EXISTS = Symbol('CATALOG_FILTER_EXISTS'); +export const CATALOG_FILTER_EXISTS = Symbol.for( + // Random UUID to ensure no collisions + 'CATALOG_FILTER_EXISTS_0e15b590c0b343a2bae3e787e84c2111', +); /** * A request type for retrieving catalog Entities. diff --git a/packages/catalog-client/src/types/index.ts b/packages/catalog-client/src/types/index.ts index f3c6fab4e9cc9..cb6166c6d54d7 100644 --- a/packages/catalog-client/src/types/index.ts +++ b/packages/catalog-client/src/types/index.ts @@ -24,7 +24,5 @@ export type { CatalogEntityAncestorsRequest, CatalogEntityAncestorsResponse, } from './api'; -export type { DiscoveryApi } from './discovery'; -export type { FetchApi } from './fetch'; export { CATALOG_FILTER_EXISTS } from './api'; export { ENTITY_STATUS_CATALOG_PROCESSING_TYPE } from './status';