feat(tech-insights): add plugin for new backend system

A new backend plugin for the tech-insights backend
was added and exported as `default`
as well as extension points to be used by modules.

The plugin can be used like

```ts title="packages/backend/src/index.ts"
backend.add(import('@backstage/plugin-tech-insights-backend'));
```

Fact retrievers will be added
(built-in or through the extension point),
but only registered if the user adds a configuration for it
(cadence, etc.).

Signed-off-by: Patrick Jungermann <Patrick.Jungermann@gmail.com>
This commit is contained in:
Patrick Jungermann
2024-01-08 23:34:43 +01:00
parent bc72782dd6
commit 7201af3445
16 changed files with 541 additions and 1 deletions
+24
View File
@@ -8,6 +8,7 @@ import { Config } from '@backstage/config';
import { DateTime } from 'luxon';
import { Duration } from 'luxon';
import { DurationLike } from 'luxon';
import { ExtensionPoint } from '@backstage/backend-plugin-api';
import { FactSchema } from '@backstage/plugin-tech-insights-common';
import { HumanDuration } from '@backstage/types';
import { JsonValue } from '@backstage/types';
@@ -137,6 +138,29 @@ export type TechInsightFact = {
timestamp?: DateTime;
};
// @public (undocumented)
export interface TechInsightsFactCheckerFactoryExtensionPoint {
// (undocumented)
setFactCheckerFactory<
CheckType extends TechInsightCheck,
CheckResultType extends CheckResult,
>(
factory: FactCheckerFactory<CheckType, CheckResultType>,
): void;
}
// @public
export const techInsightsFactCheckerFactoryExtensionPoint: ExtensionPoint<TechInsightsFactCheckerFactoryExtensionPoint>;
// @public (undocumented)
export interface TechInsightsFactRetrieversExtensionPoint {
// (undocumented)
addFactRetrievers(factRetrievers: Record<string, FactRetriever>): void;
}
// @public
export const techInsightsFactRetrieversExtensionPoint: ExtensionPoint<TechInsightsFactRetrieversExtensionPoint>;
// @public
export interface TechInsightsStore {
getFactsBetweenTimestampsByIds(
+1
View File
@@ -33,6 +33,7 @@
},
"dependencies": {
"@backstage/backend-common": "workspace:^",
"@backstage/backend-plugin-api": "workspace:^",
"@backstage/config": "workspace:^",
"@backstage/plugin-tech-insights-common": "workspace:^",
"@backstage/types": "workspace:^",
@@ -0,0 +1,59 @@
/*
* Copyright 2024 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { createExtensionPoint } from '@backstage/backend-plugin-api';
import { CheckResult } from '@backstage/plugin-tech-insights-common';
import { FactRetriever } from './facts';
import { FactCheckerFactory, TechInsightCheck } from './checks';
/**
* @public
*/
export interface TechInsightsFactRetrieversExtensionPoint {
addFactRetrievers(factRetrievers: Record<string, FactRetriever>): void;
}
/**
* An extension point that allows other plugins or modules to add fact retrievers.
*
* @public
*/
export const techInsightsFactRetrieversExtensionPoint =
createExtensionPoint<TechInsightsFactRetrieversExtensionPoint>({
id: 'tech-insights.fact-retrievers',
});
/**
* @public
*/
export interface TechInsightsFactCheckerFactoryExtensionPoint {
setFactCheckerFactory<
CheckType extends TechInsightCheck,
CheckResultType extends CheckResult,
>(
factory: FactCheckerFactory<CheckType, CheckResultType>,
): void;
}
/**
* An extension point that allows other plugins or modules to set a FactCheckerFactory.
*
* @public
*/
export const techInsightsFactCheckerFactoryExtensionPoint =
createExtensionPoint<TechInsightsFactCheckerFactoryExtensionPoint>({
id: 'tech-insights.fact-checker-factory',
});
+1
View File
@@ -15,5 +15,6 @@
*/
export * from './checks';
export * from './extensionPoints';
export * from './facts';
export * from './persistence';