@@ -92,11 +92,14 @@ export class CatalogClient implements CatalogApi {
|
||||
* {@inheritdoc CatalogApi.getLocationByEntity}
|
||||
*/
|
||||
async getLocationByEntity(
|
||||
entityRef: CompoundEntityRef,
|
||||
entityRef: CompoundEntityRef | string,
|
||||
options?: CatalogRequestOptions,
|
||||
): Promise<Location | undefined> {
|
||||
return await this.requestOptional(
|
||||
await this.apiClient.getLocationByEntity({ path: entityRef }, options),
|
||||
await this.apiClient.getLocationByEntity(
|
||||
{ path: parseEntityRef(entityRef) },
|
||||
options,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -632,11 +632,11 @@ export interface CatalogApi {
|
||||
/**
|
||||
* Gets a location associated with an entity.
|
||||
*
|
||||
* @param entityRef - A reference to an entity
|
||||
* @param entityRef - A complete entity ref, either on string or compound form
|
||||
* @param options - Additional options
|
||||
*/
|
||||
getLocationByEntity(
|
||||
entityRef: CompoundEntityRef,
|
||||
entityRef: string | CompoundEntityRef,
|
||||
options?: CatalogRequestOptions,
|
||||
): Promise<Location | undefined>;
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import { LocationInput, LocationStore } from '../../service/types';
|
||||
import {
|
||||
ANNOTATION_ORIGIN_LOCATION,
|
||||
CompoundEntityRef,
|
||||
parseLocationRef,
|
||||
stringifyEntityRef,
|
||||
} from '@backstage/catalog-model';
|
||||
|
||||
@@ -143,9 +144,8 @@ export class DefaultLocationStore implements LocationStore, EntityProvider {
|
||||
`found no origin annotation for ref ${entityRefString}`,
|
||||
);
|
||||
}
|
||||
const [type, ...rest] = locationKeyValue.value?.split(':') ?? [];
|
||||
const target = rest.join(':');
|
||||
|
||||
const { type, target } = parseLocationRef(entityRefString);
|
||||
// const kind, target = split[0], split[1];
|
||||
const [location] = await this.db<DbLocationsRow>('locations')
|
||||
.where({ type, target })
|
||||
|
||||
@@ -113,7 +113,7 @@ export class AuthorizedLocationService implements LocationService {
|
||||
}
|
||||
|
||||
async getLocationByEntity(
|
||||
entityRef: CompoundEntityRef,
|
||||
entityRef: CompoundEntityRef | string,
|
||||
options?: { authorizationToken?: string | undefined } | undefined,
|
||||
): Promise<Location> {
|
||||
const authorizationResponse = (
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
ANNOTATION_ORIGIN_LOCATION,
|
||||
stringifyEntityRef,
|
||||
CompoundEntityRef,
|
||||
parseEntityRef,
|
||||
} from '@backstage/catalog-model';
|
||||
import { Location } from '@backstage/catalog-client';
|
||||
import { CatalogProcessingOrchestrator } from '../processing/types';
|
||||
@@ -69,8 +70,10 @@ export class DefaultLocationService implements LocationService {
|
||||
return this.store.deleteLocation(id);
|
||||
}
|
||||
|
||||
getLocationByEntity(entityRef: CompoundEntityRef): Promise<Location> {
|
||||
return this.store.getLocationByEntity(entityRef);
|
||||
getLocationByEntity(
|
||||
entityRef: CompoundEntityRef | string,
|
||||
): Promise<Location> {
|
||||
return this.store.getLocationByEntity(parseEntityRef(entityRef));
|
||||
}
|
||||
|
||||
private async processEntities(
|
||||
|
||||
@@ -49,7 +49,7 @@ export interface LocationService {
|
||||
options?: { authorizationToken?: string },
|
||||
): Promise<void>;
|
||||
getLocationByEntity(
|
||||
entityRef: CompoundEntityRef,
|
||||
entityRef: CompoundEntityRef | string,
|
||||
options?: { authorizationToken?: string },
|
||||
): Promise<Location>;
|
||||
}
|
||||
@@ -86,5 +86,5 @@ export interface LocationStore {
|
||||
listLocations(): Promise<Location[]>;
|
||||
getLocation(id: string): Promise<Location>;
|
||||
deleteLocation(id: string): Promise<void>;
|
||||
getLocationByEntity(entityRef: CompoundEntityRef): Promise<Location>;
|
||||
getLocationByEntity(entityRef: CompoundEntityRef | string): Promise<Location>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user