Make default repository impl protected
Expose a construction function instead. Signed-off-by: Jussi Hallila <jussi@hallila.com>
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
```ts
|
||||
import { CheckResult } from '@backstage/plugin-tech-insights-common';
|
||||
import { Config } from '@backstage/config';
|
||||
import { DateTime } from 'luxon';
|
||||
import { Duration } from 'luxon';
|
||||
import express from 'express';
|
||||
import { FactChecker } from '@backstage/plugin-tech-insights-node';
|
||||
@@ -14,16 +13,12 @@ import { FactLifecycle } from '@backstage/plugin-tech-insights-node';
|
||||
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 { FactSchemaDefinition } from '@backstage/plugin-tech-insights-node';
|
||||
import { FlatTechInsightFact } from '@backstage/plugin-tech-insights-node';
|
||||
import { HumanDuration } from '@backstage/types';
|
||||
import { Knex } from 'knex';
|
||||
import { Logger } from 'winston';
|
||||
import { PluginDatabaseManager } from '@backstage/backend-common';
|
||||
import { PluginEndpointDiscovery } from '@backstage/backend-common';
|
||||
import { PluginTaskScheduler } from '@backstage/backend-tasks';
|
||||
import { TechInsightCheck } from '@backstage/plugin-tech-insights-node';
|
||||
import { TechInsightFact } from '@backstage/plugin-tech-insights-node';
|
||||
import { TechInsightsStore } from '@backstage/plugin-tech-insights-node';
|
||||
import { TokenManager } from '@backstage/backend-common';
|
||||
|
||||
@@ -35,6 +30,11 @@ export const buildTechInsightsContext: <
|
||||
options: TechInsightsOptions<CheckType, CheckResultType>,
|
||||
) => Promise<TechInsightsContext<CheckType, CheckResultType>>;
|
||||
|
||||
// @public
|
||||
export type CreateDatabaseOptions = {
|
||||
logger: Logger;
|
||||
};
|
||||
|
||||
// @public
|
||||
export function createFactRetrieverRegistration(
|
||||
options: FactRetrieverRegistrationOptions,
|
||||
@@ -82,6 +82,12 @@ export interface FactRetrieverRegistry {
|
||||
register(registration: FactRetrieverRegistration): Promise<void>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export const initializePersistenceContext: (
|
||||
database: PluginDatabaseManager,
|
||||
options?: CreateDatabaseOptions,
|
||||
) => Promise<PersistenceContext>;
|
||||
|
||||
// @public
|
||||
export type PersistenceContext = {
|
||||
techInsightsStore: TechInsightsStore;
|
||||
@@ -111,41 +117,6 @@ export type TechInsightsContext<
|
||||
factRetrieverEngine: FactRetrieverEngine;
|
||||
};
|
||||
|
||||
// @public
|
||||
export class TechInsightsDatabase implements TechInsightsStore {
|
||||
constructor(db: Knex, logger: Logger);
|
||||
// (undocumented)
|
||||
getFactsBetweenTimestampsByIds(
|
||||
ids: string[],
|
||||
entityTriplet: string,
|
||||
startDateTime: DateTime,
|
||||
endDateTime: DateTime,
|
||||
): Promise<{
|
||||
[factId: string]: FlatTechInsightFact[];
|
||||
}>;
|
||||
// (undocumented)
|
||||
getLatestFactsByIds(
|
||||
ids: string[],
|
||||
entityTriplet: string,
|
||||
): Promise<{
|
||||
[factId: string]: FlatTechInsightFact;
|
||||
}>;
|
||||
// (undocumented)
|
||||
getLatestSchemas(ids?: string[]): Promise<FactSchema[]>;
|
||||
// (undocumented)
|
||||
insertFacts({
|
||||
id,
|
||||
facts,
|
||||
lifecycle,
|
||||
}: {
|
||||
id: string;
|
||||
facts: TechInsightFact[];
|
||||
lifecycle?: FactLifecycle;
|
||||
}): Promise<void>;
|
||||
// (undocumented)
|
||||
insertFactSchema(schemaDefinition: FactSchemaDefinition): Promise<void>;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export interface TechInsightsOptions<
|
||||
CheckType extends TechInsightCheck,
|
||||
|
||||
@@ -18,13 +18,16 @@ export * from './service/router';
|
||||
export type { RouterOptions } from './service/router';
|
||||
|
||||
export { buildTechInsightsContext } from './service/techInsightsContextBuilder';
|
||||
export { initializePersistenceContext } from './service/persistence/persistenceContext';
|
||||
export type {
|
||||
TechInsightsOptions,
|
||||
TechInsightsContext,
|
||||
} from './service/techInsightsContextBuilder';
|
||||
export type { FactRetrieverEngine } from './service/fact/FactRetrieverEngine';
|
||||
export type { TechInsightsDatabase } from './service/persistence/TechInsightsDatabase';
|
||||
export type { PersistenceContext } from './service/persistence/persistenceContext';
|
||||
export type {
|
||||
PersistenceContext,
|
||||
CreateDatabaseOptions,
|
||||
} from './service/persistence/persistenceContext';
|
||||
export { createFactRetrieverRegistration } from './service/fact/createFactRetriever';
|
||||
export type { FactRetrieverRegistry } from './service/fact/FactRetrieverRegistry';
|
||||
export type { FactRetrieverRegistrationOptions } from './service/fact/createFactRetriever';
|
||||
|
||||
@@ -49,7 +49,7 @@ type RawDbFactSchemaRow = {
|
||||
/**
|
||||
* Default TechInsightsDatabase implementation.
|
||||
*
|
||||
* @public
|
||||
* @internal
|
||||
*/
|
||||
export class TechInsightsDatabase implements TechInsightsStore {
|
||||
private readonly CHUNK_SIZE = 50;
|
||||
|
||||
@@ -36,6 +36,11 @@ export type PersistenceContext = {
|
||||
techInsightsStore: TechInsightsStore;
|
||||
};
|
||||
|
||||
/**
|
||||
* A Container for persistence context initialization options
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type CreateDatabaseOptions = {
|
||||
logger: Logger;
|
||||
};
|
||||
@@ -45,7 +50,7 @@ const defaultOptions: CreateDatabaseOptions = {
|
||||
};
|
||||
|
||||
/**
|
||||
* A factory method to construct persistence context for running implementation.
|
||||
* A factory function to construct persistence context for running implementation.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user