backend-app-api,backend-plugin-api: refactor existing service factories and fix type issues

Co-authored-by: blam <ben@blam.sh>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-09-09 16:10:59 +02:00
parent fb93ecad9c
commit 2a29d24519
18 changed files with 145 additions and 114 deletions
@@ -21,5 +21,6 @@ import { createServiceRef } from '../system/types';
* @public
*/
export const configServiceRef = createServiceRef<Config>({
id: 'core.config',
id: 'core.root.config',
scope: 'root',
});
@@ -26,4 +26,5 @@ export { discoveryServiceRef } from './discoveryServiceRef';
export { tokenManagerServiceRef } from './tokenManagerServiceRef';
export { permissionsServiceRef } from './permissionsServiceRef';
export { schedulerServiceRef } from './schedulerServiceRef';
export { rootLoggerServiceRef } from './rootLoggerServiceRef';
export { pluginMetadataServiceRef } from './pluginMetadataServiceRef';
@@ -0,0 +1,26 @@
/*
* Copyright 2022 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 { createServiceRef } from '../system/types';
import { Logger } from './loggerServiceRef';
/**
* @public
*/
export const rootLoggerServiceRef = createServiceRef<Logger>({
id: 'core.root.logger',
scope: 'root',
});
@@ -14,11 +14,5 @@
* limitations under the License.
*/
export type {
ServiceRef,
TypesToServiceRef,
DepsToDepFactories,
FactoryFunc,
ServiceFactory,
} from './types';
export type { ServiceRef, TypesToServiceRef, ServiceFactory } from './types';
export { createServiceRef, createServiceFactory } from './types';
@@ -116,6 +116,7 @@ export function createServiceRef<T>(options: {
};
}
/** @ignore */
type ServiceRefsToInstances<
T extends { [key in string]: ServiceRef<unknown> },
TScope extends 'root' | 'plugin' = 'root' | 'plugin',