backend-plugin-api: simplified ServiceFactory type

Co-authored-by: Fredrik Adelöw <freben@gmail.com>
Co-authored-by: Johan Haals <johan.haals@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-08-17 18:11:41 +02:00
parent 70343d6813
commit eef91a2558
12 changed files with 70 additions and 108 deletions
+11 -38
View File
@@ -3,7 +3,6 @@
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts
import { AnyServiceFactory } from '@backstage/backend-plugin-api';
import { BackendFeature } from '@backstage/backend-plugin-api';
import { Config } from '@backstage/config';
import { ExtensionPoint } from '@backstage/backend-plugin-api';
@@ -29,14 +28,10 @@ export interface Backend {
}
// @public (undocumented)
export const cacheFactory: ServiceFactory<
PluginCacheManager,
PluginCacheManager,
{}
>;
export const cacheFactory: ServiceFactory<PluginCacheManager>;
// @public (undocumented)
export const configFactory: ServiceFactory<Config, Config, {}>;
export const configFactory: ServiceFactory<Config>;
// @public (undocumented)
export function createSpecializedBackend(
@@ -46,46 +41,28 @@ export function createSpecializedBackend(
// @public (undocumented)
export interface CreateSpecializedBackendOptions {
// (undocumented)
services: AnyServiceFactory[];
services: ServiceFactory[];
}
// @public (undocumented)
export const databaseFactory: ServiceFactory<
PluginDatabaseManager,
PluginDatabaseManager,
{}
>;
export const databaseFactory: ServiceFactory<PluginDatabaseManager>;
// @public (undocumented)
export const discoveryFactory: ServiceFactory<
PluginEndpointDiscovery,
PluginEndpointDiscovery,
{}
>;
export const discoveryFactory: ServiceFactory<PluginEndpointDiscovery>;
// @public (undocumented)
export const httpRouterFactory: ServiceFactory<
HttpRouterService,
HttpRouterService,
{}
>;
export const httpRouterFactory: ServiceFactory<HttpRouterService>;
// @public (undocumented)
export const loggerFactory: ServiceFactory<Logger, Logger, {}>;
export const loggerFactory: ServiceFactory<Logger>;
// @public (undocumented)
export const permissionsFactory: ServiceFactory<
PermissionAuthorizer | PermissionEvaluator,
PermissionAuthorizer | PermissionEvaluator,
{}
PermissionAuthorizer | PermissionEvaluator
>;
// @public (undocumented)
export const schedulerFactory: ServiceFactory<
PluginTaskScheduler,
PluginTaskScheduler,
{}
>;
export const schedulerFactory: ServiceFactory<PluginTaskScheduler>;
// @public (undocumented)
export type ServiceOrExtensionPoint<T = unknown> =
@@ -93,12 +70,8 @@ export type ServiceOrExtensionPoint<T = unknown> =
| ServiceRef<T>;
// @public (undocumented)
export const tokenManagerFactory: ServiceFactory<
TokenManager,
TokenManager,
{}
>;
export const tokenManagerFactory: ServiceFactory<TokenManager>;
// @public (undocumented)
export const urlReaderFactory: ServiceFactory<UrlReader, UrlReader, {}>;
export const urlReaderFactory: ServiceFactory<UrlReader>;
```
@@ -108,7 +108,9 @@ export class BackendInitializer {
id: feature.id,
provides,
consumes: new Set(Object.values(registerOptions.deps)),
deps: registerOptions.deps,
deps: registerOptions.deps as {
[name: string]: ServiceOrExtensionPoint;
},
init: registerOptions.init as BackendRegisterInit['init'],
};
},
@@ -14,10 +14,7 @@
* limitations under the License.
*/
import {
AnyServiceFactory,
BackendFeature,
} from '@backstage/backend-plugin-api';
import { ServiceFactory, BackendFeature } from '@backstage/backend-plugin-api';
import { BackendInitializer } from './BackendInitializer';
import { ServiceRegistry } from './ServiceRegistry';
import { Backend } from './types';
@@ -26,7 +23,7 @@ export class BackstageBackend implements Backend {
#services: ServiceRegistry;
#initializer: BackendInitializer;
constructor(apiFactories: AnyServiceFactory[]) {
constructor(apiFactories: ServiceFactory[]) {
this.#services = new ServiceRegistry(apiFactories);
this.#initializer = new BackendInitializer(this.#services);
}
+2 -2
View File
@@ -15,7 +15,7 @@
*/
import {
AnyServiceFactory,
ServiceFactory,
BackendFeature,
ExtensionPoint,
FactoryFunc,
@@ -43,7 +43,7 @@ export interface BackendRegisterInit {
* @public
*/
export interface CreateSpecializedBackendOptions {
services: AnyServiceFactory[];
services: ServiceFactory[];
}
export type ServiceHolder = {