always fetch full entities

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2023-10-23 16:45:28 +02:00
parent 762f6091d4
commit 430f2931b3
3 changed files with 0 additions and 38 deletions
-1
View File
@@ -257,7 +257,6 @@ export interface DefaultEntityPresentationApiOptions {
// @public
export interface DefaultEntityPresentationApiRenderer {
async?: boolean;
extraFields?: string[];
render: (options: {
entityRef: string;
loading: boolean;
@@ -24,12 +24,10 @@ import {
import { HumanDuration } from '@backstage/types';
import DataLoader from 'dataloader';
import ExpiryMap from 'expiry-map';
import uniq from 'lodash/uniq';
import ObservableImpl from 'zen-observable';
import {
DEFAULT_BATCH_DELAY,
DEFAULT_CACHE_TTL,
DEFAULT_ENTITY_FIELDS,
createDefaultRenderer,
} from './defaults';
import { durationToMs } from './util';
@@ -40,23 +38,6 @@ import { durationToMs } from './util';
* @public
*/
export interface DefaultEntityPresentationApiRenderer {
/**
* An extra set of fields to request for entities from the catalog API.
*
* @remarks
*
* You may want to specify this to get additional entity fields. The smaller
* the set of fields, the more efficient requests will be to the catalog
* backend.
*
* The default set of fields is: apiVersion, kind, the scalar metadata fields
* (uid, etag, name, namespace, title, description), spec.type, and
* spec.profile.
*
* This field is ignored if async is set to false.
*/
extraFields?: string[];
/**
* Whether to request the entity from the catalog API asynchronously.
*
@@ -332,15 +313,10 @@ export class DefaultEntityPresentationApi implements EntityPresentationApi {
const cacheTtlMs = durationToMs(options.cacheTtl);
const batchDelayMs = durationToMs(options.batchDelay);
const entityFields = uniq(
[DEFAULT_ENTITY_FIELDS, options.renderer?.extraFields ?? []].flat(),
);
return new DataLoader(
async (entityRefs: readonly string[]) => {
const { items } = await options.catalogApi!.getEntitiesByRefs({
entityRefs: entityRefs as string[],
fields: [...entityFields],
});
const now = Date.now();
@@ -32,19 +32,6 @@ export const DEFAULT_CACHE_TTL: HumanDuration = { seconds: 10 };
export const DEFAULT_BATCH_DELAY: HumanDuration = { milliseconds: 50 };
export const DEFAULT_ENTITY_FIELDS: string[] = [
'apiVersion',
'kind',
'metadata.uid',
'metadata.etag',
'metadata.name',
'metadata.namespace',
'metadata.title',
'metadata.description',
'spec.type',
'spec.profile',
];
export const UNKNOWN_KIND_ICON: IconComponent = HelpIcon;
export const DEFAULT_ICONS: Record<string, IconComponent> = {