From 9a6ad82fbae03a668c1cb86f667b0c28a917e9dc Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Tue, 12 Oct 2021 13:41:33 +0200 Subject: [PATCH] Restructure NextcatalogBuilder, util and NextEntitiesCatalog Signed-off-by: Johan Haals --- plugins/catalog-backend/src/index.ts | 1 - .../src/legacy/service/CatalogBuilder.test.ts | 2 +- .../src/legacy/service/CatalogBuilder.ts | 2 +- plugins/catalog-backend/src/next/index.ts | 19 --------------- plugins/catalog-backend/src/next/types.ts | 24 ------------------- .../processing/ProcessorOutputCollector.ts | 2 +- .../providers/ConfigLocationEntityProvider.ts | 2 +- .../src/providers/DefaultLocationStore.ts | 5 ++-- .../service/DefaultLocationService.test.ts | 2 +- .../src/service/DefaultLocationService.ts | 5 ++-- .../{next => service}/NextCatalogBuilder.ts | 8 +++---- .../NextEntitiesCatalog.test.ts | 0 .../{next => service}/NextEntitiesCatalog.ts | 0 plugins/catalog-backend/src/service/index.ts | 9 ++++++- plugins/catalog-backend/src/service/types.ts | 7 ++++++ .../src/{next/util.ts => util/conversion.ts} | 0 16 files changed, 28 insertions(+), 60 deletions(-) delete mode 100644 plugins/catalog-backend/src/next/index.ts delete mode 100644 plugins/catalog-backend/src/next/types.ts rename plugins/catalog-backend/src/{next => service}/NextCatalogBuilder.ts (98%) rename plugins/catalog-backend/src/{next => service}/NextEntitiesCatalog.test.ts (100%) rename plugins/catalog-backend/src/{next => service}/NextEntitiesCatalog.ts (100%) rename plugins/catalog-backend/src/{next/util.ts => util/conversion.ts} (100%) diff --git a/plugins/catalog-backend/src/index.ts b/plugins/catalog-backend/src/index.ts index 5fe0ca2483..7ad888bee4 100644 --- a/plugins/catalog-backend/src/index.ts +++ b/plugins/catalog-backend/src/index.ts @@ -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'; diff --git a/plugins/catalog-backend/src/legacy/service/CatalogBuilder.test.ts b/plugins/catalog-backend/src/legacy/service/CatalogBuilder.test.ts index 1b366130ed..926aa67635 100644 --- a/plugins/catalog-backend/src/legacy/service/CatalogBuilder.test.ts +++ b/plugins/catalog-backend/src/legacy/service/CatalogBuilder.test.ts @@ -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', diff --git a/plugins/catalog-backend/src/legacy/service/CatalogBuilder.ts b/plugins/catalog-backend/src/legacy/service/CatalogBuilder.ts index 1a151b77d6..b8e45c7cf3 100644 --- a/plugins/catalog-backend/src/legacy/service/CatalogBuilder.ts +++ b/plugins/catalog-backend/src/legacy/service/CatalogBuilder.ts @@ -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. diff --git a/plugins/catalog-backend/src/next/index.ts b/plugins/catalog-backend/src/next/index.ts deleted file mode 100644 index c37ebf4ff7..0000000000 --- a/plugins/catalog-backend/src/next/index.ts +++ /dev/null @@ -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'; diff --git a/plugins/catalog-backend/src/next/types.ts b/plugins/catalog-backend/src/next/types.ts deleted file mode 100644 index b5888a5a3a..0000000000 --- a/plugins/catalog-backend/src/next/types.ts +++ /dev/null @@ -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; - listLocations(): Promise; - getLocation(id: string): Promise; - deleteLocation(id: string): Promise; -} diff --git a/plugins/catalog-backend/src/processing/ProcessorOutputCollector.ts b/plugins/catalog-backend/src/processing/ProcessorOutputCollector.ts index 9ff4c9240c..dfaa25418b 100644 --- a/plugins/catalog-backend/src/processing/ProcessorOutputCollector.ts +++ b/plugins/catalog-backend/src/processing/ProcessorOutputCollector.ts @@ -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, diff --git a/plugins/catalog-backend/src/providers/ConfigLocationEntityProvider.ts b/plugins/catalog-backend/src/providers/ConfigLocationEntityProvider.ts index e497515035..389cd8d9ff 100644 --- a/plugins/catalog-backend/src/providers/ConfigLocationEntityProvider.ts +++ b/plugins/catalog-backend/src/providers/ConfigLocationEntityProvider.ts @@ -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) {} diff --git a/plugins/catalog-backend/src/providers/DefaultLocationStore.ts b/plugins/catalog-backend/src/providers/DefaultLocationStore.ts index fdd33a422d..9214cd0bc1 100644 --- a/plugins/catalog-backend/src/providers/DefaultLocationStore.ts +++ b/plugins/catalog-backend/src/providers/DefaultLocationStore.ts @@ -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; diff --git a/plugins/catalog-backend/src/service/DefaultLocationService.test.ts b/plugins/catalog-backend/src/service/DefaultLocationService.test.ts index 8d9dee0703..a089989d20 100644 --- a/plugins/catalog-backend/src/service/DefaultLocationService.test.ts +++ b/plugins/catalog-backend/src/service/DefaultLocationService.test.ts @@ -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 = { diff --git a/plugins/catalog-backend/src/service/DefaultLocationService.ts b/plugins/catalog-backend/src/service/DefaultLocationService.ts index bc066823db..2166341935 100644 --- a/plugins/catalog-backend/src/service/DefaultLocationService.ts +++ b/plugins/catalog-backend/src/service/DefaultLocationService.ts @@ -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( diff --git a/plugins/catalog-backend/src/next/NextCatalogBuilder.ts b/plugins/catalog-backend/src/service/NextCatalogBuilder.ts similarity index 98% rename from plugins/catalog-backend/src/next/NextCatalogBuilder.ts rename to plugins/catalog-backend/src/service/NextCatalogBuilder.ts index 2150c10756..60a1668f37 100644 --- a/plugins/catalog-backend/src/next/NextCatalogBuilder.ts +++ b/plugins/catalog-backend/src/service/NextCatalogBuilder.ts @@ -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; diff --git a/plugins/catalog-backend/src/next/NextEntitiesCatalog.test.ts b/plugins/catalog-backend/src/service/NextEntitiesCatalog.test.ts similarity index 100% rename from plugins/catalog-backend/src/next/NextEntitiesCatalog.test.ts rename to plugins/catalog-backend/src/service/NextEntitiesCatalog.test.ts diff --git a/plugins/catalog-backend/src/next/NextEntitiesCatalog.ts b/plugins/catalog-backend/src/service/NextEntitiesCatalog.ts similarity index 100% rename from plugins/catalog-backend/src/next/NextEntitiesCatalog.ts rename to plugins/catalog-backend/src/service/NextEntitiesCatalog.ts diff --git a/plugins/catalog-backend/src/service/index.ts b/plugins/catalog-backend/src/service/index.ts index f47d796693..5345f79628 100644 --- a/plugins/catalog-backend/src/service/index.ts +++ b/plugins/catalog-backend/src/service/index.ts @@ -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'; diff --git a/plugins/catalog-backend/src/service/types.ts b/plugins/catalog-backend/src/service/types.ts index eedc688bb3..05d3d00f4d 100644 --- a/plugins/catalog-backend/src/service/types.ts +++ b/plugins/catalog-backend/src/service/types.ts @@ -47,3 +47,10 @@ export interface RefreshService { */ refresh(options: RefreshOptions): Promise; } + +export interface LocationStore { + createLocation(spec: LocationSpec): Promise; + listLocations(): Promise; + getLocation(id: string): Promise; + deleteLocation(id: string): Promise; +} diff --git a/plugins/catalog-backend/src/next/util.ts b/plugins/catalog-backend/src/util/conversion.ts similarity index 100% rename from plugins/catalog-backend/src/next/util.ts rename to plugins/catalog-backend/src/util/conversion.ts