well, let's clean up some more

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-08-18 15:42:17 +02:00
parent e195112c5c
commit f6be17460d
17 changed files with 101 additions and 114 deletions
+8
View File
@@ -0,0 +1,8 @@
---
'@backstage/plugin-kafka': patch
'@backstage/plugin-kafka-backend': patch
'@backstage/plugin-lighthouse': patch
'@backstage/plugin-proxy-backend': patch
---
Minor API signatures cleanup
+8 -3
View File
@@ -7,9 +7,14 @@ import { Config } from '@backstage/config';
import express from 'express';
import { Logger } from 'winston';
// Warning: (ae-forgotten-export) The symbol "RouterOptions" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "createRouter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export function createRouter(options: RouterOptions): Promise<express.Router>;
// @public (undocumented)
export interface RouterOptions {
// (undocumented)
config: Config;
// (undocumented)
logger: Logger;
}
```
+1
View File
@@ -20,4 +20,5 @@
* @packageDocumentation
*/
export type { RouterOptions } from './service/router';
export { createRouter } from './service/router';
@@ -23,6 +23,7 @@ import { KafkaApi, KafkaJsApiImpl } from './KafkaApi';
import _ from 'lodash';
import { getClusterDetails } from '../config/ClusterReader';
/** @public */
export interface RouterOptions {
logger: Logger;
config: Config;
@@ -84,6 +85,7 @@ export const makeRouter = (
return router;
};
/** @public */
export async function createRouter(
options: RouterOptions,
): Promise<express.Router> {
+2 -13
View File
@@ -9,26 +9,18 @@ import { BackstagePlugin } from '@backstage/core-plugin-api';
import { Entity } from '@backstage/catalog-model';
import { RouteRef } from '@backstage/core-plugin-api';
// Warning: (ae-missing-release-tag) "EntityKafkaContent" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const EntityKafkaContent: (_props: {}) => JSX.Element;
export const EntityKafkaContent: () => JSX.Element;
// Warning: (ae-missing-release-tag) "isPluginApplicableToEntity" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
const isPluginApplicableToEntity: (entity: Entity) => boolean;
export { isPluginApplicableToEntity as isKafkaAvailable };
export { isPluginApplicableToEntity };
// Warning: (ae-missing-release-tag) "KAFKA_CONSUMER_GROUP_ANNOTATION" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const KAFKA_CONSUMER_GROUP_ANNOTATION =
'kafka.apache.org/consumer-groups';
// Warning: (ae-missing-release-tag) "kafkaPlugin" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
const kafkaPlugin: BackstagePlugin<
{
@@ -40,9 +32,6 @@ const kafkaPlugin: BackstagePlugin<
export { kafkaPlugin };
export { kafkaPlugin as plugin };
// Warning: (ae-forgotten-export) The symbol "Props" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "Router" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const Router: (_props: Props) => JSX.Element;
export const Router: () => JSX.Element;
```
+3 -3
View File
@@ -22,12 +22,12 @@ import { KAFKA_CONSUMER_GROUP_ANNOTATION } from './constants';
import { KafkaTopicsForConsumer } from './components/ConsumerGroupOffsets/ConsumerGroupOffsets';
import { MissingAnnotationEmptyState } from '@backstage/core-components';
/** @public */
export const isPluginApplicableToEntity = (entity: Entity) =>
Boolean(entity.metadata.annotations?.[KAFKA_CONSUMER_GROUP_ANNOTATION]);
type Props = {};
export const Router = (_props: Props) => {
/** @public */
export const Router = () => {
const { entity } = useEntity();
if (!isPluginApplicableToEntity(entity)) {
+3
View File
@@ -13,6 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** @public */
export const KAFKA_CONSUMER_GROUP_ANNOTATION =
'kafka.apache.org/consumer-groups';
export const KAFKA_DASHBOARD_URL = 'kafka.apache.org/dashboard-urls';
+3
View File
@@ -26,10 +26,12 @@ import {
} from '@backstage/core-plugin-api';
import { KafkaDashboardClient } from './api/KafkaDashboardClient';
/** @public */
export const rootCatalogKafkaRouteRef = createRouteRef({
id: 'kafka',
});
/** @public */
export const kafkaPlugin = createPlugin({
id: 'kafka',
apis: [
@@ -50,6 +52,7 @@ export const kafkaPlugin = createPlugin({
},
});
/** @public */
export const EntityKafkaContent = kafkaPlugin.provide(
createRoutableExtension({
name: 'EntityKafkaContent',
+17 -64
View File
@@ -12,14 +12,19 @@ import { Entity } from '@backstage/catalog-model';
import { InfoCardVariants } from '@backstage/core-components';
import { RouteRef } from '@backstage/core-plugin-api';
// Warning: (ae-missing-release-tag) "Audit" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type Audit = AuditRunning | AuditFailed | AuditCompleted;
// Warning: (ae-forgotten-export) The symbol "AuditBase" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "AuditCompleted" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export interface AuditBase {
// (undocumented)
id: string;
// (undocumented)
timeCreated: string;
// (undocumented)
url: string;
}
// @public (undocumented)
export interface AuditCompleted extends AuditBase {
// (undocumented)
@@ -32,8 +37,6 @@ export interface AuditCompleted extends AuditBase {
timeCompleted: string;
}
// Warning: (ae-missing-release-tag) "AuditFailed" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export interface AuditFailed extends AuditBase {
// (undocumented)
@@ -42,38 +45,24 @@ export interface AuditFailed extends AuditBase {
timeCompleted: string;
}
// Warning: (ae-missing-release-tag) "AuditRunning" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export interface AuditRunning extends AuditBase {
// (undocumented)
status: 'RUNNING';
}
// Warning: (ae-forgotten-export) The symbol "Props" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "EmbeddedRouter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const EmbeddedRouter: (_props: Props) => JSX.Element;
export const EmbeddedRouter: () => JSX.Element;
// Warning: (ae-missing-release-tag) "EntityLastLighthouseAuditCard" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const EntityLastLighthouseAuditCard: ({
dense,
variant,
}: {
export const EntityLastLighthouseAuditCard: (props: {
dense?: boolean | undefined;
variant?: InfoCardVariants | undefined;
}) => JSX.Element;
// Warning: (ae-missing-release-tag) "EntityLighthouseContent" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const EntityLighthouseContent: (_props: {}) => JSX.Element;
export const EntityLighthouseContent: () => JSX.Element;
// Warning: (ae-missing-release-tag) "FetchError" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export class FetchError extends Error {
// (undocumented)
@@ -82,15 +71,11 @@ export class FetchError extends Error {
get name(): string;
}
// Warning: (ae-missing-release-tag) "isLighthouseAvailable" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
const isLighthouseAvailable: (entity: Entity) => boolean;
export { isLighthouseAvailable };
export { isLighthouseAvailable as isPluginApplicableToEntity };
// Warning: (ae-missing-release-tag) "LASListRequest" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export interface LASListRequest {
// (undocumented)
@@ -99,8 +84,6 @@ export interface LASListRequest {
offset?: number;
}
// Warning: (ae-missing-release-tag) "LASListResponse" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export interface LASListResponse<Item> {
// (undocumented)
@@ -113,19 +96,12 @@ export interface LASListResponse<Item> {
total: number;
}
// Warning: (ae-missing-release-tag) "LastLighthouseAuditCard" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const LastLighthouseAuditCard: ({
dense,
variant,
}: {
dense?: boolean | undefined;
variant?: InfoCardVariants | undefined;
export const LastLighthouseAuditCard: (props: {
dense?: boolean;
variant?: InfoCardVariants;
}) => JSX.Element;
// Warning: (ae-missing-release-tag) "LighthouseApi" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type LighthouseApi = {
url: string;
@@ -135,13 +111,9 @@ export type LighthouseApi = {
getWebsiteByUrl: (websiteUrl: string) => Promise<Website>;
};
// Warning: (ae-missing-release-tag) "lighthouseApiRef" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const lighthouseApiRef: ApiRef<LighthouseApi>;
// Warning: (ae-missing-release-tag) "LighthouseCategoryAbbr" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export interface LighthouseCategoryAbbr {
// (undocumented)
@@ -152,8 +124,6 @@ export interface LighthouseCategoryAbbr {
title: string;
}
// Warning: (ae-missing-release-tag) "LighthouseCategoryId" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type LighthouseCategoryId =
| 'pwa'
@@ -162,13 +132,9 @@ export type LighthouseCategoryId =
| 'accessibility'
| 'best-practices';
// Warning: (ae-missing-release-tag) "LighthousePage" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const LighthousePage: () => JSX.Element;
// Warning: (ae-missing-release-tag) "lighthousePlugin" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
const lighthousePlugin: BackstagePlugin<
{
@@ -181,8 +147,6 @@ const lighthousePlugin: BackstagePlugin<
export { lighthousePlugin };
export { lighthousePlugin as plugin };
// Warning: (ae-missing-release-tag) "LighthouseRestApi" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export class LighthouseRestApi implements LighthouseApi {
constructor(url: string);
@@ -193,23 +157,16 @@ export class LighthouseRestApi implements LighthouseApi {
// (undocumented)
getWebsiteForAuditId(auditId: string): Promise<Website>;
// (undocumented)
getWebsiteList({
limit,
offset,
}?: LASListRequest): Promise<WebsiteListResponse>;
getWebsiteList(options?: LASListRequest): Promise<WebsiteListResponse>;
// (undocumented)
triggerAudit(payload: TriggerAuditPayload): Promise<Audit>;
// (undocumented)
url: string;
}
// Warning: (ae-missing-release-tag) "Router" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const Router: () => JSX.Element;
// Warning: (ae-missing-release-tag) "TriggerAuditPayload" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export interface TriggerAuditPayload {
// (undocumented)
@@ -224,8 +181,6 @@ export interface TriggerAuditPayload {
url: string;
}
// Warning: (ae-missing-release-tag) "Website" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export interface Website {
// (undocumented)
@@ -236,8 +191,6 @@ export interface Website {
url: string;
}
// Warning: (ae-missing-release-tag) "WebsiteListResponse" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type WebsiteListResponse = LASListResponse<Website>;
```
+4 -3
View File
@@ -25,9 +25,11 @@ import { LIGHTHOUSE_WEBSITE_URL_ANNOTATION } from '../constants';
import { AuditListForEntity } from './components/AuditList/AuditListForEntity';
import { MissingAnnotationEmptyState } from '@backstage/core-components';
/** @public */
export const isLighthouseAvailable = (entity: Entity) =>
Boolean(entity.metadata.annotations?.[LIGHTHOUSE_WEBSITE_URL_ANNOTATION]);
/** @public */
export const Router = () => (
<Routes>
<Route path="/" element={<AuditList />} />
@@ -36,9 +38,8 @@ export const Router = () => (
</Routes>
);
type Props = {};
export const EmbeddedRouter = (_props: Props) => {
/** @public */
export const EmbeddedRouter = () => {
const { entity } = useEntity();
if (!isLighthouseAvailable(entity)) {
+21 -5
View File
@@ -17,6 +17,7 @@
import { Config } from '@backstage/config';
import { createApiRef } from '@backstage/core-plugin-api';
/** @public */
export type LighthouseCategoryId =
| 'pwa'
| 'seo'
@@ -24,17 +25,20 @@ export type LighthouseCategoryId =
| 'accessibility'
| 'best-practices';
/** @public */
export interface LighthouseCategoryAbbr {
id: LighthouseCategoryId;
score: number;
title: string;
}
/** @public */
export interface LASListRequest {
offset?: number;
limit?: number;
}
/** @public */
export interface LASListResponse<Item> {
items: Item[];
total: number;
@@ -42,21 +46,25 @@ export interface LASListResponse<Item> {
limit: number;
}
interface AuditBase {
/** @public */
export interface AuditBase {
id: string;
url: string;
timeCreated: string;
}
/** @public */
export interface AuditRunning extends AuditBase {
status: 'RUNNING';
}
/** @public */
export interface AuditFailed extends AuditBase {
status: 'FAILED';
timeCompleted: string;
}
/** @public */
export interface AuditCompleted extends AuditBase {
status: 'COMPLETED';
timeCompleted: string;
@@ -64,16 +72,20 @@ export interface AuditCompleted extends AuditBase {
categories: Record<LighthouseCategoryId, LighthouseCategoryAbbr>;
}
/** @public */
export type Audit = AuditRunning | AuditFailed | AuditCompleted;
/** @public */
export interface Website {
url: string;
audits: Audit[];
lastAudit: Audit;
}
/** @public */
export type WebsiteListResponse = LASListResponse<Website>;
/** @public */
export interface TriggerAuditPayload {
url: string;
options: {
@@ -85,6 +97,7 @@ export interface TriggerAuditPayload {
};
}
/** @public */
export class FetchError extends Error {
get name(): string {
return this.constructor.name;
@@ -99,6 +112,7 @@ export class FetchError extends Error {
}
}
/** @public */
export type LighthouseApi = {
url: string;
getWebsiteList: (listOptions: LASListRequest) => Promise<WebsiteListResponse>;
@@ -107,10 +121,12 @@ export type LighthouseApi = {
getWebsiteByUrl: (websiteUrl: string) => Promise<Website>;
};
/** @public */
export const lighthouseApiRef = createApiRef<LighthouseApi>({
id: 'plugin.lighthouse.service',
});
/** @public */
export class LighthouseRestApi implements LighthouseApi {
static fromConfig(config: Config) {
return new LighthouseRestApi(config.getString('lighthouse.baseUrl'));
@@ -124,10 +140,10 @@ export class LighthouseRestApi implements LighthouseApi {
return await resp.json();
}
async getWebsiteList({
limit,
offset,
}: LASListRequest = {}): Promise<WebsiteListResponse> {
async getWebsiteList(
options: LASListRequest = {},
): Promise<WebsiteListResponse> {
const { limit, offset } = options;
const params = new URLSearchParams();
if (typeof limit === 'number') params.append('limit', limit.toString());
if (typeof offset === 'number') params.append('offset', offset.toString());
@@ -27,8 +27,8 @@ import {
StructuredMetadataTable,
} from '@backstage/core-components';
const LighthouseCategoryScoreStatus = ({ score }: { score: number }) => {
const scoreAsPercentage = Math.round(score * 100);
const LighthouseCategoryScoreStatus = (props: { score: number }) => {
const scoreAsPercentage = Math.round(props.score * 100);
switch (true) {
case scoreAsPercentage >= 90:
return (
@@ -56,20 +56,15 @@ const LighthouseCategoryScoreStatus = ({ score }: { score: number }) => {
}
};
const LighthouseAuditStatus = ({ audit }: { audit: Audit }) => (
const LighthouseAuditStatus = (props: { audit: Audit }) => (
<>
<AuditStatusIcon audit={audit} />
{audit.status.toLocaleUpperCase('en-US')}
<AuditStatusIcon audit={props.audit} />
{props.audit.status.toLocaleUpperCase('en-US')}
</>
);
const LighthouseAuditSummary = ({
audit,
dense = false,
}: {
audit: Audit;
dense?: boolean;
}) => {
const LighthouseAuditSummary = (props: { audit: Audit; dense?: boolean }) => {
const { audit, dense = false } = props;
const { url } = audit;
const flattenedCategoryData: Record<string, React.ReactNode> = {};
if (audit.status === 'COMPLETED') {
@@ -92,13 +87,12 @@ const LighthouseAuditSummary = ({
return <StructuredMetadataTable metadata={tableData} dense={dense} />;
};
export const LastLighthouseAuditCard = ({
dense = false,
variant,
}: {
/** @public */
export const LastLighthouseAuditCard = (props: {
dense?: boolean;
variant?: InfoCardVariants;
}) => {
const { dense = false, variant } = props;
const { value: website, loading, error } = useWebsiteForEntity();
let content;
+4
View File
@@ -40,6 +40,7 @@ export const entityContentRouteRef = createRouteRef({
id: 'lighthouse:entity-content',
});
/** @public */
export const lighthousePlugin = createPlugin({
id: 'lighthouse',
apis: [
@@ -55,6 +56,7 @@ export const lighthousePlugin = createPlugin({
},
});
/** @public */
export const LighthousePage = lighthousePlugin.provide(
createRoutableExtension({
name: 'LighthousePage',
@@ -63,6 +65,7 @@ export const LighthousePage = lighthousePlugin.provide(
}),
);
/** @public */
export const EntityLighthouseContent = lighthousePlugin.provide(
createRoutableExtension({
name: 'EntityLighthouseContent',
@@ -71,6 +74,7 @@ export const EntityLighthouseContent = lighthousePlugin.provide(
}),
);
/** @public */
export const EntityLastLighthouseAuditCard = lighthousePlugin.provide(
createComponentExtension({
name: 'EntityLastLighthouseAuditCard',
+12 -3
View File
@@ -8,9 +8,18 @@ import express from 'express';
import { Logger } from 'winston';
import { PluginEndpointDiscovery } from '@backstage/backend-common';
// Warning: (ae-forgotten-export) The symbol "RouterOptions" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "createRouter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export function createRouter(options: RouterOptions): Promise<express.Router>;
// @public (undocumented)
export interface RouterOptions {
// (undocumented)
config: Config;
// (undocumented)
discovery: PluginEndpointDiscovery;
// (undocumented)
logger: Logger;
// (undocumented)
skipInvalidProxies?: boolean;
}
```
@@ -14,4 +14,5 @@
* limitations under the License.
*/
export type { RouterOptions } from './router';
export { createRouter } from './router';
@@ -47,6 +47,7 @@ const safeForwardHeaders = [
'user-agent',
];
/** @public */
export interface RouterOptions {
logger: Logger;
config: Config;
@@ -177,6 +178,7 @@ export function buildMiddleware(
return createProxyMiddleware(filter, fullConfig);
}
/** @public */
export async function createRouter(
options: RouterOptions,
): Promise<express.Router> {
-4
View File
@@ -236,15 +236,11 @@ const ALLOW_WARNINGS = [
'plugins/ilert',
'plugins/jenkins',
'plugins/jenkins-backend',
'plugins/kafka',
'plugins/kafka-backend',
'plugins/kubernetes',
'plugins/kubernetes-common',
'plugins/lighthouse',
'plugins/newrelic',
'plugins/newrelic-dashboard',
'plugins/pagerduty',
'plugins/proxy-backend',
'plugins/rollbar',
'plugins/rollbar-backend',
'plugins/search-backend-module-pg',