From d83079fc11f11fae4817615ba271d144ec4082dc Mon Sep 17 00:00:00 2001 From: goenning Date: Thu, 23 Dec 2021 16:04:38 +0000 Subject: [PATCH 1/4] expose techInsightsApiRef Signed-off-by: goenning --- .changeset/slimy-socks-pump.md | 5 +++++ plugins/tech-insights/api-report.md | 10 ++++++++++ plugins/tech-insights/src/index.ts | 2 ++ 3 files changed, 17 insertions(+) create mode 100644 .changeset/slimy-socks-pump.md diff --git a/.changeset/slimy-socks-pump.md b/.changeset/slimy-socks-pump.md new file mode 100644 index 0000000000..7fae7da78a --- /dev/null +++ b/.changeset/slimy-socks-pump.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-tech-insights': patch +--- + +expose apiRef diff --git a/plugins/tech-insights/api-report.md b/plugins/tech-insights/api-report.md index e7f30a2b30..279545091c 100644 --- a/plugins/tech-insights/api-report.md +++ b/plugins/tech-insights/api-report.md @@ -5,12 +5,22 @@ ```ts /// +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 (undocumented) export const EntityTechInsightsScorecardContent: () => JSX.Element; +// Warning: (ae-forgotten-export) The symbol "TechInsightsApi" needs to be exported by the entry point index.d.ts +// Warning: (ae-missing-release-tag) "techInsightsApiRef" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export const techInsightsApiRef: ApiRef; + // @public (undocumented) export const techInsightsPlugin: BackstagePlugin< { diff --git a/plugins/tech-insights/src/index.ts b/plugins/tech-insights/src/index.ts index 273c11fd71..a6a4bee3e3 100644 --- a/plugins/tech-insights/src/index.ts +++ b/plugins/tech-insights/src/index.ts @@ -17,3 +17,5 @@ export { techInsightsPlugin, EntityTechInsightsScorecardContent, } from './plugin'; + +export { techInsightsApiRef } from './api/TechInsightsApi'; From c75c918048743cdbed58fde99f8647d9b845acec Mon Sep 17 00:00:00 2001 From: goenning Date: Thu, 23 Dec 2021 16:24:29 +0000 Subject: [PATCH 2/4] add @types/react dependency Signed-off-by: goenning --- plugins/tech-insights/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/tech-insights/package.json b/plugins/tech-insights/package.json index 9466433b8e..b238ddaafd 100644 --- a/plugins/tech-insights/package.json +++ b/plugins/tech-insights/package.json @@ -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": { From d85f2850f341bba1c5d84fa3aa246445e8c93644 Mon Sep 17 00:00:00 2001 From: Guilherme Oenning Date: Tue, 28 Dec 2021 10:06:50 +0000 Subject: [PATCH 3/4] Update .changeset/slimy-socks-pump.md Co-authored-by: Patrik Oldsberg Signed-off-by: goenning --- .changeset/slimy-socks-pump.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/slimy-socks-pump.md b/.changeset/slimy-socks-pump.md index 7fae7da78a..f7252340f1 100644 --- a/.changeset/slimy-socks-pump.md +++ b/.changeset/slimy-socks-pump.md @@ -2,4 +2,4 @@ '@backstage/plugin-tech-insights': patch --- -expose apiRef +Export `techInsightsApiRef` and associated types. From a69651d69d4451130fba9ed6b0752c422f464867 Mon Sep 17 00:00:00 2001 From: goenning Date: Tue, 28 Dec 2021 10:45:23 +0000 Subject: [PATCH 4/4] add documentation to exported types Signed-off-by: goenning --- plugins/tech-insights/api-report.md | 35 ++++++++++++++++--- .../tech-insights/src/api/TechInsightsApi.ts | 10 ++++++ plugins/tech-insights/src/api/types.ts | 6 ++++ .../src/components/CheckResultRenderer.tsx | 5 +++ plugins/tech-insights/src/index.ts | 3 ++ 5 files changed, 55 insertions(+), 4 deletions(-) diff --git a/plugins/tech-insights/api-report.md b/plugins/tech-insights/api-report.md index 279545091c..1849508f63 100644 --- a/plugins/tech-insights/api-report.md +++ b/plugins/tech-insights/api-report.md @@ -12,13 +12,40 @@ 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; -// Warning: (ae-forgotten-export) The symbol "TechInsightsApi" needs to be exported by the entry point index.d.ts -// Warning: (ae-missing-release-tag) "techInsightsApiRef" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) +// @public +export interface TechInsightsApi { + // (undocumented) + getAllChecks(): Promise; + // (undocumented) + getScorecardsDefinition: ( + type: string, + value: CheckResult[], + ) => CheckResultRenderer | undefined; + // (undocumented) + runChecks(entityParams: EntityName, checks?: Check[]): Promise; +} + +// @public export const techInsightsApiRef: ApiRef; // @public (undocumented) diff --git a/plugins/tech-insights/src/api/TechInsightsApi.ts b/plugins/tech-insights/src/api/TechInsightsApi.ts index d3ff9ac2ff..6c5f272e7f 100644 --- a/plugins/tech-insights/src/api/TechInsightsApi.ts +++ b/plugins/tech-insights/src/api/TechInsightsApi.ts @@ -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({ id: 'plugin.techinsights.service', }); +/** + * API client interface for the Tech Insights plugin + * + * @public + */ export interface TechInsightsApi { getScorecardsDefinition: ( type: string, diff --git a/plugins/tech-insights/src/api/types.ts b/plugins/tech-insights/src/api/types.ts index 20071ba0c9..10dfa06420 100644 --- a/plugins/tech-insights/src/api/types.ts +++ b/plugins/tech-insights/src/api/types.ts @@ -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; diff --git a/plugins/tech-insights/src/components/CheckResultRenderer.tsx b/plugins/tech-insights/src/components/CheckResultRenderer.tsx index 60e0fad9c5..d57d547384 100644 --- a/plugins/tech-insights/src/components/CheckResultRenderer.tsx +++ b/plugins/tech-insights/src/components/CheckResultRenderer.tsx @@ -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; diff --git a/plugins/tech-insights/src/index.ts b/plugins/tech-insights/src/index.ts index a6a4bee3e3..b59ac453ce 100644 --- a/plugins/tech-insights/src/index.ts +++ b/plugins/tech-insights/src/index.ts @@ -19,3 +19,6 @@ export { } 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';