Merge pull request #22145 from Bonial-International-GmbH/pjungermann/new-backend/tech-insights
new backend system: tech-insights
This commit is contained in:
@@ -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';
|
||||
@@ -79,6 +80,20 @@ export type FactRetrieverRegistration = {
|
||||
initialDelay?: Duration | HumanDuration;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export interface FactRetrieverRegistry {
|
||||
// (undocumented)
|
||||
get(retrieverReference: string): Promise<FactRetrieverRegistration>;
|
||||
// (undocumented)
|
||||
getSchemas(): Promise<FactSchema[]>;
|
||||
// (undocumented)
|
||||
listRegistrations(): Promise<FactRetrieverRegistration[]>;
|
||||
// (undocumented)
|
||||
listRetrievers(): Promise<FactRetriever[]>;
|
||||
// (undocumented)
|
||||
register(registration: FactRetrieverRegistration): Promise<void>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export type FactSchemaDefinition = Omit<FactRetriever, 'handler'>;
|
||||
|
||||
@@ -92,6 +107,11 @@ export type MaxItems = {
|
||||
maxItems: number;
|
||||
};
|
||||
|
||||
// @public
|
||||
export type PersistenceContext = {
|
||||
techInsightsStore: TechInsightsStore;
|
||||
};
|
||||
|
||||
// @public
|
||||
export interface TechInsightCheck {
|
||||
description: string;
|
||||
@@ -137,6 +157,47 @@ 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 TechInsightsFactRetrieverRegistryExtensionPoint {
|
||||
// (undocumented)
|
||||
setFactRetrieverRegistry(registry: FactRetrieverRegistry): void;
|
||||
}
|
||||
|
||||
// @public
|
||||
export const techInsightsFactRetrieverRegistryExtensionPoint: ExtensionPoint<TechInsightsFactRetrieverRegistryExtensionPoint>;
|
||||
|
||||
// @public (undocumented)
|
||||
export interface TechInsightsFactRetrieversExtensionPoint {
|
||||
// (undocumented)
|
||||
addFactRetrievers(factRetrievers: Record<string, FactRetriever>): void;
|
||||
}
|
||||
|
||||
// @public
|
||||
export const techInsightsFactRetrieversExtensionPoint: ExtensionPoint<TechInsightsFactRetrieversExtensionPoint>;
|
||||
|
||||
// @public (undocumented)
|
||||
export interface TechInsightsPersistenceContextExtensionPoint {
|
||||
// (undocumented)
|
||||
setPersistenceContext(context: PersistenceContext): void;
|
||||
}
|
||||
|
||||
// @public
|
||||
export const techInsightsPersistenceContextExtensionPoint: ExtensionPoint<TechInsightsPersistenceContextExtensionPoint>;
|
||||
|
||||
// @public
|
||||
export interface TechInsightsStore {
|
||||
getFactsBetweenTimestampsByIds(
|
||||
|
||||
@@ -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,94 @@
|
||||
/*
|
||||
* 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 { FactCheckerFactory, TechInsightCheck } from './checks';
|
||||
import { FactRetriever, FactRetrieverRegistry } from './facts';
|
||||
import { PersistenceContext } from './persistence';
|
||||
|
||||
/**
|
||||
* @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',
|
||||
});
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface TechInsightsFactRetrieverRegistryExtensionPoint {
|
||||
setFactRetrieverRegistry(registry: FactRetrieverRegistry): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* An extension point that allows other plugins or modules to set a custom FactRetrieverRegistry.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const techInsightsFactRetrieverRegistryExtensionPoint =
|
||||
createExtensionPoint<TechInsightsFactRetrieverRegistryExtensionPoint>({
|
||||
id: 'tech-insights.fact-retriever-registry',
|
||||
});
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface TechInsightsPersistenceContextExtensionPoint {
|
||||
setPersistenceContext(context: PersistenceContext): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* An extension point that allows other plugins or modules to set a custom PersistenceContext.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const techInsightsPersistenceContextExtensionPoint =
|
||||
createExtensionPoint<TechInsightsPersistenceContextExtensionPoint>({
|
||||
id: 'tech-insights.persistence-context',
|
||||
});
|
||||
@@ -230,3 +230,14 @@ export type FactRetrieverRegistration = {
|
||||
*/
|
||||
initialDelay?: Duration | HumanDuration;
|
||||
};
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface FactRetrieverRegistry {
|
||||
register(registration: FactRetrieverRegistration): Promise<void>;
|
||||
get(retrieverReference: string): Promise<FactRetrieverRegistration>;
|
||||
listRetrievers(): Promise<FactRetriever[]>;
|
||||
listRegistrations(): Promise<FactRetrieverRegistration[]>;
|
||||
getSchemas(): Promise<FactSchema[]>;
|
||||
}
|
||||
|
||||
@@ -15,5 +15,6 @@
|
||||
*/
|
||||
|
||||
export * from './checks';
|
||||
export * from './extensionPoints';
|
||||
export * from './facts';
|
||||
export * from './persistence';
|
||||
|
||||
@@ -22,6 +22,15 @@ import {
|
||||
import { DateTime } from 'luxon';
|
||||
import { FactSchema } from '@backstage/plugin-tech-insights-common';
|
||||
|
||||
/**
|
||||
* A Container for persistence related components in TechInsights
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type PersistenceContext = {
|
||||
techInsightsStore: TechInsightsStore;
|
||||
};
|
||||
|
||||
/**
|
||||
* TechInsights Database
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user