Backstage
    Preparing search index...

    A mock friendly version of CatalogService / @backstage/catalog-client#CatalogApi | CatalogApi.

    This interface supports both API types at the same time, and has an optional second argument to simplify testing since the mock implementation does not care about credentials.

    interface CatalogServiceMock {
        addLocation(
            location: AddLocationRequest,
            options?: CatalogRequestOptions | CatalogServiceRequestOptions,
        ): Promise<AddLocationResponse>;
        analyzeLocation(
            location: AnalyzeLocationRequest,
            options?: CatalogRequestOptions | CatalogServiceRequestOptions,
        ): Promise<AnalyzeLocationResponse>;
        getEntities(
            request?: GetEntitiesRequest,
            options?: CatalogRequestOptions | CatalogServiceRequestOptions,
        ): Promise<GetEntitiesResponse>;
        getEntitiesByRefs(
            request: GetEntitiesByRefsRequest,
            options?: CatalogRequestOptions | CatalogServiceRequestOptions,
        ): Promise<GetEntitiesByRefsResponse>;
        getEntityAncestors(
            request: GetEntityAncestorsRequest,
            options?: CatalogRequestOptions | CatalogServiceRequestOptions,
        ): Promise<GetEntityAncestorsResponse>;
        getEntityByRef(
            entityRef: string | CompoundEntityRef,
            options?: CatalogRequestOptions | CatalogServiceRequestOptions,
        ): Promise<Entity | undefined>;
        getEntityFacets(
            request: GetEntityFacetsRequest,
            options?: CatalogRequestOptions | CatalogServiceRequestOptions,
        ): Promise<GetEntityFacetsResponse>;
        getLocationByEntity(
            entityRef: string | CompoundEntityRef,
            options?: CatalogRequestOptions | CatalogServiceRequestOptions,
        ): Promise<Location | undefined>;
        getLocationById(
            id: string,
            options?: CatalogRequestOptions | CatalogServiceRequestOptions,
        ): Promise<Location | undefined>;
        getLocationByRef(
            locationRef: string,
            options?: CatalogRequestOptions | CatalogServiceRequestOptions,
        ): Promise<Location | undefined>;
        getLocations(
            request?: {},
            options?: CatalogRequestOptions | CatalogServiceRequestOptions,
        ): Promise<GetLocationsResponse>;
        queryEntities(
            request?: QueryEntitiesRequest,
            options?: CatalogRequestOptions | CatalogServiceRequestOptions,
        ): Promise<QueryEntitiesResponse>;
        queryLocations(
            request?: QueryLocationsRequest,
            options?: CatalogRequestOptions | CatalogServiceRequestOptions,
        ): Promise<QueryLocationsResponse>;
        refreshEntity(
            entityRef: string,
            options?: CatalogRequestOptions | CatalogServiceRequestOptions,
        ): Promise<void>;
        removeEntityByUid(
            uid: string,
            options?: CatalogRequestOptions | CatalogServiceRequestOptions,
        ): Promise<void>;
        removeLocationById(
            id: string,
            options?: CatalogRequestOptions | CatalogServiceRequestOptions,
        ): Promise<void>;
        streamEntities(
            request?: StreamEntitiesRequest,
            options?: CatalogRequestOptions | CatalogServiceRequestOptions,
        ): AsyncIterable<Entity[]>;
        streamLocations(
            request?: QueryLocationsInitialRequest,
            options?: CatalogRequestOptions | CatalogServiceRequestOptions,
        ): AsyncIterable<Location[]>;
        validateEntity(
            entity: Entity,
            locationRef: string,
            options?: CatalogRequestOptions | CatalogServiceRequestOptions,
        ): Promise<ValidateEntityResponse>;
    }

    Hierarchy (View Summary)

    Index

    Methods

    • Gets paginated entities from the catalog.

      Parameters

      Returns Promise<QueryEntitiesResponse>

      const response = await catalogClient.queryEntities({
      filter: [{ kind: 'group' }],
      limit: 20,
      fields: ['metadata', 'kind'],
      fullTextFilter: {
      term: 'A',
      },
      orderFields: { field: 'metadata.name', order: 'asc' },
      });

      this will match all entities of type group having a name starting with 'A', ordered by name ascending.

      The response will contain a maximum of 20 entities. In case more than 20 entities exist, the response will contain a nextCursor property that can be used to fetch the next batch of entities.

      const secondBatchResponse = await catalogClient
      .queryEntities({
      cursor: response.nextCursor,
      limit: 20,
      fields: ['metadata', 'kind'],
      });

      secondBatchResponse will contain the next batch of (maximum) 20 entities, together with a prevCursor property, useful to fetch the previous batch.