Add explicit type information to checks

Types can be used to:
* Determine which check logic to run
* Determine the correct persistence option to use
* Choose correct ser/deser logic for the check
* Determine correct components to render on the frontend

Modify router API to be post for better usability. The API might end up doing writes if caching etc. is added in later as well.

Modify CheckRegistry & FactChecker to return persisted check when it is registered.

Signed-off-by: Jussi Hallila <jussi@hallila.com>
This commit is contained in:
Jussi Hallila
2021-10-21 09:25:26 +02:00
parent 75fc6ac85b
commit b2363f3e3b
11 changed files with 91 additions and 17 deletions
+4 -4
View File
@@ -21,6 +21,7 @@ export interface CheckResponse {
id: string;
metadata?: Record<string, any>;
name: string;
type: string;
}
// @public
@@ -34,7 +35,7 @@ export interface FactChecker<
CheckType extends TechInsightCheck,
CheckResultType extends CheckResult,
> {
addCheck(check: CheckType): Promise<boolean>;
addCheck(check: CheckType): Promise<CheckType>;
getChecks(): Promise<CheckType[]>;
runChecks(entity: string, checks: string[]): Promise<CheckResultType[]>;
validate(check: CheckType): Promise<boolean>;
@@ -108,14 +109,13 @@ export type FlatTechInsightFact = TechInsightFact & {
// @public
export interface TechInsightCheck {
// (undocumented)
description: string;
factRefs: string[];
failureMetadata?: Record<string, any>;
id: string;
// (undocumented)
name: string;
successMetadata?: Record<string, any>;
type: string;
}
// @public
@@ -127,7 +127,7 @@ export interface TechInsightCheckRegistry<CheckType extends TechInsightCheck> {
// (undocumented)
list(): Promise<CheckType[]>;
// (undocumented)
register(check: CheckType): Promise<void>;
register(check: CheckType): Promise<CheckType>;
}
// @public
+16 -2
View File
@@ -66,7 +66,7 @@ export interface FactChecker<
* @param check - The actual check to be added.
* @returns - An indicator if fact was successfully added
*/
addCheck(check: CheckType): Promise<boolean>;
addCheck(check: CheckType): Promise<CheckType>;
/**
* Retrieves all available checks that can be used to run checks against.
@@ -93,7 +93,7 @@ export interface FactChecker<
*
*/
export interface TechInsightCheckRegistry<CheckType extends TechInsightCheck> {
register(check: CheckType): Promise<void>;
register(check: CheckType): Promise<CheckType>;
get(checkId: string): Promise<CheckType>;
getAll(checks: string[]): Promise<CheckType[]>;
list(): Promise<CheckType[]>;
@@ -135,7 +135,21 @@ export interface TechInsightCheck {
*/
id: string;
/**
* Type identifier for the check.
* Can be used to determine storage options, logical routing to correct FactChecker implementation
* or to help frontend render correct component types based on this
*/
type: string;
/**
* Human readable name of the check, may be displayed in the UI
*/
name: string;
/**
* Human readable description of the check, may be displayed in the UI
*/
description: string;
/**
@@ -26,6 +26,12 @@ export interface CheckResponse {
* Identifier of the Check
*/
id: string;
/**
* Type identifier for the check.
* Can be used to determine storage options, logical routing to correct FactChecker implementation
* or to help frontend render correct component types based on this
*/
type: string;
/**
* Human readable name of the Check
*/