Merge pull request #13498 from backstage/rugvip/internalfactory
backend-plugin-api: made defaultFactories internal
This commit is contained in:
@@ -108,9 +108,7 @@ export class BackendInitializer {
|
||||
id: feature.id,
|
||||
provides,
|
||||
consumes: new Set(Object.values(registerOptions.deps)),
|
||||
deps: registerOptions.deps as {
|
||||
[name: string]: ServiceOrExtensionPoint;
|
||||
},
|
||||
deps: registerOptions.deps,
|
||||
init: registerOptions.init as BackendRegisterInit['init'],
|
||||
};
|
||||
},
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
ServiceFactory,
|
||||
FactoryFunc,
|
||||
@@ -20,6 +21,14 @@ import {
|
||||
} from '@backstage/backend-plugin-api';
|
||||
import { stringifyError } from '@backstage/errors';
|
||||
|
||||
/**
|
||||
* Keep in sync with `@backstage/backend-plugin-api/src/services/system/types.ts`
|
||||
* @internal
|
||||
*/
|
||||
export type InternalServiceRef<T> = ServiceRef<T> & {
|
||||
__defaultFactory?: (service: ServiceRef<T>) => Promise<ServiceFactory<T>>;
|
||||
};
|
||||
|
||||
export class ServiceRegistry {
|
||||
readonly #providedFactories: Map<string, ServiceFactory>;
|
||||
readonly #loadedDefaultFactories: Map<Function, Promise<ServiceFactory>>;
|
||||
@@ -39,7 +48,7 @@ export class ServiceRegistry {
|
||||
|
||||
get<T>(ref: ServiceRef<T>): FactoryFunc<T> | undefined {
|
||||
let factory = this.#providedFactories.get(ref.id);
|
||||
const { defaultFactory } = ref;
|
||||
const { __defaultFactory: defaultFactory } = ref as InternalServiceRef<T>;
|
||||
if (!factory && !defaultFactory) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user