Revert "Refactor"
This reverts commit 54f4eba561.
Signed-off-by: sblausten <sam@roadie.io>
This commit is contained in:
@@ -9,7 +9,7 @@ import express from 'express';
|
||||
import { FactChecker } from '@backstage/plugin-tech-insights-node';
|
||||
import { FactCheckerFactory } from '@backstage/plugin-tech-insights-node';
|
||||
import { FactLifecycle } from '@backstage/plugin-tech-insights-node';
|
||||
import { FactRetriever } from '@backstage/plugin-tech-insights-common';
|
||||
import { FactRetriever } from '@backstage/plugin-tech-insights-node';
|
||||
import { FactRetrieverRegistration } from '@backstage/plugin-tech-insights-node';
|
||||
import { FactSchema } from '@backstage/plugin-tech-insights-node';
|
||||
import { Logger } from 'winston';
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {
|
||||
FactRetriever,
|
||||
FactRetrieverRegistration,
|
||||
FactSchemaDefinition,
|
||||
TechInsightFact,
|
||||
@@ -29,15 +30,12 @@ import {
|
||||
import { ConfigReader } from '@backstage/config';
|
||||
import { TestDatabaseId, TestDatabases } from '@backstage/backend-test-utils';
|
||||
import { TaskScheduler } from '@backstage/backend-tasks';
|
||||
import { FactRetriever } from '@backstage/plugin-tech-insights-common';
|
||||
|
||||
jest.useFakeTimers();
|
||||
|
||||
const testFactRetriever: FactRetriever = {
|
||||
id: 'test_factretriever',
|
||||
version: '0.0.1',
|
||||
title: 'Test 1',
|
||||
description: 'testing',
|
||||
entityFilter: [{ kind: 'component' }],
|
||||
schema: {
|
||||
testnumberfact: {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
import {
|
||||
FactLifecycle,
|
||||
FactRetriever,
|
||||
FactRetrieverContext,
|
||||
FactRetrieverRegistration,
|
||||
TechInsightFact,
|
||||
@@ -24,7 +25,6 @@ import { FactRetrieverRegistry } from './FactRetrieverRegistry';
|
||||
import { Logger } from 'winston';
|
||||
import { PluginTaskScheduler } from '@backstage/backend-tasks';
|
||||
import { Duration } from 'luxon';
|
||||
import { FactRetriever } from '@backstage/plugin-tech-insights-common';
|
||||
|
||||
function randomDailyCron() {
|
||||
const rand = (min: number, max: number) =>
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
FactRetriever,
|
||||
FactRetrieverRegistration,
|
||||
FactSchema,
|
||||
} from '@backstage/plugin-tech-insights-node';
|
||||
import { ConflictError, NotFoundError } from '@backstage/errors';
|
||||
import { FactRetriever } from '@backstage/plugin-tech-insights-common';
|
||||
|
||||
/**
|
||||
* @public
|
||||
|
||||
@@ -15,15 +15,15 @@
|
||||
*/
|
||||
import {
|
||||
FactLifecycle,
|
||||
FactRetriever,
|
||||
FactRetrieverRegistration,
|
||||
} from '@backstage/plugin-tech-insights-node';
|
||||
import { FactRetriever } from '@backstage/plugin-tech-insights-common';
|
||||
|
||||
/**
|
||||
* @public
|
||||
*
|
||||
* @param cadence - cron expression to indicate when the fact retriever should be triggered
|
||||
* @param factRetriever - Implementation of fact retriever definition
|
||||
* @param factRetriever - Implementation of fact retriever consisting of at least id, version, schema and handler
|
||||
* @param lifecycle - Optional lifecycle definition indicating the cleanup logic of facts when this retriever is run
|
||||
*
|
||||
*/
|
||||
|
||||
+4
-2
@@ -14,11 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FactRetrieverContext } from '@backstage/plugin-tech-insights-node';
|
||||
import {
|
||||
FactRetriever,
|
||||
FactRetrieverContext,
|
||||
} from '@backstage/plugin-tech-insights-node';
|
||||
import { CatalogClient } from '@backstage/catalog-client';
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import isEmpty from 'lodash/isEmpty';
|
||||
import { FactRetriever } from '@backstage/plugin-tech-insights-common';
|
||||
|
||||
/**
|
||||
* Generates facts which indicate the completeness of entity metadata.
|
||||
|
||||
+4
-2
@@ -14,10 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FactRetrieverContext } from '@backstage/plugin-tech-insights-node';
|
||||
import {
|
||||
FactRetriever,
|
||||
FactRetrieverContext,
|
||||
} from '@backstage/plugin-tech-insights-node';
|
||||
import { CatalogClient } from '@backstage/catalog-client';
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { FactRetriever } from '@backstage/plugin-tech-insights-common';
|
||||
|
||||
/**
|
||||
* Generates facts which indicate the quality of data in the spec.owner field.
|
||||
|
||||
+4
-2
@@ -14,11 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FactRetrieverContext } from '@backstage/plugin-tech-insights-node';
|
||||
import {
|
||||
FactRetriever,
|
||||
FactRetrieverContext,
|
||||
} from '@backstage/plugin-tech-insights-node';
|
||||
import { CatalogClient } from '@backstage/catalog-client';
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { entityHasAnnotation, generateAnnotationFactName } from './utils';
|
||||
import { FactRetriever } from '@backstage/plugin-tech-insights-common';
|
||||
|
||||
const techdocsAnnotation = 'backstage.io/techdocs-ref';
|
||||
const techdocsAnnotationFactName =
|
||||
|
||||
@@ -4,10 +4,7 @@
|
||||
|
||||
```ts
|
||||
import { DateTime } from 'luxon';
|
||||
import { FactRetrieverContext } from '../../tech-insights-node';
|
||||
import { FactSchema } from '../../tech-insights-node';
|
||||
import { JsonValue } from '@backstage/types';
|
||||
import { TechInsightFact } from '../../tech-insights-node';
|
||||
|
||||
// @public
|
||||
export interface BooleanCheckResult extends CheckResult {
|
||||
@@ -50,18 +47,5 @@ export type FactResponse = {
|
||||
};
|
||||
};
|
||||
|
||||
// @public
|
||||
export interface FactRetriever {
|
||||
description: string;
|
||||
entityFilter?:
|
||||
| Record<string, string | symbol | (string | symbol)[]>[]
|
||||
| Record<string, string | symbol | (string | symbol)[]>;
|
||||
handler: (ctx: FactRetrieverContext) => Promise<TechInsightFact[]>;
|
||||
id: string;
|
||||
schema: FactSchema;
|
||||
title: string;
|
||||
version: string;
|
||||
}
|
||||
|
||||
// (No @packageDocumentation comment for this package)
|
||||
```
|
||||
|
||||
@@ -35,8 +35,7 @@
|
||||
"dependencies": {
|
||||
"@types/luxon": "^2.0.5",
|
||||
"luxon": "^2.0.2",
|
||||
"@backstage/types": "^1.0.0",
|
||||
"@backstage/plugin-tech-insights-node": "^0.3.1"
|
||||
"@backstage/types": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@backstage/cli": "^0.18.0-next.1"
|
||||
|
||||
@@ -16,11 +16,6 @@
|
||||
|
||||
import { DateTime } from 'luxon';
|
||||
import { JsonValue } from '@backstage/types';
|
||||
import {
|
||||
FactRetrieverContext,
|
||||
FactSchema,
|
||||
TechInsightFact,
|
||||
} from '@backstage/plugin-tech-insights-node';
|
||||
|
||||
/**
|
||||
* @public
|
||||
@@ -106,63 +101,6 @@ export type FactResponse = {
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* FactRetriever interface
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface FactRetriever {
|
||||
/**
|
||||
* A unique identifier of the retriever.
|
||||
* Used to identify and store individual facts returned from this retriever
|
||||
* and schemas defined by this retriever.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* Semver string indicating the version of this fact retriever
|
||||
* This version is used to determine if the schema this fact retriever matches the data this fact retriever provides.
|
||||
*
|
||||
* Should be incremented on changes to returned data from the handler or if the schema changes.
|
||||
*/
|
||||
version: string;
|
||||
|
||||
/**
|
||||
* A short display title for the fact retriever to be used in the interface
|
||||
*/
|
||||
title: string;
|
||||
|
||||
/**
|
||||
* A short display description for the fact retriever to be used in the interface.
|
||||
*/
|
||||
description: string;
|
||||
|
||||
/**
|
||||
* Handler function that needs to be implemented to retrieve fact values for entities.
|
||||
*
|
||||
* @param ctx - FactRetrieverContext which can be used to retrieve config and contact integrations
|
||||
* @returns - A collection of TechInsightFacts grouped by entities.
|
||||
*/
|
||||
handler: (ctx: FactRetrieverContext) => Promise<TechInsightFact[]>;
|
||||
|
||||
/**
|
||||
* A fact schema defining the shape of data returned from the handler method for each entity
|
||||
*/
|
||||
schema: FactSchema;
|
||||
|
||||
/**
|
||||
* An optional object/array of objects of entity filters to indicate if this fact retriever is valid for an entity type.
|
||||
* If omitted, the retriever should apply to all entities.
|
||||
*
|
||||
* Should be defined for example:
|
||||
* \{ field: 'kind', values: \['component'\] \}
|
||||
* \{ field: 'metadata.name', values: \['component-1', 'component-2'\] \}
|
||||
*/
|
||||
entityFilter?:
|
||||
| Record<string, string | symbol | (string | symbol)[]>[]
|
||||
| Record<string, string | symbol | (string | symbol)[]>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic CheckResult
|
||||
*
|
||||
|
||||
@@ -8,7 +8,6 @@ import { Config } from '@backstage/config';
|
||||
import { DateTime } from 'luxon';
|
||||
import { Duration } from 'luxon';
|
||||
import { DurationLike } from 'luxon';
|
||||
import { FactRetriever } from '@backstage/plugin-tech-insights-common';
|
||||
import { JsonValue } from '@backstage/types';
|
||||
import { Logger } from 'winston';
|
||||
import { PluginEndpointDiscovery } from '@backstage/backend-common';
|
||||
@@ -45,6 +44,19 @@ export interface FactCheckerFactory<
|
||||
// @public
|
||||
export type FactLifecycle = TTL | MaxItems;
|
||||
|
||||
// @public
|
||||
export interface FactRetriever {
|
||||
description: string;
|
||||
entityFilter?:
|
||||
| Record<string, string | symbol | (string | symbol)[]>[]
|
||||
| Record<string, string | symbol | (string | symbol)[]>;
|
||||
handler: (ctx: FactRetrieverContext) => Promise<TechInsightFact[]>;
|
||||
id: string;
|
||||
schema: FactSchema;
|
||||
title: string;
|
||||
version: string;
|
||||
}
|
||||
|
||||
// @public
|
||||
export type FactRetrieverContext = {
|
||||
config: Config;
|
||||
|
||||
@@ -21,7 +21,6 @@ import {
|
||||
TokenManager,
|
||||
} from '@backstage/backend-common';
|
||||
import { Logger } from 'winston';
|
||||
import { FactRetriever } from '@backstage/plugin-tech-insights-common';
|
||||
|
||||
/**
|
||||
* A container for facts. The shape of the fact records needs to correspond to the FactSchema with same `ref` value.
|
||||
@@ -154,6 +153,63 @@ export type FactRetrieverContext = {
|
||||
| Record<string, string | symbol | (string | symbol)[]>;
|
||||
};
|
||||
|
||||
/**
|
||||
* FactRetriever interface
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface FactRetriever {
|
||||
/**
|
||||
* A unique identifier of the retriever.
|
||||
* Used to identify and store individual facts returned from this retriever
|
||||
* and schemas defined by this retriever.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* Semver string indicating the version of this fact retriever
|
||||
* This version is used to determine if the schema this fact retriever matches the data this fact retriever provides.
|
||||
*
|
||||
* Should be incremented on changes to returned data from the handler or if the schema changes.
|
||||
*/
|
||||
version: string;
|
||||
|
||||
/**
|
||||
* A short display title for the fact retriever to be used in the interface
|
||||
*/
|
||||
title: string;
|
||||
|
||||
/**
|
||||
* A short display description for the fact retriever to be used in the interface.
|
||||
*/
|
||||
description: string;
|
||||
|
||||
/**
|
||||
* Handler function that needs to be implemented to retrieve fact values for entities.
|
||||
*
|
||||
* @param ctx - FactRetrieverContext which can be used to retrieve config and contact integrations
|
||||
* @returns - A collection of TechInsightFacts grouped by entities.
|
||||
*/
|
||||
handler: (ctx: FactRetrieverContext) => Promise<TechInsightFact[]>;
|
||||
|
||||
/**
|
||||
* A fact schema defining the shape of data returned from the handler method for each entity
|
||||
*/
|
||||
schema: FactSchema;
|
||||
|
||||
/**
|
||||
* An optional object/array of objects of entity filters to indicate if this fact retriever is valid for an entity type.
|
||||
* If omitted, the retriever should apply to all entities.
|
||||
*
|
||||
* Should be defined for example:
|
||||
* \{ field: 'kind', values: \['component'\] \}
|
||||
* \{ field: 'metadata.name', values: \['component-1', 'component-2'\] \}
|
||||
*/
|
||||
entityFilter?:
|
||||
| Record<string, string | symbol | (string | symbol)[]>[]
|
||||
| Record<string, string | symbol | (string | symbol)[]>;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Luxon duration like object for time to live value
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user