diff --git a/.changeset/evil-forks-hang.md b/.changeset/evil-forks-hang.md new file mode 100644 index 0000000000..8258c904b9 --- /dev/null +++ b/.changeset/evil-forks-hang.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-react': minor +--- + +Added the analyzeLocation method to catalogApiMock diff --git a/.changeset/long-grapes-glow.md b/.changeset/long-grapes-glow.md new file mode 100644 index 0000000000..e0e805ed87 --- /dev/null +++ b/.changeset/long-grapes-glow.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-node': minor +--- + +Added the analyze-location endpoint to the CatalogService diff --git a/packages/catalog-client/report-testUtils.api.md b/packages/catalog-client/report-testUtils.api.md index bb6a8dd469..f5bcf55c53 100644 --- a/packages/catalog-client/report-testUtils.api.md +++ b/packages/catalog-client/report-testUtils.api.md @@ -5,6 +5,8 @@ ```ts import { AddLocationRequest } from '@backstage/catalog-client'; import { AddLocationResponse } from '@backstage/catalog-client'; +import type { AnalyzeLocationRequest } from '@backstage/plugin-catalog-common'; +import type { AnalyzeLocationResponse } from '@backstage/plugin-catalog-common'; import { CatalogApi } from '@backstage/catalog-client'; import { CompoundEntityRef } from '@backstage/catalog-model'; import { Entity } from '@backstage/catalog-model'; @@ -28,6 +30,10 @@ export class InMemoryCatalogClient implements CatalogApi { // (undocumented) addLocation(_location: AddLocationRequest): Promise; // (undocumented) + analyzeLocation( + _location: AnalyzeLocationRequest, + ): Promise; + // (undocumented) getEntities(request?: GetEntitiesRequest): Promise; // (undocumented) getEntitiesByRefs( diff --git a/packages/catalog-client/report.api.md b/packages/catalog-client/report.api.md index 0a37ed7e42..ebb0f5ac97 100644 --- a/packages/catalog-client/report.api.md +++ b/packages/catalog-client/report.api.md @@ -3,6 +3,8 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts +import type { AnalyzeLocationRequest } from '@backstage/plugin-catalog-common'; +import type { AnalyzeLocationResponse } from '@backstage/plugin-catalog-common'; import { CompoundEntityRef } from '@backstage/catalog-model'; import { Entity } from '@backstage/catalog-model'; import { SerializedError } from '@backstage/errors'; @@ -30,6 +32,10 @@ export interface CatalogApi { location: AddLocationRequest, options?: CatalogRequestOptions, ): Promise; + analyzeLocation( + location: AnalyzeLocationRequest, + options?: CatalogRequestOptions, + ): Promise; getEntities( request?: GetEntitiesRequest, options?: CatalogRequestOptions, @@ -103,6 +109,10 @@ export class CatalogClient implements CatalogApi { request: AddLocationRequest, options?: CatalogRequestOptions, ): Promise; + analyzeLocation( + request: AnalyzeLocationRequest, + options?: CatalogRequestOptions, + ): Promise; getEntities( request?: GetEntitiesRequest, options?: CatalogRequestOptions, diff --git a/packages/catalog-client/src/testUtils/InMemoryCatalogClient.ts b/packages/catalog-client/src/testUtils/InMemoryCatalogClient.ts index 746871a1b3..97663de922 100644 --- a/packages/catalog-client/src/testUtils/InMemoryCatalogClient.ts +++ b/packages/catalog-client/src/testUtils/InMemoryCatalogClient.ts @@ -44,6 +44,10 @@ import { import { NotFoundError, NotImplementedError } from '@backstage/errors'; // eslint-disable-next-line @backstage/no-relative-monorepo-imports import { traverse } from '../../../../plugins/catalog-backend/src/database/operations/stitcher/buildEntitySearch'; +import type { + AnalyzeLocationRequest, + AnalyzeLocationResponse, +} from '@backstage/plugin-catalog-common'; function buildEntitySearch(entity: Entity) { const rows = traverse(entity); @@ -269,6 +273,12 @@ export class InMemoryCatalogClient implements CatalogApi { throw new NotImplementedError('Method not implemented.'); } + async analyzeLocation( + _location: AnalyzeLocationRequest, + ): Promise { + throw new NotImplementedError('Method not implemented.'); + } + #createEntityRefMap() { return new Map(this.#entities.map(e => [stringifyEntityRef(e), e])); } diff --git a/plugins/catalog-node/report-testUtils.api.md b/plugins/catalog-node/report-testUtils.api.md index 3098888fcb..3fa7057a99 100644 --- a/plugins/catalog-node/report-testUtils.api.md +++ b/plugins/catalog-node/report-testUtils.api.md @@ -5,6 +5,8 @@ ```ts import { AddLocationRequest } from '@backstage/catalog-client'; import { AddLocationResponse } from '@backstage/catalog-client'; +import { AnalyzeLocationRequest } from '@backstage/plugin-catalog-common'; +import { AnalyzeLocationResponse } from '@backstage/plugin-catalog-common'; import { CatalogApi } from '@backstage/catalog-client'; import { CatalogRequestOptions } from '@backstage/catalog-client'; import { CatalogService } from '@backstage/plugin-catalog-node'; @@ -35,6 +37,11 @@ export interface CatalogServiceMock extends CatalogService, CatalogApi { options?: CatalogServiceRequestOptions | CatalogRequestOptions, ): Promise; // (undocumented) + analyzeLocation( + location: AnalyzeLocationRequest, + options?: CatalogServiceRequestOptions | CatalogRequestOptions, + ): Promise; + // (undocumented) getEntities( request?: GetEntitiesRequest, options?: CatalogServiceRequestOptions | CatalogRequestOptions, diff --git a/plugins/catalog-node/report.api.md b/plugins/catalog-node/report.api.md index 807bcaa8d5..debafad5c4 100644 --- a/plugins/catalog-node/report.api.md +++ b/plugins/catalog-node/report.api.md @@ -125,6 +125,11 @@ export interface CatalogService { options: CatalogServiceRequestOptions, ): Promise; // (undocumented) + analyzeLocation( + location: AnalyzeLocationRequest, + options: CatalogServiceRequestOptions, + ): Promise; + // (undocumented) getEntities( request: GetEntitiesRequest | undefined, options: CatalogServiceRequestOptions, diff --git a/plugins/catalog-node/src/catalogService.ts b/plugins/catalog-node/src/catalogService.ts index 51bb1d92e5..9478c6b48a 100644 --- a/plugins/catalog-node/src/catalogService.ts +++ b/plugins/catalog-node/src/catalogService.ts @@ -42,6 +42,10 @@ import { ValidateEntityResponse, } from '@backstage/catalog-client'; import { CompoundEntityRef, Entity } from '@backstage/catalog-model'; +import { + AnalyzeLocationRequest, + AnalyzeLocationResponse, +} from '@backstage/plugin-catalog-common'; /** * @public @@ -132,6 +136,11 @@ export interface CatalogService { locationRef: string, options: CatalogServiceRequestOptions, ): Promise; + + analyzeLocation( + location: AnalyzeLocationRequest, + options: CatalogServiceRequestOptions, + ): Promise; } class DefaultCatalogService implements CatalogService { @@ -301,6 +310,16 @@ class DefaultCatalogService implements CatalogService { ); } + async analyzeLocation( + location: AnalyzeLocationRequest, + options: CatalogServiceRequestOptions, + ): Promise { + return this.#catalogApi.analyzeLocation( + location, + await this.#getOptions(options), + ); + } + async #getOptions( options: CatalogServiceRequestOptions, ): Promise { diff --git a/plugins/catalog-node/src/testUtils/catalogServiceMock.ts b/plugins/catalog-node/src/testUtils/catalogServiceMock.ts index ec469fc927..20e04e12b4 100644 --- a/plugins/catalog-node/src/testUtils/catalogServiceMock.ts +++ b/plugins/catalog-node/src/testUtils/catalogServiceMock.ts @@ -102,5 +102,6 @@ export namespace catalogServiceMock { removeLocationById: jest.fn(), getLocationByEntity: jest.fn(), validateEntity: jest.fn(), + analyzeLocation: jest.fn(), })); } diff --git a/plugins/catalog-node/src/testUtils/types.ts b/plugins/catalog-node/src/testUtils/types.ts index 6e6331a630..96380e9434 100644 --- a/plugins/catalog-node/src/testUtils/types.ts +++ b/plugins/catalog-node/src/testUtils/types.ts @@ -34,6 +34,10 @@ import { ValidateEntityResponse, } from '@backstage/catalog-client'; import { CompoundEntityRef, Entity } from '@backstage/catalog-model'; +import { + AnalyzeLocationRequest, + AnalyzeLocationResponse, +} from '@backstage/plugin-catalog-common'; import { CatalogService, CatalogServiceRequestOptions, @@ -126,4 +130,9 @@ export interface CatalogServiceMock extends CatalogService, CatalogApi { locationRef: string, options?: CatalogServiceRequestOptions | CatalogRequestOptions, ): Promise; + + analyzeLocation( + location: AnalyzeLocationRequest, + options?: CatalogServiceRequestOptions | CatalogRequestOptions, + ): Promise; } diff --git a/plugins/catalog-react/src/testUtils/catalogApiMock.ts b/plugins/catalog-react/src/testUtils/catalogApiMock.ts index 08520e2a9b..42c6b1004f 100644 --- a/plugins/catalog-react/src/testUtils/catalogApiMock.ts +++ b/plugins/catalog-react/src/testUtils/catalogApiMock.ts @@ -101,5 +101,6 @@ export namespace catalogApiMock { removeLocationById: jest.fn(), getLocationByEntity: jest.fn(), validateEntity: jest.fn(), + analyzeLocation: jest.fn(), })); }