deprecate EntityName, introduce CompoundEntityRef

deprecate getEntityName, introduce getCompoundEntityRef

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-03-02 21:26:22 +01:00
parent 80d2674a31
commit 36aa63022b
84 changed files with 393 additions and 268 deletions
+9
View File
@@ -0,0 +1,9 @@
---
'@backstage/catalog-model': patch
---
**DEPRECATION**: Deprecated the `EntityName` type, and added the better-named `CompoundEntityRef` to replace it.
**DEPRECATION**: Deprecated the `getEntityName` function, and added the better-named `getCompoundEntityRef` to replace it.
Please switch over to using the new symbols, as the old ones may be removed in a future release.
+22
View File
@@ -0,0 +1,22 @@
---
'@backstage/catalog-client': patch
'@backstage/plugin-auth-backend': patch
'@backstage/plugin-catalog': patch
'@backstage/plugin-catalog-backend': patch
'@backstage/plugin-catalog-graph': patch
'@backstage/plugin-catalog-import': patch
'@backstage/plugin-catalog-react': patch
'@backstage/plugin-code-coverage': patch
'@backstage/plugin-code-coverage-backend': patch
'@backstage/plugin-fossa': patch
'@backstage/plugin-jenkins': patch
'@backstage/plugin-jenkins-backend': patch
'@backstage/plugin-scaffolder-backend': patch
'@backstage/plugin-tech-insights': patch
'@backstage/plugin-tech-insights-backend': patch
'@backstage/plugin-techdocs': patch
'@backstage/plugin-techdocs-backend': patch
'@backstage/plugin-todo-backend': patch
---
Use `CompoundEntityRef` instead of `EntityName`, and `getCompoundEntityRef` instead of `getEntityName`, from `@backstage/catalog-model`.
+3 -3
View File
@@ -3,8 +3,8 @@
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts
import { CompoundEntityRef } from '@backstage/catalog-model';
import { Entity } from '@backstage/catalog-model';
import { EntityName } from '@backstage/catalog-model';
// @public
export type AddLocationRequest = {
@@ -39,7 +39,7 @@ export interface CatalogApi {
options?: CatalogRequestOptions,
): Promise<GetEntityAncestorsResponse>;
getEntityByName(
name: EntityName,
name: CompoundEntityRef,
options?: CatalogRequestOptions,
): Promise<Entity | undefined>;
getEntityFacets(
@@ -91,7 +91,7 @@ export class CatalogClient implements CatalogApi {
options?: CatalogRequestOptions,
): Promise<GetEntityAncestorsResponse>;
getEntityByName(
compoundName: EntityName,
compoundName: CompoundEntityRef,
options?: CatalogRequestOptions,
): Promise<Entity | undefined>;
getEntityFacets(
+2 -2
View File
@@ -18,7 +18,7 @@ import {
ANNOTATION_LOCATION,
ANNOTATION_ORIGIN_LOCATION,
Entity,
EntityName,
CompoundEntityRef,
parseEntityRef,
stringifyEntityRef,
stringifyLocationRef,
@@ -174,7 +174,7 @@ export class CatalogClient implements CatalogApi {
* {@inheritdoc CatalogApi.getEntityByName}
*/
async getEntityByName(
compoundName: EntityName,
compoundName: CompoundEntityRef,
options?: CatalogRequestOptions,
): Promise<Entity | undefined> {
const { kind, namespace = 'default', name } = compoundName;
+2 -2
View File
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { Entity, EntityName } from '@backstage/catalog-model';
import { CompoundEntityRef, Entity } from '@backstage/catalog-model';
/**
* This symbol can be used in place of a value when passed to filters in e.g.
@@ -310,7 +310,7 @@ export interface CatalogApi {
* @param options - Additional options
*/
getEntityByName(
name: EntityName,
name: CompoundEntityRef,
options?: CatalogRequestOptions,
): Promise<Entity | undefined>;
+16 -10
View File
@@ -88,6 +88,13 @@ export { ComponentEntityV1alpha1 };
// @public
export const componentEntityV1alpha1Validator: KindValidator;
// @public
export type CompoundEntityRef = {
kind: string;
namespace: string;
name: string;
};
// @public
export const DEFAULT_NAMESPACE = 'default';
@@ -166,12 +173,8 @@ export type EntityMeta = JsonObject & {
links?: EntityLink[];
};
// @public
export type EntityName = {
kind: string;
namespace: string;
name: string;
};
// @public @deprecated
export type EntityName = CompoundEntityRef;
// @public
export const EntityPolicies: {
@@ -196,7 +199,7 @@ export type EntityRef =
// @public
export type EntityRelation = {
type: string;
target: EntityName;
target: CompoundEntityRef;
targetRef: string;
};
@@ -229,7 +232,10 @@ export class FieldFormatEntityPolicy implements EntityPolicy {
}
// @public
export function getEntityName(entity: Entity): EntityName;
export function getCompoundEntityRef(entity: Entity): CompoundEntityRef;
// @public @deprecated
export const getEntityName: typeof getCompoundEntityRef;
// @public
export function getEntitySourceLocation(entity: Entity): {
@@ -337,7 +343,7 @@ export function parseEntityName(
defaultKind?: string;
defaultNamespace?: string;
},
): EntityName;
): CompoundEntityRef;
// @public
export function parseEntityRef(
@@ -352,7 +358,7 @@ export function parseEntityRef(
defaultKind?: string;
defaultNamespace?: string;
},
): EntityName;
): CompoundEntityRef;
// @public
export function parseLocationRef(ref: string): {
+2 -2
View File
@@ -15,7 +15,7 @@
*/
import { JsonObject } from '@backstage/types';
import { EntityName } from '../types';
import { CompoundEntityRef } from '../types';
import { EntityStatus } from './EntityStatus';
/**
@@ -201,7 +201,7 @@ export type EntityRelation = {
*
* @deprecated use targetRef instead
*/
target: EntityName;
target: CompoundEntityRef;
/**
* The entity ref of the target of this relation.
@@ -34,6 +34,7 @@ export type {
} from './EntityStatus';
export * from './policies';
export {
getCompoundEntityRef,
getEntityName,
parseEntityName,
parseEntityRef,
+18 -7
View File
@@ -15,7 +15,7 @@
*/
import { DEFAULT_NAMESPACE } from './constants';
import { EntityName } from '../types';
import { CompoundEntityRef } from '../types';
import { Entity } from './Entity';
function parseRefString(ref: string): {
@@ -38,14 +38,25 @@ function parseRefString(ref: string): {
}
/**
* Extracts the kind, namespace and name that form the name triplet of the
* given entity.
* Extracts the kind, namespace and name that form the compound entity ref
* triplet of the given entity.
*
* @public
* @deprecated Use getCompoundEntityRef instead
* @param entity - An entity
* @returns The compound entity ref
*/
export const getEntityName = getCompoundEntityRef;
/**
* Extracts the kind, namespace and name that form the compound entity ref
* triplet of the given entity.
*
* @public
* @param entity - An entity
* @returns The complete entity name
* @returns The compound entity ref
*/
export function getEntityName(entity: Entity): EntityName {
export function getCompoundEntityRef(entity: Entity): CompoundEntityRef {
return {
kind: entity.kind,
namespace: entity.metadata.namespace || DEFAULT_NAMESPACE,
@@ -77,7 +88,7 @@ export function parseEntityName(
/** The default namespace, if none is given in the reference */
defaultNamespace?: string;
} = {},
): EntityName {
): CompoundEntityRef {
const { kind, namespace, name } = parseEntityRef(ref, {
defaultNamespace: DEFAULT_NAMESPACE,
...context,
@@ -114,7 +125,7 @@ export function parseEntityRef(
/** The default namespace, if none is given in the reference */
defaultNamespace?: string;
},
): EntityName {
): CompoundEntityRef {
if (!ref) {
throw new Error(`Entity reference must not be empty`);
}
+1 -1
View File
@@ -24,5 +24,5 @@ export * from './entity';
export { EntityPolicies } from './EntityPolicies';
export * from './kinds';
export * from './location';
export type { EntityName, EntityRef } from './types';
export type { EntityName, EntityRef, CompoundEntityRef } from './types';
export * from './validation';
+11 -2
View File
@@ -15,16 +15,25 @@
*/
/**
* A complete entity name, with the full kind-namespace-name triplet.
* All parts of a complete entity ref, forming a full kind-namespace-name
* triplet.
*
* @public
*/
export type EntityName = {
export type CompoundEntityRef = {
kind: string;
namespace: string;
name: string;
};
/**
* A complete entity name, with the full kind-namespace-name triplet.
*
* @deprecated Use CompoundEntityRef instead
* @public
*/
export type EntityName = CompoundEntityRef;
/**
* A reference by name to an entity, either as a compact string representation,
* or as a compound reference structure.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { EntityName } from '@backstage/catalog-model';
import { CompoundEntityRef } from '@backstage/catalog-model';
import { Config } from '@backstage/config';
import {
scmIntegrationsApiRef,
@@ -81,7 +81,7 @@ class TechDocsDevStorageApi implements TechDocsStorageApi {
return this.configApi.getString('techdocs.builder');
}
async getEntityDocs(_entityId: EntityName, path: string) {
async getEntityDocs(_entityId: CompoundEntityRef, path: string) {
const apiOrigin = await this.getApiOrigin();
// Irrespective of the entity, use mkdocs server to find the file for the path.
const url = `${apiOrigin}/${path}`;
@@ -97,7 +97,7 @@ class TechDocsDevStorageApi implements TechDocsStorageApi {
return request.text();
}
async syncEntityDocs(_: EntityName): Promise<SyncResult> {
async syncEntityDocs(_: CompoundEntityRef): Promise<SyncResult> {
// this is just stub of this function as we don't need to check if docs are up to date,
// we always want to retrigger a new build
return 'cached';
@@ -106,7 +106,7 @@ class TechDocsDevStorageApi implements TechDocsStorageApi {
// Used by transformer to modify the request to assets (CSS, Image) from inside the HTML.
async getBaseUrl(
oldBaseUrl: string,
_entityId: EntityName,
_entityId: CompoundEntityRef,
path: string,
): Promise<string> {
const apiOrigin = await this.getApiOrigin();
@@ -154,7 +154,7 @@ class TechDocsDevApi implements TechDocsApi {
};
}
async getTechDocsMetadata(_entityId: EntityName) {
async getTechDocsMetadata(_entityId: CompoundEntityRef) {
return {
site_name: 'Live preview environment',
site_description: '',
@@ -29,7 +29,7 @@ import LightIcon from '@material-ui/icons/Brightness7';
import DarkIcon from '@material-ui/icons/Brightness4';
import { lightTheme, darkTheme } from '@backstage/theme';
import { EntityName } from '@backstage/catalog-model';
import { CompoundEntityRef } from '@backstage/catalog-model';
import { Content } from '@backstage/core-components';
@@ -127,7 +127,7 @@ const TechDocsPageContent = ({
onReady,
entityRef,
}: {
entityRef: EntityName;
entityRef: CompoundEntityRef;
onReady: () => void;
}) => {
const classes = useStyles();
+4 -2
View File
@@ -5,10 +5,10 @@
```ts
/// <reference types="node" />
import { CompoundEntityRef } from '@backstage/catalog-model';
import { Config } from '@backstage/config';
import { ContainerRunner } from '@backstage/backend-common';
import { Entity } from '@backstage/catalog-model';
import { EntityName } from '@backstage/catalog-model';
import express from 'express';
import { IndexableDocument } from '@backstage/search-common';
import { Logger as Logger_2 } from 'winston';
@@ -157,7 +157,9 @@ export class Publisher {
// @public
export interface PublisherBase {
docsRouter(): express.Handler;
fetchTechDocsMetadata(entityName: EntityName): Promise<TechDocsMetadata>;
fetchTechDocsMetadata(
entityName: CompoundEntityRef,
): Promise<TechDocsMetadata>;
getReadiness(): Promise<ReadinessResponse>;
hasDocsBeenGenerated(entityName: Entity): Promise<boolean>;
migrateDocsCase?(migrateRequest: MigrateRequest): Promise<void>;
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Entity, EntityName } from '@backstage/catalog-model';
import { Entity, CompoundEntityRef } from '@backstage/catalog-model';
import { Config } from '@backstage/config';
import { assertError, ForwardedError } from '@backstage/errors';
import aws, { Credentials } from 'aws-sdk';
@@ -321,7 +321,7 @@ export class AwsS3Publish implements PublisherBase {
}
async fetchTechDocsMetadata(
entityName: EntityName,
entityName: CompoundEntityRef,
): Promise<TechDocsMetadata> {
try {
return await new Promise<TechDocsMetadata>(async (resolve, reject) => {
@@ -19,7 +19,7 @@ import {
ContainerClient,
StorageSharedKeyCredential,
} from '@azure/storage-blob';
import { Entity, EntityName } from '@backstage/catalog-model';
import { Entity, CompoundEntityRef } from '@backstage/catalog-model';
import { Config } from '@backstage/config';
import { assertError, ForwardedError } from '@backstage/errors';
import express from 'express';
@@ -300,7 +300,7 @@ export class AzureBlobStoragePublish implements PublisherBase {
}
async fetchTechDocsMetadata(
entityName: EntityName,
entityName: CompoundEntityRef,
): Promise<TechDocsMetadata> {
const entityTriplet = `${entityName.namespace}/${entityName.kind}/${entityName.name}`;
const entityRootDir = this.legacyPathCasing
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Entity, EntityName } from '@backstage/catalog-model';
import { Entity, CompoundEntityRef } from '@backstage/catalog-model';
import { Config } from '@backstage/config';
import { assertError } from '@backstage/errors';
import { File, FileExistsResponse, Storage } from '@google-cloud/storage';
@@ -238,7 +238,9 @@ export class GoogleGCSPublish implements PublisherBase {
return { objects };
}
fetchTechDocsMetadata(entityName: EntityName): Promise<TechDocsMetadata> {
fetchTechDocsMetadata(
entityName: CompoundEntityRef,
): Promise<TechDocsMetadata> {
return new Promise((resolve, reject) => {
const entityTriplet = `${entityName.namespace}/${entityName.kind}/${entityName.name}`;
const entityDir = this.legacyPathCasing
@@ -17,7 +17,7 @@ import {
PluginEndpointDiscovery,
resolvePackagePath,
} from '@backstage/backend-common';
import { Entity, EntityName } from '@backstage/catalog-model';
import { Entity, CompoundEntityRef } from '@backstage/catalog-model';
import { Config } from '@backstage/config';
import express from 'express';
import fs from 'fs-extra';
@@ -142,7 +142,7 @@ export class LocalPublish implements PublisherBase {
}
async fetchTechDocsMetadata(
entityName: EntityName,
entityName: CompoundEntityRef,
): Promise<TechDocsMetadata> {
const metadataPath = this.staticEntityPathJoin(
entityName.namespace,
@@ -17,7 +17,7 @@
import { getVoidLogger } from '@backstage/backend-common';
import {
Entity,
EntityName,
CompoundEntityRef,
DEFAULT_NAMESPACE,
} from '@backstage/catalog-model';
import { ConfigReader } from '@backstage/config';
@@ -45,7 +45,7 @@ const createMockEntity = (annotations = {}): Entity => {
};
};
const createMockEntityName = (): EntityName => ({
const createMockEntityName = (): CompoundEntityRef => ({
kind: 'TestKind',
name: 'test-component-name',
namespace: 'test-namespace',
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Entity, EntityName } from '@backstage/catalog-model';
import { Entity, CompoundEntityRef } from '@backstage/catalog-model';
import { Config } from '@backstage/config';
import express from 'express';
import fs from 'fs-extra';
@@ -194,7 +194,7 @@ export class OpenStackSwiftPublish implements PublisherBase {
}
async fetchTechDocsMetadata(
entityName: EntityName,
entityName: CompoundEntityRef,
): Promise<TechDocsMetadata> {
return await new Promise<TechDocsMetadata>(async (resolve, reject) => {
const entityRootDir = `${entityName.namespace}/${entityName.kind}/${entityName.name}`;
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Entity, EntityName } from '@backstage/catalog-model';
import { Entity, CompoundEntityRef } from '@backstage/catalog-model';
import { PluginEndpointDiscovery } from '@backstage/backend-common';
import { Logger } from 'winston';
import express from 'express';
@@ -133,7 +133,9 @@ export interface PublisherBase {
* Retrieve TechDocs Metadata about a site e.g. name, contributors, last updated, etc.
* This API uses the techdocs_metadata.json file that co-exists along with the generated docs.
*/
fetchTechDocsMetadata(entityName: EntityName): Promise<TechDocsMetadata>;
fetchTechDocsMetadata(
entityName: CompoundEntityRef,
): Promise<TechDocsMetadata>;
/**
* Route middleware to serve static documentation files for an entity.
@@ -18,7 +18,7 @@ import { Logger } from 'winston';
import { ConflictError, NotFoundError } from '@backstage/errors';
import { CatalogApi } from '@backstage/catalog-client';
import {
EntityName,
CompoundEntityRef,
parseEntityRef,
RELATION_MEMBER_OF,
stringifyEntityRef,
@@ -96,7 +96,7 @@ export class CatalogIdentityClient {
return null;
}
})
.filter((ref): ref is EntityName => ref !== null);
.filter((ref): ref is CompoundEntityRef => ref !== null);
const filter = resolvedEntityRefs.map(ref => ({
kind: ref.kind,
+3 -3
View File
@@ -7,12 +7,12 @@
import { BitbucketIntegration } from '@backstage/integration';
import { CatalogApi } from '@backstage/catalog-client';
import { CompoundEntityRef } from '@backstage/catalog-model';
import { ConditionalPolicyDecision } from '@backstage/plugin-permission-node';
import { Conditions } from '@backstage/plugin-permission-node';
import { Config } from '@backstage/config';
import { DocumentCollatorFactory } from '@backstage/search-common';
import { Entity } from '@backstage/catalog-model';
import { EntityName } from '@backstage/catalog-model';
import { EntityPolicy } from '@backstage/catalog-model';
import express from 'express';
import { GetEntitiesRequest } from '@backstage/catalog-client';
@@ -649,9 +649,9 @@ export type EntityProviderMutation =
// @public
export type EntityRelationSpec = {
source: EntityName;
source: CompoundEntityRef;
type: string;
target: EntityName;
target: CompoundEntityRef;
};
// @public (undocumented)
+3 -3
View File
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { EntityName } from '@backstage/catalog-model';
import { CompoundEntityRef } from '@backstage/catalog-model';
/**
* Holds the entity location information.
@@ -42,7 +42,7 @@ export type EntityRelationSpec = {
/**
* The source entity of this relation.
*/
source: EntityName;
source: CompoundEntityRef;
/**
* The type of the relation.
@@ -52,5 +52,5 @@ export type EntityRelationSpec = {
/**
* The target entity of this relation.
*/
target: EntityName;
target: CompoundEntityRef;
};
@@ -22,7 +22,7 @@ import {
DomainEntity,
domainEntityV1alpha1Validator,
Entity,
getEntityName,
getCompoundEntityRef,
GroupEntity,
groupEntityV1alpha1Validator,
locationEntityV1alpha1Validator,
@@ -93,7 +93,7 @@ export class BuiltinKindsEntityProcessor implements CatalogProcessor {
_location: LocationSpec,
emit: CatalogProcessorEmit,
): Promise<Entity> {
const selfRef = getEntityName(entity);
const selfRef = getCompoundEntityRef(entity);
/*
* Utilities
+2 -2
View File
@@ -6,8 +6,8 @@
/// <reference types="react" />
import { BackstagePlugin } from '@backstage/core-plugin-api';
import { CompoundEntityRef } from '@backstage/catalog-model';
import { DependencyGraphTypes } from '@backstage/core-components';
import { EntityName } from '@backstage/catalog-model';
import { ExternalRouteRef } from '@backstage/core-plugin-api';
import { InfoCardVariants } from '@backstage/core-components';
import { MouseEvent as MouseEvent_2 } from 'react';
@@ -129,7 +129,7 @@ export const EntityRelationsGraph: ({
className,
zoom,
}: {
rootEntityNames: EntityName | EntityName[];
rootEntityNames: CompoundEntityRef | CompoundEntityRef[];
maxDepth?: number | undefined;
unidirectional?: boolean | undefined;
mergeRelations?: boolean | undefined;
+4 -2
View File
@@ -16,7 +16,7 @@
import { GetEntitiesResponse } from '@backstage/catalog-client';
import {
Entity,
EntityName,
CompoundEntityRef,
DEFAULT_NAMESPACE,
RELATION_API_CONSUMED_BY,
RELATION_API_PROVIDED_BY,
@@ -139,7 +139,9 @@ createDevApp()
deps: {},
factory() {
return {
async getEntityByName(name: EntityName): Promise<Entity | undefined> {
async getEntityByName(
name: CompoundEntityRef,
): Promise<Entity | undefined> {
return entities[stringifyEntityRef(name)];
},
async getEntities(): Promise<GetEntitiesResponse> {
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import {
getEntityName,
getCompoundEntityRef,
parseEntityRef,
stringifyEntityRef,
} from '@backstage/catalog-model';
@@ -77,7 +77,7 @@ export const CatalogGraphCard = ({
zoom?: 'enabled' | 'disabled' | 'enable-on-click';
}) => {
const { entity } = useEntity();
const entityName = getEntityName(entity);
const entityName = getCompoundEntityRef(entity);
const catalogEntityRoute = useRouteRef(entityRouteRef);
const catalogGraphRoute = useRouteRef(catalogGraphRouteRef);
const navigate = useNavigate();
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import {
EntityName,
CompoundEntityRef,
parseEntityRef,
stringifyEntityRef,
} from '@backstage/catalog-model';
@@ -32,8 +32,8 @@ import usePrevious from 'react-use/lib/usePrevious';
import { Direction } from '../EntityRelationsGraph';
export type CatalogGraphPageValue = {
rootEntityNames: EntityName[];
setRootEntityNames: Dispatch<React.SetStateAction<EntityName[]>>;
rootEntityNames: CompoundEntityRef[];
setRootEntityNames: Dispatch<React.SetStateAction<CompoundEntityRef[]>>;
maxDepth: number;
setMaxDepth: Dispatch<React.SetStateAction<number>>;
selectedRelations: string[] | undefined;
@@ -82,11 +82,12 @@ export function useCatalogGraphPage({
);
// Initial state
const [rootEntityNames, setRootEntityNames] = useState<EntityName[]>(() =>
(Array.isArray(query.rootEntityRefs)
? query.rootEntityRefs
: initialState?.rootEntityRefs ?? []
).map(r => parseEntityRef(r)),
const [rootEntityNames, setRootEntityNames] = useState<CompoundEntityRef[]>(
() =>
(Array.isArray(query.rootEntityRefs)
? query.rootEntityRefs
: initialState?.rootEntityRefs ?? []
).map(r => parseEntityRef(r)),
);
const [maxDepth, setMaxDepth] = useState<number>(() =>
typeof query.maxDepth === 'string'
@@ -13,7 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { EntityName, stringifyEntityRef } from '@backstage/catalog-model';
import {
CompoundEntityRef,
stringifyEntityRef,
} from '@backstage/catalog-model';
import {
DependencyGraph,
DependencyGraphTypes,
@@ -77,7 +80,7 @@ export const EntityRelationsGraph = ({
className,
zoom = 'enabled',
}: {
rootEntityNames: EntityName | EntityName[];
rootEntityNames: CompoundEntityRef | CompoundEntityRef[];
maxDepth?: number;
unidirectional?: boolean;
mergeRelations?: boolean;
+5 -5
View File
@@ -8,11 +8,11 @@
import { ApiRef } from '@backstage/core-plugin-api';
import { BackstagePlugin } from '@backstage/core-plugin-api';
import { CatalogApi } from '@backstage/catalog-client';
import { CompoundEntityRef } from '@backstage/catalog-model';
import { ConfigApi } from '@backstage/core-plugin-api';
import { Controller } from 'react-hook-form';
import { DiscoveryApi } from '@backstage/core-plugin-api';
import { Entity } from '@backstage/catalog-model';
import { EntityName } from '@backstage/catalog-model';
import { FieldErrors } from 'react-hook-form';
import { IdentityApi } from '@backstage/core-plugin-api';
import { InfoCardVariants } from '@backstage/core-components';
@@ -33,7 +33,7 @@ export type AnalyzeResult =
locations: Array<{
target: string;
exists?: boolean;
entities: EntityName[];
entities: CompoundEntityRef[];
}>;
}
| {
@@ -165,7 +165,7 @@ export interface EntityListComponentProps {
// (undocumented)
locations: Array<{
target: string;
entities: (Entity | EntityName)[];
entities: (Entity | CompoundEntityRef)[];
}>;
// (undocumented)
onItemClick?: (target: string) => void;
@@ -246,7 +246,7 @@ export type PrepareResult =
locations: Array<{
exists?: boolean;
target: string;
entities: EntityName[];
entities: CompoundEntityRef[];
}>;
}
| {
@@ -258,7 +258,7 @@ export type PrepareResult =
};
locations: Array<{
target: string;
entities: EntityName[];
entities: CompoundEntityRef[];
}>;
};
+2 -2
View File
@@ -15,7 +15,7 @@
*/
import { CatalogApi } from '@backstage/catalog-client';
import { Entity, EntityName } from '@backstage/catalog-model';
import { Entity, CompoundEntityRef } from '@backstage/catalog-model';
import { createDevApp } from '@backstage/dev-utils';
import { catalogApiRef } from '@backstage/plugin-catalog-react';
import { Grid, ListItem, ListItemIcon, ListItemText } from '@material-ui/core';
@@ -32,7 +32,7 @@ import {
import { ImportPage } from '../src/components/ImportPage';
import { Content, Header, InfoCard, Page } from '@backstage/core-components';
const getEntityNames = (url: string): EntityName[] => [
const getEntityNames = (url: string): CompoundEntityRef[] => [
{
kind: 'Component',
namespace: url.replace(/^.*(folder-[^/]+).*|.*()$/, '$1') || 'default',
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { EntityName } from '@backstage/catalog-model';
import { CompoundEntityRef } from '@backstage/catalog-model';
import { createApiRef } from '@backstage/core-plugin-api';
import { PartialEntity } from '../types';
@@ -38,7 +38,7 @@ export type AnalyzeResult =
locations: Array<{
target: string;
exists?: boolean;
entities: EntityName[];
entities: CompoundEntityRef[];
}>;
}
| {
@@ -15,7 +15,7 @@
*/
import { CatalogApi } from '@backstage/catalog-client';
import { EntityName } from '@backstage/catalog-model';
import { CompoundEntityRef } from '@backstage/catalog-model';
import {
ConfigApi,
DiscoveryApi,
@@ -212,7 +212,7 @@ the component will become available.\n\nFor more information, read an \
}): Promise<
Array<{
target: string;
entities: EntityName[];
entities: CompoundEntityRef[];
}>
> {
const { url, owner, repo, githubIntegrationConfig } = options;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { Entity, EntityName } from '@backstage/catalog-model';
import { Entity, CompoundEntityRef } from '@backstage/catalog-model';
import { useApp } from '@backstage/core-plugin-api';
import {
EntityRefLink,
@@ -41,7 +41,7 @@ const useStyles = makeStyles(theme => ({
},
}));
function sortEntities(entities: Array<EntityName | Entity>) {
function sortEntities(entities: Array<CompoundEntityRef | Entity>) {
return entities.sort((a, b) =>
humanizeEntityRef(a).localeCompare(humanizeEntityRef(b)),
);
@@ -53,7 +53,10 @@ function sortEntities(entities: Array<EntityName | Entity>) {
* @public
*/
export interface EntityListComponentProps {
locations: Array<{ target: string; entities: (Entity | EntityName)[] }>;
locations: Array<{
target: string;
entities: (Entity | CompoundEntityRef)[];
}>;
locationListItemIcon: (target: string) => React.ReactElement;
collapsed?: boolean;
firstListItem?: React.ReactElement;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { Entity, EntityName } from '@backstage/catalog-model';
import { Entity, CompoundEntityRef } from '@backstage/catalog-model';
import { cleanup } from '@testing-library/react';
import { act, renderHook } from '@testing-library/react-hooks';
import { AnalyzeResult } from '../api';
@@ -37,7 +37,7 @@ describe('useImportState', () => {
locations: [
{
target: 'https://0',
entities: [] as EntityName[],
entities: [] as CompoundEntityRef[],
},
],
};
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { Entity, EntityName } from '@backstage/catalog-model';
import { Entity, CompoundEntityRef } from '@backstage/catalog-model';
import { useReducer } from 'react';
import { AnalyzeResult } from '../api';
@@ -43,7 +43,7 @@ export type PrepareResult =
locations: Array<{
exists?: boolean;
target: string;
entities: EntityName[];
entities: CompoundEntityRef[];
}>;
}
| {
@@ -55,7 +55,7 @@ export type PrepareResult =
};
locations: Array<{
target: string;
entities: EntityName[];
entities: CompoundEntityRef[];
}>;
};
+14 -8
View File
@@ -11,8 +11,8 @@ import { CATALOG_FILTER_EXISTS } from '@backstage/catalog-client';
import { CatalogApi } from '@backstage/catalog-client';
import { ComponentEntity } from '@backstage/catalog-model';
import { ComponentProps } from 'react';
import { CompoundEntityRef } from '@backstage/catalog-model';
import { Entity } from '@backstage/catalog-model';
import { EntityName } from '@backstage/catalog-model';
import { GetEntitiesResponse } from '@backstage/catalog-client';
import { IconButton } from '@material-ui/core';
import { LinkProps } from '@backstage/core-components';
@@ -250,7 +250,7 @@ export const EntityRefLink: (props: EntityRefLinkProps) => JSX.Element;
// @public
export type EntityRefLinkProps = {
entityRef: Entity | EntityName | string;
entityRef: Entity | CompoundEntityRef | string;
defaultKind?: string;
title?: string;
children?: React_2.ReactNode;
@@ -265,7 +265,7 @@ export const EntityRefLinks: ({
// @public
export type EntityRefLinksProps = {
entityRefs: (Entity | EntityName)[];
entityRefs: (Entity | CompoundEntityRef)[];
defaultKind?: string;
} & Omit<LinkProps, 'to'>;
@@ -429,7 +429,7 @@ export function getEntityRelations(
filter?: {
kind: string;
},
): EntityName[];
): CompoundEntityRef[];
// @public (undocumented)
export function getEntitySourceLocation(
@@ -439,7 +439,7 @@ export function getEntitySourceLocation(
// @public (undocumented)
export function humanizeEntityRef(
entityRef: Entity | EntityName,
entityRef: Entity | CompoundEntityRef,
opts?: {
defaultKind?: string;
},
@@ -627,12 +627,18 @@ export type UserListPickerProps = {
// @public (undocumented)
export function useStarredEntities(): {
starredEntities: Set<string>;
toggleStarredEntity: (entityOrRef: Entity | EntityName | string) => void;
isStarredEntity: (entityOrRef: Entity | EntityName | string) => boolean;
toggleStarredEntity: (
entityOrRef: Entity | CompoundEntityRef | string,
) => void;
isStarredEntity: (
entityOrRef: Entity | CompoundEntityRef | string,
) => boolean;
};
// @public (undocumented)
export function useStarredEntity(entityOrRef: Entity | EntityName | string): {
export function useStarredEntity(
entityOrRef: Entity | CompoundEntityRef | string,
): {
toggleStarredEntity: () => void;
isStarredEntity: boolean;
};
@@ -16,7 +16,7 @@
import {
Entity,
EntityName,
CompoundEntityRef,
DEFAULT_NAMESPACE,
parseEntityRef,
} from '@backstage/catalog-model';
@@ -33,7 +33,7 @@ import { Tooltip } from '@material-ui/core';
* @public
*/
export type EntityRefLinkProps = {
entityRef: Entity | EntityName | string;
entityRef: Entity | CompoundEntityRef | string;
defaultKind?: string;
title?: string;
children?: React.ReactNode;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { Entity, EntityName } from '@backstage/catalog-model';
import { Entity, CompoundEntityRef } from '@backstage/catalog-model';
import React from 'react';
import { EntityRefLink } from './EntityRefLink';
import { LinkProps } from '@backstage/core-components';
@@ -25,7 +25,7 @@ import { LinkProps } from '@backstage/core-components';
* @public
*/
export type EntityRefLinksProps = {
entityRefs: (Entity | EntityName)[];
entityRefs: (Entity | CompoundEntityRef)[];
defaultKind?: string;
} & Omit<LinkProps, 'to'>;
@@ -16,7 +16,7 @@
import {
Entity,
EntityName,
CompoundEntityRef,
DEFAULT_NAMESPACE,
} from '@backstage/catalog-model';
@@ -25,7 +25,7 @@ export const formatEntityRefTitle = humanizeEntityRef;
/** @public */
export function humanizeEntityRef(
entityRef: Entity | EntityName,
entityRef: Entity | CompoundEntityRef,
opts?: { defaultKind?: string },
) {
const defaultKind = opts?.defaultKind;
@@ -16,7 +16,7 @@
import {
Entity,
EntityName,
CompoundEntityRef,
RELATION_OWNED_BY,
RELATION_PART_OF,
} from '@backstage/catalog-model';
@@ -81,7 +81,7 @@ export const columnFactories = Object.freeze({
defaultKind?: string;
filter?: { kind: string };
}): TableColumn<T> {
function getRelations(entity: T): EntityName[] {
function getRelations(entity: T): CompoundEntityRef[] {
return getEntityRelations(entity, relation, entityFilter);
}
@@ -16,8 +16,8 @@
import {
Entity,
EntityName,
getEntityName,
CompoundEntityRef,
getCompoundEntityRef,
ANNOTATION_ORIGIN_LOCATION,
} from '@backstage/catalog-model';
import { catalogApiRef } from '../../api';
@@ -44,7 +44,7 @@ export type UseUnregisterEntityDialogState =
| {
type: 'unregister';
location: string;
colocatedEntities: EntityName[];
colocatedEntities: CompoundEntityRef[];
unregisterLocation: () => Promise<void>;
deleteEntity: () => Promise<void>;
}
@@ -141,7 +141,7 @@ export function useUnregisterEntityDialogState(
return {
type: 'unregister',
location: locationRef!,
colocatedEntities: colocatedEntities.map(getEntityName),
colocatedEntities: colocatedEntities.map(getCompoundEntityRef),
unregisterLocation,
deleteEntity,
};
@@ -16,7 +16,7 @@
import {
Entity,
EntityName,
CompoundEntityRef,
stringifyEntityRef,
} from '@backstage/catalog-model';
import { useApi } from '@backstage/core-plugin-api';
@@ -24,7 +24,9 @@ import { useCallback } from 'react';
import useObservable from 'react-use/lib/useObservable';
import { starredEntitiesApiRef } from '../apis';
function getEntityRef(entityOrRef: Entity | EntityName | string): string {
function getEntityRef(
entityOrRef: Entity | CompoundEntityRef | string,
): string {
return typeof entityOrRef === 'string'
? entityOrRef
: stringifyEntityRef(entityOrRef);
@@ -33,8 +35,12 @@ function getEntityRef(entityOrRef: Entity | EntityName | string): string {
/** @public */
export function useStarredEntities(): {
starredEntities: Set<string>;
toggleStarredEntity: (entityOrRef: Entity | EntityName | string) => void;
isStarredEntity: (entityOrRef: Entity | EntityName | string) => boolean;
toggleStarredEntity: (
entityOrRef: Entity | CompoundEntityRef | string,
) => void;
isStarredEntity: (
entityOrRef: Entity | CompoundEntityRef | string,
) => boolean;
} {
const starredEntitiesApi = useApi(starredEntitiesApiRef);
@@ -44,13 +50,13 @@ export function useStarredEntities(): {
);
const isStarredEntity = useCallback(
(entityOrRef: Entity | EntityName | string) =>
(entityOrRef: Entity | CompoundEntityRef | string) =>
starredEntities.has(getEntityRef(entityOrRef)),
[starredEntities],
);
const toggleStarredEntity = useCallback(
(entityOrRef: Entity | EntityName | string) =>
(entityOrRef: Entity | CompoundEntityRef | string) =>
starredEntitiesApi.toggleStarred(getEntityRef(entityOrRef)).then(),
[starredEntitiesApi],
);
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { Entity, EntityName } from '@backstage/catalog-model';
import { Entity, CompoundEntityRef } from '@backstage/catalog-model';
import { TestApiProvider } from '@backstage/test-utils';
import { renderHook } from '@testing-library/react-hooks';
import React, { PropsWithChildren } from 'react';
@@ -44,7 +44,7 @@ describe('useStarredEntity', () => {
describe.each`
title | entityOrRef
${'entity reference'} | ${'component:default/mock'}
${'entity name'} | ${{ kind: 'component', namespace: 'default', name: 'mock' } as EntityName}
${'entity name'} | ${{ kind: 'component', namespace: 'default', name: 'mock' } as CompoundEntityRef}
${'entity'} | ${{ apiVersion: '1', kind: 'Component', metadata: { name: 'mock' } } as Entity}
`('with $title', ({ entityOrRef }) => {
describe('toggleStarredEntity', () => {
@@ -16,21 +16,25 @@
import {
Entity,
EntityName,
CompoundEntityRef,
stringifyEntityRef,
} from '@backstage/catalog-model';
import { useApi } from '@backstage/core-plugin-api';
import { useCallback, useEffect, useState } from 'react';
import { starredEntitiesApiRef } from '../apis';
function getEntityRef(entityOrRef: Entity | EntityName | string): string {
function getEntityRef(
entityOrRef: Entity | CompoundEntityRef | string,
): string {
return typeof entityOrRef === 'string'
? entityOrRef
: stringifyEntityRef(entityOrRef);
}
/** @public */
export function useStarredEntity(entityOrRef: Entity | EntityName | string): {
export function useStarredEntity(
entityOrRef: Entity | CompoundEntityRef | string,
): {
toggleStarredEntity: () => void;
isStarredEntity: boolean;
} {
@@ -14,7 +14,11 @@
* limitations under the License.
*/
import { Entity, EntityName, parseEntityRef } from '@backstage/catalog-model';
import {
Entity,
CompoundEntityRef,
parseEntityRef,
} from '@backstage/catalog-model';
// TODO(freben): This should be returning entity refs instead
/**
@@ -26,7 +30,7 @@ export function getEntityRelations(
entity: Entity | undefined,
relationType: string,
filter?: { kind: string },
): EntityName[] {
): CompoundEntityRef[] {
let entityNames =
entity?.relations
?.filter(r => r.type === relationType)
+2 -2
View File
@@ -16,7 +16,7 @@
import {
Entity,
getEntityName,
getCompoundEntityRef,
RELATION_MEMBER_OF,
RELATION_OWNED_BY,
stringifyEntityRef,
@@ -31,7 +31,7 @@ export function isOwnerOf(owner: Entity, owned: Entity) {
const possibleOwners = new Set(
[
...getEntityRelations(owner, RELATION_MEMBER_OF, { kind: 'group' }),
...(owner ? [getEntityName(owner)] : []),
...(owner ? [getCompoundEntityRef(owner)] : []),
].map(stringifyEntityRef),
);
+3 -3
View File
@@ -7,8 +7,8 @@
import { ApiHolder } from '@backstage/core-plugin-api';
import { BackstagePlugin } from '@backstage/core-plugin-api';
import { CompoundEntityRef } from '@backstage/catalog-model';
import { Entity } from '@backstage/catalog-model';
import { EntityName } from '@backstage/catalog-model';
import { ExternalRouteRef } from '@backstage/core-plugin-api';
import { IconComponent } from '@backstage/core-plugin-api';
import { IndexableDocument } from '@backstage/search-common';
@@ -157,9 +157,9 @@ export interface CatalogTableRow {
resolved: {
name: string;
partOfSystemRelationTitle?: string;
partOfSystemRelations: EntityName[];
partOfSystemRelations: CompoundEntityRef[];
ownedByRelationsTitle?: string;
ownedByRelations: EntityName[];
ownedByRelations: CompoundEntityRef[];
};
}
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { Entity, EntityName } from '@backstage/catalog-model';
import { Entity, CompoundEntityRef } from '@backstage/catalog-model';
/** @public */
export interface CatalogTableRow {
@@ -22,8 +22,8 @@ export interface CatalogTableRow {
resolved: {
name: string;
partOfSystemRelationTitle?: string;
partOfSystemRelations: EntityName[];
partOfSystemRelations: CompoundEntityRef[];
ownedByRelationsTitle?: string;
ownedByRelations: EntityName[];
ownedByRelations: CompoundEntityRef[];
};
}
@@ -13,16 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { EntityName } from '@backstage/catalog-model';
import { CompoundEntityRef } from '@backstage/catalog-model';
export type JsonCodeCoverage = {
metadata: CoverageMetadata;
entity: EntityName;
entity: CompoundEntityRef;
files: Array<FileEntry>;
};
export type JsonCoverageHistory = {
entity: EntityName;
entity: CompoundEntityRef;
history: Array<AggregateCoverage>;
};
+12 -7
View File
@@ -14,20 +14,25 @@
* limitations under the License.
*/
import { EntityName, stringifyEntityRef } from '@backstage/catalog-model';
import {
CompoundEntityRef,
stringifyEntityRef,
} from '@backstage/catalog-model';
import { ResponseError } from '@backstage/errors';
import { JsonCodeCoverage, JsonCoverageHistory } from './types';
import { createApiRef, DiscoveryApi } from '@backstage/core-plugin-api';
export type CodeCoverageApi = {
discovery: DiscoveryApi;
getCoverageForEntity: (entity: EntityName) => Promise<JsonCodeCoverage>;
getCoverageForEntity: (
entity: CompoundEntityRef,
) => Promise<JsonCodeCoverage>;
getFileContentFromEntity: (
entity: EntityName,
entity: CompoundEntityRef,
filePath: string,
) => Promise<string>;
getCoverageHistoryForEntity: (
entity: EntityName,
entity: CompoundEntityRef,
limit?: number,
) => Promise<JsonCoverageHistory>;
};
@@ -59,7 +64,7 @@ export class CodeCoverageRestApi implements CodeCoverageApi {
}
async getCoverageForEntity(
entityName: EntityName,
entityName: CompoundEntityRef,
): Promise<JsonCodeCoverage> {
const entity = encodeURIComponent(stringifyEntityRef(entityName));
return (await this.fetch<JsonCodeCoverage>(
@@ -68,7 +73,7 @@ export class CodeCoverageRestApi implements CodeCoverageApi {
}
async getFileContentFromEntity(
entityName: EntityName,
entityName: CompoundEntityRef,
filePath: string,
): Promise<string> {
const entity = encodeURIComponent(stringifyEntityRef(entityName));
@@ -78,7 +83,7 @@ export class CodeCoverageRestApi implements CodeCoverageApi {
}
async getCoverageHistoryForEntity(
entityName: EntityName,
entityName: CompoundEntityRef,
limit?: number,
): Promise<JsonCoverageHistory> {
const entity = encodeURIComponent(stringifyEntityRef(entityName));
+4 -3
View File
@@ -13,16 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { EntityName } from '@backstage/catalog-model';
import { CompoundEntityRef } from '@backstage/catalog-model';
export type JsonCodeCoverage = {
metadata: CoverageMetadata;
entity: EntityName;
entity: CompoundEntityRef;
files: Array<FileEntry>;
};
export type JsonCoverageHistory = {
entity: EntityName;
entity: CompoundEntityRef;
history: Array<AggregateCoverage>;
};
@@ -16,7 +16,7 @@
import {
Entity,
EntityName,
CompoundEntityRef,
RELATION_OWNED_BY,
} from '@backstage/catalog-model';
import {
@@ -56,7 +56,7 @@ type FossaRow = {
resolved: {
name: string;
ownedByRelationsTitle?: string;
ownedByRelations: EntityName[];
ownedByRelations: CompoundEntityRef[];
loading: boolean;
details?: FindingSummary;
};
+3 -3
View File
@@ -4,8 +4,8 @@
```ts
import { CatalogApi } from '@backstage/catalog-client';
import { CompoundEntityRef } from '@backstage/catalog-model';
import { Config } from '@backstage/config';
import { EntityName } from '@backstage/catalog-model';
import express from 'express';
import { Logger as Logger_2 } from 'winston';
@@ -25,7 +25,7 @@ export class DefaultJenkinsInfoProvider implements JenkinsInfoProvider {
}): DefaultJenkinsInfoProvider;
// (undocumented)
getInstance(opt: {
entityRef: EntityName;
entityRef: CompoundEntityRef;
jobFullName?: string;
}): Promise<JenkinsInfo>;
// (undocumented)
@@ -65,7 +65,7 @@ export interface JenkinsInfo {
export interface JenkinsInfoProvider {
// (undocumented)
getInstance(options: {
entityRef: EntityName;
entityRef: CompoundEntityRef;
jobFullName?: string;
}): Promise<JenkinsInfo>;
}
@@ -15,7 +15,7 @@
*/
import { CatalogApi } from '@backstage/catalog-client';
import { Entity, EntityName } from '@backstage/catalog-model';
import { Entity, CompoundEntityRef } from '@backstage/catalog-model';
import { ConfigReader } from '@backstage/config';
import {
DefaultJenkinsInfoProvider,
@@ -163,7 +163,7 @@ describe('DefaultJenkinsInfoProvider', () => {
getEntityByName: jest.fn(),
} as any as jest.Mocked<CatalogApi>;
const entityRef: EntityName = {
const entityRef: CompoundEntityRef = {
kind: 'Component',
namespace: 'foo',
name: 'bar',
@@ -17,7 +17,7 @@
import { CatalogApi } from '@backstage/catalog-client';
import {
Entity,
EntityName,
CompoundEntityRef,
stringifyEntityRef,
} from '@backstage/catalog-model';
import { Config } from '@backstage/config';
@@ -27,7 +27,7 @@ export interface JenkinsInfoProvider {
/**
* The entity to get the info about.
*/
entityRef: EntityName;
entityRef: CompoundEntityRef;
/**
* A specific job to get. This is only passed in when we know about a job name we are interested in.
*/
@@ -182,7 +182,7 @@ export class DefaultJenkinsInfoProvider implements JenkinsInfoProvider {
}
async getInstance(opt: {
entityRef: EntityName;
entityRef: CompoundEntityRef;
jobFullName?: string;
}): Promise<JenkinsInfo> {
// load entity
@@ -18,7 +18,7 @@ import { createServiceBuilder } from '@backstage/backend-common';
import { Server } from 'http';
import { Logger } from 'winston';
import { createRouter } from './router';
import { EntityName } from '@backstage/catalog-model';
import { CompoundEntityRef } from '@backstage/catalog-model';
import { JenkinsInfo } from './jenkinsInfoProvider';
export interface ServerOptions {
@@ -35,7 +35,9 @@ export async function startStandaloneServer(
const router = await createRouter({
logger,
jenkinsInfoProvider: {
async getInstance(_: { entityRef: EntityName }): Promise<JenkinsInfo> {
async getInstance(_: {
entityRef: CompoundEntityRef;
}): Promise<JenkinsInfo> {
return { baseUrl: 'https://example.com/', jobFullName: 'build-foo' };
},
},
+7 -7
View File
@@ -7,9 +7,9 @@
import { ApiRef } from '@backstage/core-plugin-api';
import { BackstagePlugin } from '@backstage/core-plugin-api';
import type { CompoundEntityRef } from '@backstage/catalog-model';
import { DiscoveryApi } from '@backstage/core-plugin-api';
import { Entity } from '@backstage/catalog-model';
import type { EntityName } from '@backstage/catalog-model';
import { IdentityApi } from '@backstage/core-plugin-api';
import { InfoCardVariants } from '@backstage/core-components';
import { RouteRef } from '@backstage/core-plugin-api';
@@ -48,20 +48,20 @@ export const JENKINS_ANNOTATION = 'jenkins.io/job-full-name';
export interface JenkinsApi {
// Warning: (ae-forgotten-export) The symbol "Build" needs to be exported by the entry point index.d.ts
getBuild(options: {
entity: EntityName;
entity: CompoundEntityRef;
jobFullName: string;
buildNumber: string;
}): Promise<Build>;
// Warning: (ae-forgotten-export) The symbol "Project" needs to be exported by the entry point index.d.ts
getProjects(options: {
entity: EntityName;
entity: CompoundEntityRef;
filter: {
branch?: string;
};
}): Promise<Project[]>;
// (undocumented)
retry(options: {
entity: EntityName;
entity: CompoundEntityRef;
jobFullName: string;
buildNumber: string;
}): Promise<void>;
@@ -82,20 +82,20 @@ export class JenkinsClient implements JenkinsApi {
});
// (undocumented)
getBuild(options: {
entity: EntityName;
entity: CompoundEntityRef;
jobFullName: string;
buildNumber: string;
}): Promise<Build>;
// (undocumented)
getProjects(options: {
entity: EntityName;
entity: CompoundEntityRef;
filter: {
branch?: string;
};
}): Promise<Project[]>;
// (undocumented)
retry(options: {
entity: EntityName;
entity: CompoundEntityRef;
jobFullName: string;
buildNumber: string;
}): Promise<void>;
+7 -7
View File
@@ -19,7 +19,7 @@ import {
DiscoveryApi,
IdentityApi,
} from '@backstage/core-plugin-api';
import type { EntityName } from '@backstage/catalog-model';
import type { CompoundEntityRef } from '@backstage/catalog-model';
import { ResponseError } from '@backstage/errors';
export const jenkinsApiRef = createApiRef<JenkinsApi>({
@@ -80,7 +80,7 @@ export interface JenkinsApi {
*/
getProjects(options: {
/** the entity whose jobs should be retrieved. */
entity: EntityName;
entity: CompoundEntityRef;
/** a filter on jobs. Currently this just takes a branch (and assumes certain structures in jenkins) */
filter: { branch?: string };
}): Promise<Project[]>;
@@ -93,13 +93,13 @@ export interface JenkinsApi {
* TODO: abstract jobFullName (so we could support differentiating between the same named job on multiple instances).
*/
getBuild(options: {
entity: EntityName;
entity: CompoundEntityRef;
jobFullName: string;
buildNumber: string;
}): Promise<Build>;
retry(options: {
entity: EntityName;
entity: CompoundEntityRef;
jobFullName: string;
buildNumber: string;
}): Promise<void>;
@@ -118,7 +118,7 @@ export class JenkinsClient implements JenkinsApi {
}
async getProjects(options: {
entity: EntityName;
entity: CompoundEntityRef;
filter: { branch?: string };
}): Promise<Project[]> {
const { entity, filter } = options;
@@ -157,7 +157,7 @@ export class JenkinsClient implements JenkinsApi {
}
async getBuild(options: {
entity: EntityName;
entity: CompoundEntityRef;
jobFullName: string;
buildNumber: string;
}): Promise<Build> {
@@ -182,7 +182,7 @@ export class JenkinsClient implements JenkinsApi {
}
async retry(options: {
entity: EntityName;
entity: CompoundEntityRef;
jobFullName: string;
buildNumber: string;
}): Promise<void> {
@@ -19,7 +19,7 @@ import { jenkinsApiRef } from '../api';
import { useAsyncPolling } from './useAsyncPolling';
import { errorApiRef, useApi } from '@backstage/core-plugin-api';
import { useEntity } from '@backstage/plugin-catalog-react';
import { getEntityName } from '@backstage/catalog-model';
import { getCompoundEntityRef } from '@backstage/catalog-model';
const INTERVAL_AMOUNT = 1500;
@@ -41,7 +41,7 @@ export function useBuildWithSteps({
const getBuildWithSteps = useCallback(async () => {
try {
const entityName = await getEntityName(entity);
const entityName = await getCompoundEntityRef(entity);
return api.getBuild({ entity: entityName, jobFullName, buildNumber });
} catch (e) {
errorApi.post(e);
+3 -3
View File
@@ -18,7 +18,7 @@ import useAsyncRetry from 'react-use/lib/useAsyncRetry';
import { jenkinsApiRef } from '../api';
import { errorApiRef, useApi } from '@backstage/core-plugin-api';
import { useEntity } from '@backstage/plugin-catalog-react';
import { getEntityName } from '@backstage/catalog-model';
import { getCompoundEntityRef } from '@backstage/catalog-model';
export enum ErrorType {
CONNECTION_ERROR,
@@ -33,7 +33,7 @@ export enum ErrorType {
*/
export function useBuilds({ branch }: { branch?: string } = {}) {
const { entity } = useEntity();
const entityName = getEntityName(entity);
const entityName = getCompoundEntityRef(entity);
const api = useApi(jenkinsApiRef);
const errorApi = useApi(errorApiRef);
@@ -60,7 +60,7 @@ export function useBuilds({ branch }: { branch?: string } = {}) {
} = useAsyncRetry(async () => {
try {
const build = await api.getProjects({
entity: getEntityName(entity),
entity: getCompoundEntityRef(entity),
filter: { branch },
});
@@ -16,7 +16,7 @@
import {
Entity,
getEntityName,
getCompoundEntityRef,
parseEntityRef,
RELATION_OWNED_BY,
RELATION_OWNER_OF,
@@ -55,7 +55,7 @@ export class ScaffolderEntitiesProcessor implements CatalogProcessor {
_location: LocationSpec,
emit: CatalogProcessorEmit,
): Promise<Entity> {
const selfRef = getEntityName(entity);
const selfRef = getCompoundEntityRef(entity);
if (
entity.apiVersion === 'scaffolder.backstage.io/v1beta3' &&
@@ -20,7 +20,7 @@ import {
ANNOTATION_LOCATION,
parseLocationRef,
ANNOTATION_SOURCE_LOCATION,
EntityName,
CompoundEntityRef,
DEFAULT_NAMESPACE,
} from '@backstage/catalog-model';
import { Config } from '@backstage/config';
@@ -91,7 +91,7 @@ export function getEntityBaseUrl(entity: Entity): string | undefined {
* Returns the matching template, or throws a NotFoundError if no such template existed.
*/
export async function findTemplate(options: {
entityRef: EntityName;
entityRef: CompoundEntityRef;
token?: string;
catalogApi: CatalogApi;
}): Promise<TemplateEntityV1beta3 | TemplateEntityV1beta2> {
@@ -27,7 +27,7 @@ import { Logger } from 'winston';
import { DateTime } from 'luxon';
import { PersistenceContext } from './persistence/persistenceContext';
import {
EntityName,
CompoundEntityRef,
parseEntityRef,
stringifyEntityRef,
} from '@backstage/catalog-model';
@@ -99,8 +99,10 @@ export async function createRouter<
});
router.post('/checks/run', async (req, res) => {
const { checks, entities }: { checks: string[]; entities: EntityName[] } =
req.body;
const {
checks,
entities,
}: { checks: string[]; entities: CompoundEntityRef[] } = req.body;
const tasks = entities.map(async entity => {
const entityTriplet =
typeof entity === 'string' ? entity : stringifyEntityRef(entity);
+6 -3
View File
@@ -9,7 +9,7 @@ import { ApiRef } from '@backstage/core-plugin-api';
import { BackstagePlugin } from '@backstage/core-plugin-api';
import { BulkCheckResponse } from '@backstage/plugin-tech-insights-common';
import { CheckResult } from '@backstage/plugin-tech-insights-common';
import { EntityName } from '@backstage/catalog-model';
import { CompoundEntityRef } from '@backstage/catalog-model';
import { default as React_2 } from 'react';
import { RouteRef } from '@backstage/core-plugin-api';
@@ -52,11 +52,14 @@ export interface TechInsightsApi {
) => CheckResultRenderer | undefined;
// (undocumented)
runBulkChecks(
entities: EntityName[],
entities: CompoundEntityRef[],
checks?: Check[],
): Promise<BulkCheckResponse>;
// (undocumented)
runChecks(entityParams: EntityName, checks?: Check[]): Promise<CheckResult[]>;
runChecks(
entityParams: CompoundEntityRef,
checks?: Check[],
): Promise<CheckResult[]>;
}
// @public
@@ -21,7 +21,7 @@ import {
} from '@backstage/plugin-tech-insights-common';
import { Check } from './types';
import { CheckResultRenderer } from '../components/CheckResultRenderer';
import { EntityName } from '@backstage/catalog-model';
import { CompoundEntityRef } from '@backstage/catalog-model';
/**
* {@link @backstage/core-plugin-api#ApiRef} for the {@link TechInsightsApi}
@@ -45,9 +45,12 @@ export interface TechInsightsApi {
description?: string,
) => CheckResultRenderer | undefined;
getAllChecks(): Promise<Check[]>;
runChecks(entityParams: EntityName, checks?: Check[]): Promise<CheckResult[]>;
runChecks(
entityParams: CompoundEntityRef,
checks?: Check[],
): Promise<CheckResult[]>;
runBulkChecks(
entities: EntityName[],
entities: CompoundEntityRef[],
checks?: Check[],
): Promise<BulkCheckResponse>;
}
@@ -22,7 +22,7 @@ import {
import { Check } from './types';
import { DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api';
import { ResponseError } from '@backstage/errors';
import { EntityName } from '@backstage/catalog-model';
import { CompoundEntityRef } from '@backstage/catalog-model';
import {
CheckResultRenderer,
@@ -74,7 +74,7 @@ export class TechInsightsClient implements TechInsightsApi {
}
async runChecks(
entityParams: EntityName,
entityParams: CompoundEntityRef,
checks?: Check[],
): Promise<CheckResult[]> {
const url = await this.discoveryApi.getBaseUrl('tech-insights');
@@ -102,7 +102,7 @@ export class TechInsightsClient implements TechInsightsApi {
}
async runBulkChecks(
entities: EntityName[],
entities: CompoundEntityRef[],
checks?: Check[],
): Promise<BulkCheckResponse> {
const url = await this.discoveryApi.getBaseUrl('tech-insights');
@@ -16,7 +16,7 @@
import { CachedEntityLoader } from './CachedEntityLoader';
import { CatalogClient } from '@backstage/catalog-client';
import { CacheClient } from '@backstage/backend-common';
import { EntityName } from '@backstage/catalog-model';
import { CompoundEntityRef } from '@backstage/catalog-model';
describe('CachedEntityLoader', () => {
const catalog: jest.Mocked<CatalogClient> = {
@@ -28,7 +28,7 @@ describe('CachedEntityLoader', () => {
set: jest.fn(),
} as any;
const entityName: EntityName = {
const entityName: CompoundEntityRef = {
kind: 'component',
namespace: 'default',
name: 'test',
@@ -17,7 +17,7 @@ import { CatalogClient } from '@backstage/catalog-client';
import { CacheClient } from '@backstage/backend-common';
import {
Entity,
EntityName,
CompoundEntityRef,
stringifyEntityRef,
} from '@backstage/catalog-model';
@@ -37,7 +37,7 @@ export class CachedEntityLoader {
}
async load(
entityName: EntityName,
entityName: CompoundEntityRef,
token: string | undefined,
): Promise<Entity | undefined> {
const cacheKey = this.getCacheKey(entityName, token);
@@ -66,7 +66,7 @@ export class CachedEntityLoader {
}
private getCacheKey(
entityName: EntityName,
entityName: CompoundEntityRef,
token: string | undefined,
): string {
const key = ['catalog', stringifyEntityRef(entityName)];
+20 -16
View File
@@ -7,11 +7,11 @@
import { ApiRef } from '@backstage/core-plugin-api';
import { BackstagePlugin } from '@backstage/core-plugin-api';
import { CompoundEntityRef } from '@backstage/catalog-model';
import { Config } from '@backstage/config';
import { CSSProperties } from '@material-ui/styles';
import { DiscoveryApi } from '@backstage/core-plugin-api';
import { Entity } from '@backstage/catalog-model';
import { EntityName } from '@backstage/catalog-model';
import { FetchApi } from '@backstage/core-plugin-api';
import { IdentityApi } from '@backstage/core-plugin-api';
import { PropsWithChildren } from 'react';
@@ -89,7 +89,7 @@ export type DocsTableRow = {
resolved: {
docsUrl: string;
ownedByRelationsTitle: string;
ownedByRelations: EntityName[];
ownedByRelations: CompoundEntityRef[];
};
};
@@ -161,7 +161,7 @@ export const Reader: (props: ReaderProps) => JSX.Element;
// @public
export type ReaderProps = {
entityRef: EntityName;
entityRef: CompoundEntityRef;
withSearch?: boolean;
onReady?: () => void;
};
@@ -187,9 +187,11 @@ export type TabsConfig = TabConfig[];
export interface TechDocsApi {
getApiOrigin(): Promise<string>;
// (undocumented)
getEntityMetadata(entityId: EntityName): Promise<TechDocsEntityMetadata>;
getEntityMetadata(
entityId: CompoundEntityRef,
): Promise<TechDocsEntityMetadata>;
// (undocumented)
getTechDocsMetadata(entityId: EntityName): Promise<TechDocsMetadata>;
getTechDocsMetadata(entityId: CompoundEntityRef): Promise<TechDocsMetadata>;
}
// @public
@@ -208,8 +210,10 @@ export class TechDocsClient implements TechDocsApi {
discoveryApi: DiscoveryApi;
// (undocumented)
getApiOrigin(): Promise<string>;
getEntityMetadata(entityId: EntityName): Promise<TechDocsEntityMetadata>;
getTechDocsMetadata(entityId: EntityName): Promise<TechDocsMetadata>;
getEntityMetadata(
entityId: CompoundEntityRef,
): Promise<TechDocsEntityMetadata>;
getTechDocsMetadata(entityId: CompoundEntityRef): Promise<TechDocsMetadata>;
}
// @public
@@ -297,7 +301,7 @@ export const TechDocsReaderPageHeader: (
// @public
export type TechDocsReaderPageHeaderProps = PropsWithChildren<{
entityRef: EntityName;
entityRef: CompoundEntityRef;
entityMetadata?: TechDocsEntityMetadata;
techDocsMetadata?: TechDocsMetadata;
}>;
@@ -315,7 +319,7 @@ export type TechDocsReaderPageRenderFunction = ({
}: {
techdocsMetadataValue?: TechDocsMetadata | undefined;
entityMetadataValue?: TechDocsEntityMetadata | undefined;
entityRef: EntityName;
entityRef: CompoundEntityRef;
onReady: () => void;
}) => JSX.Element;
@@ -324,7 +328,7 @@ export const TechDocsSearch: (props: TechDocsSearchProps) => JSX.Element;
// @public
export type TechDocsSearchProps = {
entityId: EntityName;
entityId: CompoundEntityRef;
debounceTime?: number;
};
@@ -348,18 +352,18 @@ export interface TechDocsStorageApi {
// (undocumented)
getBaseUrl(
oldBaseUrl: string,
entityId: EntityName,
entityId: CompoundEntityRef,
path: string,
): Promise<string>;
// (undocumented)
getBuilder(): Promise<string>;
// (undocumented)
getEntityDocs(entityId: EntityName, path: string): Promise<string>;
getEntityDocs(entityId: CompoundEntityRef, path: string): Promise<string>;
// (undocumented)
getStorageUrl(): Promise<string>;
// (undocumented)
syncEntityDocs(
entityId: EntityName,
entityId: CompoundEntityRef,
logHandler?: (line: string) => void,
): Promise<SyncResult>;
}
@@ -384,18 +388,18 @@ export class TechDocsStorageClient implements TechDocsStorageApi {
// (undocumented)
getBaseUrl(
oldBaseUrl: string,
entityId: EntityName,
entityId: CompoundEntityRef,
path: string,
): Promise<string>;
// (undocumented)
getBuilder(): Promise<string>;
getEntityDocs(entityId: EntityName, path: string): Promise<string>;
getEntityDocs(entityId: CompoundEntityRef, path: string): Promise<string>;
// (undocumented)
getStorageUrl(): Promise<string>;
// (undocumented)
identityApi: IdentityApi;
syncEntityDocs(
entityId: EntityName,
entityId: CompoundEntityRef,
logHandler?: (line: string) => void,
): Promise<SyncResult>;
}
+5 -2
View File
@@ -17,7 +17,7 @@
import { createDevApp } from '@backstage/dev-utils';
import { NotFoundError } from '@backstage/errors';
import React from 'react';
import { EntityName } from '@backstage/catalog-model';
import { CompoundEntityRef } from '@backstage/catalog-model';
import {
Reader,
SyncResult,
@@ -82,7 +82,10 @@ function createPage({
});
}
async syncEntityDocs(_: EntityName, logHandler?: (line: string) => void) {
async syncEntityDocs(
_: CompoundEntityRef,
logHandler?: (line: string) => void,
) {
if (syncDocsDelay) {
for (let i = 0; i < 10; i++) {
setTimeout(
+8 -6
View File
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { EntityName } from '@backstage/catalog-model';
import { CompoundEntityRef } from '@backstage/catalog-model';
import { TechDocsEntityMetadata, TechDocsMetadata } from './types';
import { createApiRef } from '@backstage/core-plugin-api';
@@ -55,14 +55,14 @@ export interface TechDocsStorageApi {
getApiOrigin(): Promise<string>;
getStorageUrl(): Promise<string>;
getBuilder(): Promise<string>;
getEntityDocs(entityId: EntityName, path: string): Promise<string>;
getEntityDocs(entityId: CompoundEntityRef, path: string): Promise<string>;
syncEntityDocs(
entityId: EntityName,
entityId: CompoundEntityRef,
logHandler?: (line: string) => void,
): Promise<SyncResult>;
getBaseUrl(
oldBaseUrl: string,
entityId: EntityName,
entityId: CompoundEntityRef,
path: string,
): Promise<string>;
}
@@ -77,6 +77,8 @@ export interface TechDocsApi {
* Set to techdocs.requestUrl as the URL for techdocs-backend API.
*/
getApiOrigin(): Promise<string>;
getTechDocsMetadata(entityId: EntityName): Promise<TechDocsMetadata>;
getEntityMetadata(entityId: EntityName): Promise<TechDocsEntityMetadata>;
getTechDocsMetadata(entityId: CompoundEntityRef): Promise<TechDocsMetadata>;
getEntityMetadata(
entityId: CompoundEntityRef,
): Promise<TechDocsEntityMetadata>;
}
+11 -6
View File
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { EntityName } from '@backstage/catalog-model';
import { CompoundEntityRef } from '@backstage/catalog-model';
import { Config } from '@backstage/config';
import {
DiscoveryApi,
@@ -62,7 +62,9 @@ export class TechDocsClient implements TechDocsApi {
*
* @param entityId - Object containing entity data like name, namespace, etc.
*/
async getTechDocsMetadata(entityId: EntityName): Promise<TechDocsMetadata> {
async getTechDocsMetadata(
entityId: CompoundEntityRef,
): Promise<TechDocsMetadata> {
const { kind, namespace, name } = entityId;
const apiOrigin = await this.getApiOrigin();
@@ -84,7 +86,7 @@ export class TechDocsClient implements TechDocsApi {
* @param entityId - Object containing entity data like name, namespace, etc.
*/
async getEntityMetadata(
entityId: EntityName,
entityId: CompoundEntityRef,
): Promise<TechDocsEntityMetadata> {
const { kind, namespace, name } = entityId;
@@ -149,7 +151,10 @@ export class TechDocsStorageClient implements TechDocsStorageApi {
* @returns HTML content of the docs page as string
* @throws Throws error when the page is not found.
*/
async getEntityDocs(entityId: EntityName, path: string): Promise<string> {
async getEntityDocs(
entityId: CompoundEntityRef,
path: string,
): Promise<string> {
const { kind, namespace, name } = entityId;
const storageUrl = await this.getStorageUrl();
@@ -190,7 +195,7 @@ export class TechDocsStorageClient implements TechDocsStorageApi {
* @throws Throws error on error from sync endpoint in Techdocs Backend
*/
async syncEntityDocs(
entityId: EntityName,
entityId: CompoundEntityRef,
logHandler: (line: string) => void = () => {},
): Promise<SyncResult> {
const { kind, namespace, name } = entityId;
@@ -243,7 +248,7 @@ export class TechDocsStorageClient implements TechDocsStorageApi {
async getBaseUrl(
oldBaseUrl: string,
entityId: EntityName,
entityId: CompoundEntityRef,
path: string,
): Promise<string> {
const { kind, namespace, name } = entityId;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { Entity, EntityName } from '@backstage/catalog-model';
import { Entity, CompoundEntityRef } from '@backstage/catalog-model';
/**
* Generic representing the metadata structure for a docs table row.
@@ -26,6 +26,6 @@ export type DocsTableRow = {
resolved: {
docsUrl: string;
ownedByRelationsTitle: string;
ownedByRelations: EntityName[];
ownedByRelations: CompoundEntityRef[];
};
};
@@ -34,7 +34,7 @@ import {
alpha,
} from '@material-ui/core';
import { EntityName } from '@backstage/catalog-model';
import { CompoundEntityRef } from '@backstage/catalog-model';
import { useApi, configApiRef } from '@backstage/core-plugin-api';
import { scmIntegrationsApiRef } from '@backstage/integration-react';
import { BackstageTheme } from '@backstage/theme';
@@ -68,7 +68,7 @@ import { useReaderState } from './useReaderState';
* @public
*/
export type ReaderProps = {
entityRef: EntityName;
entityRef: CompoundEntityRef;
withSearch?: boolean;
onReady?: () => void;
};
@@ -95,7 +95,7 @@ const TechDocsReaderContext = createContext<TechDocsReaderValue>(
const TechDocsReaderProvider = ({
children,
entityRef,
}: PropsWithChildren<{ entityRef: EntityName }>) => {
}: PropsWithChildren<{ entityRef: CompoundEntityRef }>) => {
const { '*': path } = useParams();
const { kind, namespace, name } = entityRef;
const value = useReaderState(kind, namespace, name, path);
@@ -116,7 +116,7 @@ const TechDocsReaderProvider = ({
* @internal
*/
export const withTechDocsReaderProvider =
<T extends {}>(Component: ComponentType<T>, entityRef: EntityName) =>
<T extends {}>(Component: ComponentType<T>, entityRef: CompoundEntityRef) =>
(props: T) =>
(
<TechDocsReaderProvider entityRef={entityRef}>
@@ -157,7 +157,9 @@ const headings: TypographyHeadingsKeys[] = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
* todo: Make public or stop exporting (see others: "altReaderExperiments")
* @internal
*/
export const useTechDocsReaderDom = (entityRef: EntityName): Element | null => {
export const useTechDocsReaderDom = (
entityRef: CompoundEntityRef,
): Element | null => {
const navigate = useNavigate();
const theme = useTheme<BackstageTheme>();
const techdocsStorageApi = useApi(techdocsStorageApiRef);
@@ -322,7 +324,7 @@ export const useTechDocsReaderDom = (entityRef: EntityName): Element | null => {
--md-source-version-icon: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M2.5 7.775V2.75a.25.25 0 0 1 .25-.25h5.025a.25.25 0 0 1 .177.073l6.25 6.25a.25.25 0 0 1 0 .354l-5.025 5.025a.25.25 0 0 1-.354 0l-6.25-6.25a.25.25 0 0 1-.073-.177zm-1.5 0V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 0 1 0 2.474l-5.026 5.026a1.75 1.75 0 0 1-2.474 0l-6.25-6.25A1.75 1.75 0 0 1 1 7.775zM6 5a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>');
--md-version-icon: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--! Font Awesome Free 6.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc.--><path d="m310.6 246.6-127.1 128c-7.1 6.3-15.3 9.4-23.5 9.4s-16.38-3.125-22.63-9.375l-127.1-128C.224 237.5-2.516 223.7 2.438 211.8S19.07 192 32 192h255.1c12.94 0 24.62 7.781 29.58 19.75s3.12 25.75-6.08 34.85z"/></svg>');
}
:host > * {
/* CODE */
--md-code-fg-color: ${theme.palette.text.primary};
@@ -438,7 +440,7 @@ export const useTechDocsReaderDom = (entityRef: EntityName): Element | null => {
.md-main__inner {
margin-top: 0;
}
.md-sidebar {
height: calc(100% - 100px);
position: fixed;
@@ -450,13 +452,13 @@ export const useTechDocsReaderDom = (entityRef: EntityName): Element | null => {
.md-sidebar--secondary {
right: ${theme.spacing(3)}px;
}
.md-content {
max-width: calc(100% - 16rem * 2);
margin-left: 16rem;
margin-bottom: 50px;
}
.md-footer {
position: fixed;
bottom: 0px;
@@ -471,7 +473,7 @@ export const useTechDocsReaderDom = (entityRef: EntityName): Element | null => {
.md-dialog {
background-color: unset;
}
@media screen and (max-width: 76.1875em) {
.md-nav {
transition: none !important;
@@ -567,7 +569,7 @@ export const useTechDocsReaderDom = (entityRef: EntityName): Element | null => {
}),
injectCss({
// Typeset
css: `
css: `
.md-typeset {
font-size: var(--md-typeset-font-size);
}
@@ -600,11 +602,11 @@ export const useTechDocsReaderDom = (entityRef: EntityName): Element | null => {
.md-typeset .md-content__button {
color: var(--md-default-fg-color);
}
.md-typeset hr {
border-bottom: 0.05rem dotted ${theme.palette.divider};
}
.md-typeset details {
font-size: var(--md-typeset-font-size) !important;
}
@@ -621,7 +623,7 @@ export const useTechDocsReaderDom = (entityRef: EntityName): Element | null => {
.md-typeset details[open] > summary:after {
transform: rotate(90deg) translateX(-50%) !important;
}
.md-typeset blockquote {
color: var(--md-default-fg-color--light);
border-left: 0.2rem solid var(--md-default-fg-color--light);
@@ -667,13 +669,13 @@ export const useTechDocsReaderDom = (entityRef: EntityName): Element | null => {
.highlight .md-clipboard:after {
content: unset;
}
.highlight .nx {
color: ${isDarkTheme ? '#ff53a3' : '#ec407a'};
}
/* CODE HILITE */
.codehilite .gd {
.codehilite .gd {
background-color: ${
isDarkTheme ? 'rgba(248,81,73,0.65)' : '#fdd'
};
@@ -21,12 +21,12 @@ import useAsync from 'react-use/lib/useAsync';
import { techdocsApiRef } from '../../api';
import { LegacyTechDocsPage } from './LegacyTechDocsPage';
import { TechDocsEntityMetadata, TechDocsMetadata } from '../../types';
import { EntityName } from '@backstage/catalog-model';
import { CompoundEntityRef } from '@backstage/catalog-model';
import { useApi, useApp } from '@backstage/core-plugin-api';
import { Page } from '@backstage/core-components';
/**
* Helper function that gives the children of {@link TechDocsReaderPage} acccess to techdocs and entity metadata
* Helper function that gives the children of {@link TechDocsReaderPage} access to techdocs and entity metadata
*
* @public
*/
@@ -37,7 +37,7 @@ export type TechDocsReaderPageRenderFunction = ({
}: {
techdocsMetadataValue?: TechDocsMetadata | undefined;
entityMetadataValue?: TechDocsEntityMetadata | undefined;
entityRef: EntityName;
entityRef: CompoundEntityRef;
onReady: () => void;
}) => JSX.Element;
@@ -19,7 +19,7 @@ import CodeIcon from '@material-ui/icons/Code';
import { useRouteRef } from '@backstage/core-plugin-api';
import { Header, HeaderLabel } from '@backstage/core-components';
import { EntityName, RELATION_OWNED_BY } from '@backstage/catalog-model';
import { CompoundEntityRef, RELATION_OWNED_BY } from '@backstage/catalog-model';
import {
EntityRefLink,
EntityRefLinks,
@@ -35,7 +35,7 @@ import { TechDocsEntityMetadata, TechDocsMetadata } from '../../types';
* @public
*/
export type TechDocsReaderPageHeaderProps = PropsWithChildren<{
entityRef: EntityName;
entityRef: CompoundEntityRef;
entityMetadata?: TechDocsEntityMetadata;
techDocsMetadata?: TechDocsMetadata;
}>;
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { EntityName } from '@backstage/catalog-model';
import { CompoundEntityRef } from '@backstage/catalog-model';
import useAsyncRetry from 'react-use/lib/useAsyncRetry';
import { AsyncState } from 'react-use/lib/useAsync';
import { techdocsStorageApiRef } from '../../api';
@@ -22,7 +22,7 @@ import { useApi } from '@backstage/core-plugin-api';
export type RawPage = {
content: string;
path: string;
entityId: EntityName;
entityId: CompoundEntityRef;
};
export function useRawPage(
@@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { EntityName } from '@backstage/catalog-model';
import { CompoundEntityRef } from '@backstage/catalog-model';
import { TechDocsStorageApi } from '../../api';
import type { Transformer } from './transformer';
type AddBaseUrlOptions = {
techdocsStorageApi: TechDocsStorageApi;
entityId: EntityName;
entityId: CompoundEntityRef;
path: string;
};
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { EntityName } from '@backstage/catalog-model';
import { CompoundEntityRef } from '@backstage/catalog-model';
import { SearchContextProvider, useSearch } from '@backstage/plugin-search';
import {
makeStyles,
@@ -42,7 +42,7 @@ const useStyles = makeStyles({
* @public
*/
export type TechDocsSearchProps = {
entityId: EntityName;
entityId: CompoundEntityRef;
debounceTime?: number;
};
+2 -2
View File
@@ -4,8 +4,8 @@
```ts
import { CatalogApi } from '@backstage/catalog-client';
import { CompoundEntityRef } from '@backstage/catalog-model';
import { Config } from '@backstage/config';
import { EntityName } from '@backstage/catalog-model';
import express from 'express';
import { Logger as Logger_2 } from 'winston';
import { ScmIntegrations } from '@backstage/integration';
@@ -19,7 +19,7 @@ export function createTodoParser(options?: TodoParserOptions): TodoParser;
// @public (undocumented)
export type ListTodosRequest = {
entity?: EntityName;
entity?: CompoundEntityRef;
offset?: number;
limit?: number;
orderBy?: {
+2 -2
View File
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { EntityName, parseEntityRef } from '@backstage/catalog-model';
import { CompoundEntityRef, parseEntityRef } from '@backstage/catalog-model';
import { InputError } from '@backstage/errors';
import express from 'express';
import Router from 'express-promise-router';
@@ -52,7 +52,7 @@ export async function createRouter(
if (entityRef && typeof entityRef !== 'string') {
throw new InputError(`entity query must be a string`);
}
let entity: EntityName | undefined = undefined;
let entity: CompoundEntityRef | undefined = undefined;
if (entityRef) {
try {
entity = parseEntityRef(entityRef);
+2 -2
View File
@@ -14,12 +14,12 @@
* limitations under the License.
*/
import { EntityName } from '@backstage/catalog-model';
import { CompoundEntityRef } from '@backstage/catalog-model';
import { TodoItem } from '../lib';
/** @public */
export type ListTodosRequest = {
entity?: EntityName;
entity?: CompoundEntityRef;
offset?: number;
limit?: number;
orderBy?: {