Removed CatalogApi.geLocationByEntity and CatalogApi.getOriginLocationByEntity, and replaced them with CatalogApi.getLocationByRef.
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
@@ -43,16 +43,12 @@ export interface CatalogApi {
|
||||
name: EntityName,
|
||||
options?: CatalogRequestOptions,
|
||||
): Promise<Entity | undefined>;
|
||||
getLocationByEntity(
|
||||
entity: Entity,
|
||||
options?: CatalogRequestOptions,
|
||||
): Promise<Location_2 | undefined>;
|
||||
getLocationById(
|
||||
id: string,
|
||||
options?: CatalogRequestOptions,
|
||||
): Promise<Location_2 | undefined>;
|
||||
getOriginLocationByEntity(
|
||||
entity: Entity,
|
||||
getLocationByRef(
|
||||
locationRef: string,
|
||||
options?: CatalogRequestOptions,
|
||||
): Promise<Location_2 | undefined>;
|
||||
refreshEntity(
|
||||
@@ -95,16 +91,12 @@ export class CatalogClient implements CatalogApi {
|
||||
compoundName: EntityName,
|
||||
options?: CatalogRequestOptions,
|
||||
): Promise<Entity | undefined>;
|
||||
getLocationByEntity(
|
||||
entity: Entity,
|
||||
options?: CatalogRequestOptions,
|
||||
): Promise<Location_2 | undefined>;
|
||||
getLocationById(
|
||||
id: string,
|
||||
options?: CatalogRequestOptions,
|
||||
): Promise<Location_2 | undefined>;
|
||||
getOriginLocationByEntity(
|
||||
entity: Entity,
|
||||
getLocationByRef(
|
||||
locationRef: string,
|
||||
options?: CatalogRequestOptions,
|
||||
): Promise<Location_2 | undefined>;
|
||||
refreshEntity(
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
ANNOTATION_LOCATION,
|
||||
ANNOTATION_ORIGIN_LOCATION,
|
||||
Entity,
|
||||
EntityName,
|
||||
parseEntityRef,
|
||||
@@ -246,17 +244,12 @@ export class CatalogClient implements CatalogApi {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc CatalogApi.getOriginLocationByEntity}
|
||||
* {@inheritdoc CatalogApi.getLocationByRef}
|
||||
*/
|
||||
async getOriginLocationByEntity(
|
||||
entity: Entity,
|
||||
async getLocationByRef(
|
||||
locationRef: string,
|
||||
options?: CatalogRequestOptions,
|
||||
): Promise<Location | undefined> {
|
||||
const locationCompound =
|
||||
entity.metadata.annotations?.[ANNOTATION_ORIGIN_LOCATION];
|
||||
if (!locationCompound) {
|
||||
return undefined;
|
||||
}
|
||||
const all: { data: Location }[] = await this.requestRequired(
|
||||
'GET',
|
||||
'/locations',
|
||||
@@ -264,28 +257,7 @@ export class CatalogClient implements CatalogApi {
|
||||
);
|
||||
return all
|
||||
.map(r => r.data)
|
||||
.find(l => locationCompound === stringifyLocationRef(l));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc CatalogApi.getLocationByEntity}
|
||||
*/
|
||||
async getLocationByEntity(
|
||||
entity: Entity,
|
||||
options?: CatalogRequestOptions,
|
||||
): Promise<Location | undefined> {
|
||||
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));
|
||||
.find(l => locationRef === stringifyLocationRef(l));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -262,24 +262,13 @@ export interface CatalogApi {
|
||||
): Promise<Location | undefined>;
|
||||
|
||||
/**
|
||||
* Gets origin location by Entity.
|
||||
* Gets a registered location by its ref.
|
||||
*
|
||||
* @param entity - An {@link catalog-model#Entity}.
|
||||
* @param locationRef - A location ref, e.g. "url:https://github.com/..."
|
||||
* @param options - Additional options
|
||||
*/
|
||||
getOriginLocationByEntity(
|
||||
entity: Entity,
|
||||
options?: CatalogRequestOptions,
|
||||
): Promise<Location | undefined>;
|
||||
|
||||
/**
|
||||
* Gets Location by Entity.
|
||||
*
|
||||
* @param entity - An {@link catalog-model#Entity}.
|
||||
* @param options - Additional options
|
||||
*/
|
||||
getLocationByEntity(
|
||||
entity: Entity,
|
||||
getLocationByRef(
|
||||
locationRef: string,
|
||||
options?: CatalogRequestOptions,
|
||||
): Promise<Location | undefined>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user