Skip to content

Commit

Permalink
catalog-client: api cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
  • Loading branch information
freben committed Feb 11, 2022
1 parent 66494da commit 8eda0e7
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
9 changes: 9 additions & 0 deletions .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.
19 changes: 8 additions & 11 deletions packages/catalog-client/api-report.md
Expand Up @@ -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<string>;
};
fetchApi?: {
fetch: typeof fetch;
};
});
addLocation(
{ type, target, dryRun, presence }: AddLocationRequest,
options?: CatalogRequestOptions,
Expand Down Expand Up @@ -150,17 +157,7 @@ export type CatalogRequestOptions = {
token?: string;
};

// @public
export type DiscoveryApi = {
getBaseUrl(pluginId: string): Promise<string>;
};

// @public
export const ENTITY_STATUS_CATALOG_PROCESSING_TYPE =
'backstage.io/catalog-processing';

// @public
export type FetchApi = {
fetch: typeof fetch;
};
```
5 changes: 4 additions & 1 deletion packages/catalog-client/src/CatalogClient.ts
Expand Up @@ -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<string> };
fetchApi?: { fetch: typeof fetch };
}) {
this.discoveryApi = options.discoveryApi;
this.fetchApi = options.fetchApi || { fetch: crossFetch };
}
Expand Down
5 changes: 4 additions & 1 deletion packages/catalog-client/src/types/api.ts
Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions packages/catalog-client/src/types/index.ts
Expand Up @@ -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';

0 comments on commit 8eda0e7

Please sign in to comment.