Restructure NextcatalogBuilder, util and NextEntitiesCatalog
Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
@@ -25,7 +25,6 @@ export * from './ingestion';
|
||||
export * from './legacy';
|
||||
export * from './search';
|
||||
export * from './util';
|
||||
export * from './next';
|
||||
export * from './processing';
|
||||
export * from './providers';
|
||||
export * from './service';
|
||||
|
||||
@@ -23,7 +23,7 @@ import { DatabaseManager } from '../database';
|
||||
import { CatalogProcessorParser } from '../../ingestion';
|
||||
import * as result from '../../ingestion/processors/results';
|
||||
import { CatalogBuilder } from './CatalogBuilder';
|
||||
import { CatalogEnvironment } from '../../next';
|
||||
import { CatalogEnvironment } from '../../service';
|
||||
|
||||
const dummyEntity = {
|
||||
apiVersion: 'backstage.io/v1alpha1',
|
||||
|
||||
@@ -64,7 +64,7 @@ import {
|
||||
} from '../../ingestion/processors/PlaceholderProcessor';
|
||||
import { defaultEntityDataParser } from '../../ingestion/processors/util/parse';
|
||||
import { LocationAnalyzer } from '../../ingestion/types';
|
||||
import { CatalogEnvironment, NextCatalogBuilder } from '../../next';
|
||||
import { CatalogEnvironment, NextCatalogBuilder } from '../../service';
|
||||
|
||||
/**
|
||||
* A builder that helps wire up all of the component parts of the catalog.
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
/*
|
||||
* Copyright 2021 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.
|
||||
*/
|
||||
|
||||
export type { CatalogEnvironment } from './NextCatalogBuilder';
|
||||
export { NextCatalogBuilder } from './NextCatalogBuilder';
|
||||
export type { LocationStore } from './types';
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Copyright 2021 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 { Location, LocationSpec } from '@backstage/catalog-model';
|
||||
|
||||
export interface LocationStore {
|
||||
createLocation(spec: LocationSpec): Promise<Location>;
|
||||
listLocations(): Promise<Location[]>;
|
||||
getLocation(id: string): Promise<Location>;
|
||||
deleteLocation(id: string): Promise<void>;
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
} from '@backstage/catalog-model';
|
||||
import { Logger } from 'winston';
|
||||
import { CatalogProcessorResult } from '../ingestion';
|
||||
import { locationSpecToLocationEntity } from '../next/util';
|
||||
import { locationSpecToLocationEntity } from '../util/conversion';
|
||||
import { DeferredEntity } from './types';
|
||||
import {
|
||||
getEntityLocationRef,
|
||||
|
||||
@@ -18,7 +18,7 @@ import { Config } from '@backstage/config';
|
||||
import path from 'path';
|
||||
import { getEntityLocationRef } from '../processing/util';
|
||||
import { EntityProvider, EntityProviderConnection } from './types';
|
||||
import { locationSpecToLocationEntity } from '../next/util';
|
||||
import { locationSpecToLocationEntity } from '../util/conversion';
|
||||
|
||||
export class ConfigLocationEntityProvider implements EntityProvider {
|
||||
constructor(private readonly config: Config) {}
|
||||
|
||||
@@ -21,9 +21,8 @@ import { v4 as uuid } from 'uuid';
|
||||
import { DbLocationsRow } from '../database/tables';
|
||||
import { getEntityLocationRef } from '../processing/util';
|
||||
import { EntityProvider, EntityProviderConnection } from './types';
|
||||
|
||||
import { locationSpecToLocationEntity } from '../next/util';
|
||||
import { LocationStore } from '../next';
|
||||
import { locationSpecToLocationEntity } from '../util/conversion';
|
||||
import { LocationStore } from '../service';
|
||||
|
||||
export class DefaultLocationStore implements LocationStore, EntityProvider {
|
||||
private _connection: EntityProviderConnection | undefined;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
import { DefaultLocationService } from './DefaultLocationService';
|
||||
import { CatalogProcessingOrchestrator } from '../processing/types';
|
||||
import { LocationStore } from '../next/types';
|
||||
import { LocationStore } from './types';
|
||||
|
||||
describe('DefaultLocationServiceTest', () => {
|
||||
const orchestrator: jest.Mocked<CatalogProcessingOrchestrator> = {
|
||||
|
||||
@@ -24,9 +24,8 @@ import {
|
||||
CatalogProcessingOrchestrator,
|
||||
DeferredEntity,
|
||||
} from '../processing/types';
|
||||
import { LocationService } from './types';
|
||||
import { LocationStore } from '../next/types';
|
||||
import { locationSpecToMetadataName } from '../next/util';
|
||||
import { LocationService, LocationStore } from './types';
|
||||
import { locationSpecToMetadataName } from '../util/conversion';
|
||||
|
||||
export class DefaultLocationService implements LocationService {
|
||||
constructor(
|
||||
|
||||
+4
-4
@@ -65,7 +65,7 @@ import { ConfigLocationEntityProvider } from '../providers/ConfigLocationEntityP
|
||||
import { DefaultProcessingDatabase } from '../database/DefaultProcessingDatabase';
|
||||
import { applyDatabaseMigrations } from '../database/migrations';
|
||||
import { DefaultCatalogProcessingEngine } from '../processing/DefaultCatalogProcessingEngine';
|
||||
import { DefaultLocationService } from '../service/DefaultLocationService';
|
||||
import { DefaultLocationService } from './DefaultLocationService';
|
||||
import { DefaultLocationStore } from '../providers/DefaultLocationStore';
|
||||
import { NextEntitiesCatalog } from './NextEntitiesCatalog';
|
||||
import { DefaultCatalogProcessingOrchestrator } from '../processing/DefaultCatalogProcessingOrchestrator';
|
||||
@@ -74,12 +74,12 @@ import {
|
||||
createRandomRefreshInterval,
|
||||
RefreshIntervalFunction,
|
||||
} from '../processing/refresh';
|
||||
import { createNextRouter } from '../service/NextRouter';
|
||||
import { DefaultRefreshService } from '../service/DefaultRefreshService';
|
||||
import { createNextRouter } from './NextRouter';
|
||||
import { DefaultRefreshService } from './DefaultRefreshService';
|
||||
import { DefaultCatalogRulesEnforcer } from '../ingestion/CatalogRules';
|
||||
import { Config } from '@backstage/config';
|
||||
import { Logger } from 'winston';
|
||||
import { LocationService } from '../service/types';
|
||||
import { LocationService } from './types';
|
||||
|
||||
export type CatalogEnvironment = {
|
||||
logger: Logger;
|
||||
@@ -14,6 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export type { LocationService, RefreshService, RefreshOptions } from './types';
|
||||
export type {
|
||||
LocationService,
|
||||
RefreshService,
|
||||
RefreshOptions,
|
||||
LocationStore,
|
||||
} from './types';
|
||||
export { createNextRouter } from './NextRouter';
|
||||
export type { NextRouterOptions } from './NextRouter';
|
||||
export type { CatalogEnvironment } from './NextCatalogBuilder';
|
||||
export { NextCatalogBuilder } from './NextCatalogBuilder';
|
||||
|
||||
@@ -47,3 +47,10 @@ export interface RefreshService {
|
||||
*/
|
||||
refresh(options: RefreshOptions): Promise<void>;
|
||||
}
|
||||
|
||||
export interface LocationStore {
|
||||
createLocation(spec: LocationSpec): Promise<Location>;
|
||||
listLocations(): Promise<Location[]>;
|
||||
getLocation(id: string): Promise<Location>;
|
||||
deleteLocation(id: string): Promise<void>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user