Merge pull request #13498 from backstage/rugvip/internalfactory

backend-plugin-api: made defaultFactories internal
This commit is contained in:
Patrik Oldsberg
2022-09-05 13:36:32 +02:00
committed by GitHub
5 changed files with 29 additions and 12 deletions
@@ -28,15 +28,20 @@ export type ServiceRef<T> = {
*/
T: T;
toString(): string;
$$ref: 'service';
};
/**
* @internal
*/
export type InternalServiceRef<T> = ServiceRef<T> & {
/**
* The default factory that will be used to create service
* instances if no other factory is provided.
*/
defaultFactory?: (service: ServiceRef<T>) => Promise<ServiceFactory<T>>;
toString(): string;
$$ref: 'service';
__defaultFactory?: (service: ServiceRef<T>) => Promise<ServiceFactory<T>>;
};
/** @public */
@@ -70,12 +75,12 @@ export function createServiceRef<T>(options: {
get T(): T {
throw new Error(`tried to read ServiceRef.T of ${this}`);
},
defaultFactory,
toString() {
return `serviceRef{${options.id}}`;
},
$$ref: 'service', // TODO: declare
};
__defaultFactory: defaultFactory,
} as InternalServiceRef<T>;
}
/**