diff --git a/packages/catalog-client/api-report.md b/packages/catalog-client/api-report.md index 7427bdd235..56ba4a834f 100644 --- a/packages/catalog-client/api-report.md +++ b/packages/catalog-client/api-report.md @@ -91,6 +91,11 @@ export class CatalogClient implements CatalogApi { compoundName: EntityName, options?: CatalogRequestOptions, ): Promise; + // @deprecated (undocumented) + getLocationByEntity( + entity: Entity, + options?: CatalogRequestOptions, + ): Promise; getLocationById( id: string, options?: CatalogRequestOptions, @@ -99,6 +104,11 @@ export class CatalogClient implements CatalogApi { locationRef: string, options?: CatalogRequestOptions, ): Promise; + // @deprecated (undocumented) + getOriginLocationByEntity( + entity: Entity, + options?: CatalogRequestOptions, + ): Promise; refreshEntity( entityRef: string, options?: CatalogRequestOptions, diff --git a/packages/catalog-client/src/CatalogClient.ts b/packages/catalog-client/src/CatalogClient.ts index 84d5d02232..583f5a85bd 100644 --- a/packages/catalog-client/src/CatalogClient.ts +++ b/packages/catalog-client/src/CatalogClient.ts @@ -15,6 +15,8 @@ */ import { + ANNOTATION_LOCATION, + ANNOTATION_ORIGIN_LOCATION, Entity, EntityName, parseEntityRef, @@ -243,6 +245,49 @@ export class CatalogClient implements CatalogApi { }; } + /** + * @deprecated please use getLocationByRef instead + */ + async getOriginLocationByEntity( + entity: Entity, + options?: CatalogRequestOptions, + ): Promise { + const locationCompound = + entity.metadata.annotations?.[ANNOTATION_ORIGIN_LOCATION]; + if (!locationCompound) { + return undefined; + } + const all: { data: Location }[] = await this.requestRequired( + 'GET', + '/locations', + options, + ); + return all + .map(r => r.data) + .find(l => locationCompound === stringifyLocationRef(l)); + } + + /** + * @deprecated please use getLocationByRef instead + */ + async getLocationByEntity( + entity: Entity, + options?: CatalogRequestOptions, + ): Promise { + const locationCompound = entity.metadata.annotations?.[ANNOTATION_LOCATION]; + if (!locationCompound) { + return undefined; + } + const all: { data: Location }[] = await this.requestRequired( + 'GET', + '/locations', + options, + ); + return all + .map(r => r.data) + .find(l => locationCompound === stringifyLocationRef(l)); + } + /** * {@inheritdoc CatalogApi.getLocationByRef} */