Add more breaking changes.
Update API reports. Signed-off-by: Jussi Hallila <jussi@hallila.com>
This commit is contained in:
@@ -26,11 +26,11 @@ export const buildTechInsightsContext: <
|
||||
) => Promise<TechInsightsContext<CheckType, CheckResultType>>;
|
||||
|
||||
// @public
|
||||
export function createFactRetrieverRegistration(
|
||||
cadence: string,
|
||||
factRetriever: FactRetriever,
|
||||
lifecycle?: FactLifecycle,
|
||||
): FactRetrieverRegistration;
|
||||
export function createFactRetrieverRegistration({
|
||||
cadence,
|
||||
factRetriever,
|
||||
lifecycle,
|
||||
}: FactRetrieverRegistrationOptions): FactRetrieverRegistration;
|
||||
|
||||
// @public
|
||||
export function createRouter<
|
||||
@@ -44,6 +44,13 @@ export const entityMetadataFactRetriever: FactRetriever;
|
||||
// @public
|
||||
export const entityOwnershipFactRetriever: FactRetriever;
|
||||
|
||||
// @public (undocumented)
|
||||
export type FactRetrieverRegistrationOptions = {
|
||||
cadence: string;
|
||||
factRetriever: FactRetriever;
|
||||
lifecycle?: FactLifecycle;
|
||||
};
|
||||
|
||||
// @public
|
||||
export type PersistenceContext = {
|
||||
techInsightsStore: TechInsightsStore;
|
||||
|
||||
@@ -25,4 +25,5 @@ export type {
|
||||
|
||||
export type { PersistenceContext } from './service/persistence/persistenceContext';
|
||||
export { createFactRetrieverRegistration } from './service/fact/createFactRetriever';
|
||||
export type { FactRetrieverRegistrationOptions } from './service/fact/createFactRetriever';
|
||||
export * from './service/fact/factRetrievers';
|
||||
|
||||
@@ -125,7 +125,11 @@ export class FactRetrieverEngine {
|
||||
}
|
||||
|
||||
try {
|
||||
await this.repository.insertFacts(factRetriever.id, facts, lifecycle);
|
||||
await this.repository.insertFacts({
|
||||
id: factRetriever.id,
|
||||
facts,
|
||||
lifecycle,
|
||||
});
|
||||
this.logger.info(
|
||||
`Stored ${facts.length} facts for fact retriever ${
|
||||
factRetriever.id
|
||||
|
||||
@@ -19,6 +19,14 @@ import {
|
||||
FactRetrieverRegistration,
|
||||
} from '@backstage/plugin-tech-insights-node';
|
||||
|
||||
/**
|
||||
* @public
|
||||
*
|
||||
* @param cadence - cron expression to indicate when the fact retriever should be triggered
|
||||
* @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
|
||||
*
|
||||
*/
|
||||
export type FactRetrieverRegistrationOptions = {
|
||||
cadence: string;
|
||||
factRetriever: FactRetriever;
|
||||
@@ -50,7 +58,7 @@ export type FactRetrieverRegistrationOptions = {
|
||||
*
|
||||
* Valid lifecycle values:
|
||||
* \{ ttl: \{ weeks: 2 \} \} -- This fact retriever will remove items that are older than 2 weeks when it is run
|
||||
* \{ itl: 7 \} -- This fact retriever will leave 7 newest items in the database when it is run
|
||||
* \{ maxItems: 7 \} -- This fact retriever will leave 7 newest items in the database when it is run
|
||||
*
|
||||
*/
|
||||
export function createFactRetrieverRegistration({
|
||||
|
||||
@@ -290,7 +290,11 @@ describe('Tech Insights database', () => {
|
||||
},
|
||||
};
|
||||
const maxItems = 2;
|
||||
await store.insertFacts('test-fact', [factToBeInserted], { maxItems });
|
||||
await store.insertFacts({
|
||||
id: 'test-fact',
|
||||
facts: [factToBeInserted],
|
||||
lifecycle: { maxItems },
|
||||
});
|
||||
|
||||
const afterInsertionFacts = await testDbClient('facts').select();
|
||||
expect(afterInsertionFacts).toHaveLength(maxItems);
|
||||
@@ -334,8 +338,10 @@ describe('Tech Insights database', () => {
|
||||
testNumberFact: 555,
|
||||
},
|
||||
};
|
||||
await store.insertFacts('test-fact', [factToBeInserted], {
|
||||
timeToLive: { weeks: 2 },
|
||||
await store.insertFacts({
|
||||
id: 'test-fact',
|
||||
facts: [factToBeInserted],
|
||||
lifecycle: { timeToLive: { weeks: 2 } },
|
||||
});
|
||||
|
||||
const afterInsertionFacts = await testDbClient('facts')
|
||||
|
||||
@@ -87,11 +87,15 @@ export class TechInsightsDatabase implements TechInsightsStore {
|
||||
}
|
||||
}
|
||||
|
||||
async insertFacts(
|
||||
id: string,
|
||||
facts: TechInsightFact[],
|
||||
lifecycle?: FactLifecycle,
|
||||
): Promise<void> {
|
||||
async insertFacts({
|
||||
id,
|
||||
facts,
|
||||
lifecycle,
|
||||
}: {
|
||||
id: string;
|
||||
facts: TechInsightFact[];
|
||||
lifecycle?: FactLifecycle;
|
||||
}): Promise<void> {
|
||||
if (facts.length === 0) return;
|
||||
const currentSchema = await this.getLatestSchema(id);
|
||||
const factRows = facts.map(it => {
|
||||
|
||||
Reference in New Issue
Block a user