Move router and *Service to service folder

Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
Johan Haals
2021-10-12 11:49:21 +02:00
parent ee8d55e02b
commit 9d3ff6680f
14 changed files with 82 additions and 53 deletions
+1
View File
@@ -28,3 +28,4 @@ export * from './util';
export * from './next';
export * from './processing';
export * from './providers';
export * from './service';
@@ -25,7 +25,7 @@ import { LocationResponse, LocationsCatalog } from '../catalog/types';
import { HigherOrderOperation } from '../ingestion/types';
import { createRouter } from './router';
import { basicEntityFilter } from '../../service/request';
import { RefreshService } from '../../next';
import { RefreshService } from '../../service';
describe('createRouter readonly disabled', () => {
let entitiesCatalog: jest.Mocked<Required<EntitiesCatalog>>;
@@ -34,7 +34,7 @@ import {
RefreshService,
LocationService,
RefreshOptions,
} from '../../next/types';
} from '../../service/types';
import {
basicEntityFilter,
parseEntityFilterParams,
@@ -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 './DefaultLocationService';
import { DefaultLocationService } from '../service/DefaultLocationService';
import { DefaultLocationStore } from '../providers/DefaultLocationStore';
import { NextEntitiesCatalog } from './NextEntitiesCatalog';
import { DefaultCatalogProcessingOrchestrator } from '../processing/DefaultCatalogProcessingOrchestrator';
@@ -74,12 +74,12 @@ import {
createRandomRefreshInterval,
RefreshIntervalFunction,
} from './refresh';
import { createNextRouter } from './NextRouter';
import { DefaultRefreshService } from './DefaultRefreshService';
import { createNextRouter } from '../service/NextRouter';
import { DefaultRefreshService } from '../service/DefaultRefreshService';
import { DefaultCatalogRulesEnforcer } from '../ingestion/CatalogRules';
import { Config } from '@backstage/config';
import { Logger } from 'winston';
import { LocationService } from './types';
import { LocationService } from '../service/types';
export type CatalogEnvironment = {
logger: Logger;
+1 -10
View File
@@ -16,15 +16,6 @@
export type { CatalogEnvironment } from './NextCatalogBuilder';
export { NextCatalogBuilder } from './NextCatalogBuilder';
export { createNextRouter } from './NextRouter';
export type { NextRouterOptions } from './NextRouter';
export * from '../processing';
export { createRandomRefreshInterval } from './refresh';
export type { RefreshIntervalFunction } from './refresh';
export * from '../stitching';
export type {
LocationService,
LocationStore,
RefreshOptions,
RefreshService,
} from './types';
export type { LocationStore } from './types';
+1 -33
View File
@@ -14,17 +14,7 @@
* limitations under the License.
*/
import { Entity, Location, LocationSpec } from '@backstage/catalog-model';
export interface LocationService {
createLocation(
spec: LocationSpec,
dryRun: boolean,
): Promise<{ location: Location; entities: Entity[]; exists?: boolean }>;
listLocations(): Promise<Location[]>;
getLocation(id: string): Promise<Location>;
deleteLocation(id: string): Promise<void>;
}
import { Location, LocationSpec } from '@backstage/catalog-model';
export interface LocationStore {
createLocation(spec: LocationSpec): Promise<Location>;
@@ -32,25 +22,3 @@ export interface LocationStore {
getLocation(id: string): Promise<Location>;
deleteLocation(id: string): Promise<void>;
}
/**
* Options for requesting a refresh of entities in the catalog.
*
* @public
*/
export type RefreshOptions = {
/** The reference to a single entity that should be refreshed */
entityRef: string;
};
/**
* A service that manages refreshes of entities in the catalog.
*
* @public
*/
export interface RefreshService {
/**
* Request a refresh of entities in the catalog.
*/
refresh(options: RefreshOptions): Promise<void>;
}
@@ -16,7 +16,7 @@
import { DefaultLocationService } from './DefaultLocationService';
import { CatalogProcessingOrchestrator } from '../processing/types';
import { LocationStore } from './types';
import { LocationStore } from '../next/types';
describe('DefaultLocationServiceTest', () => {
const orchestrator: jest.Mocked<CatalogProcessingOrchestrator> = {
@@ -24,8 +24,9 @@ import {
CatalogProcessingOrchestrator,
DeferredEntity,
} from '../processing/types';
import { LocationService, LocationStore } from './types';
import { locationSpecToMetadataName } from './util';
import { LocationService } from './types';
import { LocationStore } from '../next/types';
import { locationSpecToMetadataName } from '../next/util';
export class DefaultLocationService implements LocationService {
constructor(
@@ -22,7 +22,7 @@ import express from 'express';
import request from 'supertest';
import { EntitiesCatalog } from '../catalog';
import { LocationService, RefreshService } from './types';
import { basicEntityFilter } from '../service/request';
import { basicEntityFilter } from './request';
import { createNextRouter } from './NextRouter';
describe('createNextRouter readonly disabled', () => {
@@ -0,0 +1,19 @@
/*
* 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 { LocationService, RefreshService, RefreshOptions } from './types';
export { createNextRouter } from './NextRouter';
export type { NextRouterOptions } from './NextRouter';
@@ -0,0 +1,49 @@
/*
* 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 { Entity, LocationSpec, Location } from '@backstage/catalog-model';
export interface LocationService {
createLocation(
spec: LocationSpec,
dryRun: boolean,
): Promise<{ location: Location; entities: Entity[]; exists?: boolean }>;
listLocations(): Promise<Location[]>;
getLocation(id: string): Promise<Location>;
deleteLocation(id: string): Promise<void>;
}
/**
* Options for requesting a refresh of entities in the catalog.
*
* @public
*/
export type RefreshOptions = {
/** The reference to a single entity that should be refreshed */
entityRef: string;
};
/**
* A service that manages refreshes of entities in the catalog.
*
* @public
*/
export interface RefreshService {
/**
* Request a refresh of entities in the catalog.
*/
refresh(options: RefreshOptions): Promise<void>;
}