@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/backend-plugin-api': patch
|
||||
---
|
||||
|
||||
Add a `toJSON` on refs so that they can appear in expectations in jest tests
|
||||
@@ -17,7 +17,9 @@
|
||||
import { BackendFeature } from '../../types';
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* A reference to a backend service. You can use these references to mark
|
||||
* dependencies on services and having their implementations injected
|
||||
* automatically.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
@@ -39,6 +41,11 @@ export type ServiceRef<
|
||||
*/
|
||||
scope: TScope;
|
||||
|
||||
/**
|
||||
* Marks whether the service is a multiton or not. Multiton services the
|
||||
* opposite of singletons - they can be provided many times, and when depended
|
||||
* on, you receive an array of all provided instances.
|
||||
*/
|
||||
multiton?: TInstances extends 'multiton' ? true : false;
|
||||
|
||||
/**
|
||||
@@ -142,6 +149,15 @@ export function createServiceRef<
|
||||
toString() {
|
||||
return `serviceRef{${options.id}}`;
|
||||
},
|
||||
toJSON() {
|
||||
// This avoids accidental calls to T happening e.g. in tests
|
||||
return {
|
||||
$$type: '@backstage/ServiceRef',
|
||||
id,
|
||||
scope,
|
||||
multiton,
|
||||
};
|
||||
},
|
||||
$$type: '@backstage/ServiceRef',
|
||||
__defaultFactory: defaultFactory,
|
||||
} as ServiceRef<TService, typeof scope, TInstances> & {
|
||||
|
||||
Reference in New Issue
Block a user