Merge pull request #8620 from goenning/go/expose-apiref

expose techInsightsApiRef
This commit is contained in:
Patrik Oldsberg
2021-12-28 14:11:31 +01:00
committed by GitHub
7 changed files with 69 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-tech-insights': patch
---
Export `techInsightsApiRef` and associated types.
+37
View File
@@ -5,12 +5,49 @@
```ts
/// <reference types="react" />
import { ApiRef } from '@backstage/core-plugin-api';
import { BackstagePlugin } from '@backstage/core-plugin-api';
import { CheckResult } from '@backstage/plugin-tech-insights-common';
import { EntityName } from '@backstage/catalog-model';
import { default as React_2 } from 'react';
import { RouteRef } from '@backstage/core-plugin-api';
// @public
export type Check = {
id: string;
type: string;
name: string;
description: string;
factIds: string[];
};
// @public
export type CheckResultRenderer = {
type: string;
title: string;
description: string;
component: React_2.ReactElement;
};
// @public (undocumented)
export const EntityTechInsightsScorecardContent: () => JSX.Element;
// @public
export interface TechInsightsApi {
// (undocumented)
getAllChecks(): Promise<Check[]>;
// (undocumented)
getScorecardsDefinition: (
type: string,
value: CheckResult[],
) => CheckResultRenderer | undefined;
// (undocumented)
runChecks(entityParams: EntityName, checks?: Check[]): Promise<CheckResult[]>;
}
// @public
export const techInsightsApiRef: ApiRef<TechInsightsApi>;
// @public (undocumented)
export const techInsightsPlugin: BackstagePlugin<
{
+1
View File
@@ -35,6 +35,7 @@
"react-use": "^17.2.4"
},
"peerDependencies": {
"@types/react": "^16.13.1 || ^17.0.0",
"react": "^16.13.1 || ^17.0.0"
},
"devDependencies": {
@@ -20,10 +20,20 @@ import { Check } from './types';
import { CheckResultRenderer } from '../components/CheckResultRenderer';
import { EntityName } from '@backstage/catalog-model';
/**
* {@link @backstage/core-plugin-api#ApiRef} for the {@link TechInsightsApi}
*
* @public
*/
export const techInsightsApiRef = createApiRef<TechInsightsApi>({
id: 'plugin.techinsights.service',
});
/**
* API client interface for the Tech Insights plugin
*
* @public
*/
export interface TechInsightsApi {
getScorecardsDefinition: (
type: string,
+6
View File
@@ -13,6 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Represents a single check defined on the TechInsights backend.
*
* @public
*/
export type Check = {
id: string;
type: string;
@@ -18,6 +18,11 @@ import { CheckResult } from '@backstage/plugin-tech-insights-common';
import React from 'react';
import { BooleanCheck } from './BooleanCheck';
/**
* Defines a react component that is responsible for rendering a results of a given type.
*
* @public
*/
export type CheckResultRenderer = {
type: string;
title: string;
+5
View File
@@ -17,3 +17,8 @@ export {
techInsightsPlugin,
EntityTechInsightsScorecardContent,
} from './plugin';
export { techInsightsApiRef } from './api/TechInsightsApi';
export type { TechInsightsApi } from './api/TechInsightsApi';
export type { Check } from './api/types';
export type { CheckResultRenderer } from './components/CheckResultRenderer';