backend-plugin-api: align opaque type markers

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2023-02-06 17:59:48 +01:00
parent 2c68a05fd3
commit 181c03edb5
7 changed files with 14 additions and 9 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/backend-plugin-api': patch
---
Aligned opaque type markers to all use a `$$type` property with namespacing.
+2 -2
View File
@@ -275,7 +275,7 @@ export type ExtensionPoint<T> = {
id: string;
T: T;
toString(): string;
$$ref: 'extension-point';
$$type: '@backstage/ExtensionPoint';
};
// @public
@@ -490,7 +490,7 @@ export type ServiceRef<
scope: TScope;
T: TService;
toString(): string;
$$ref: 'service';
$$type: '@backstage/ServiceRef';
};
// @public (undocumented)
@@ -44,7 +44,7 @@ export type ServiceRef<
toString(): string;
$$ref: 'service';
$$type: '@backstage/ServiceRef';
};
/** @public */
@@ -119,7 +119,7 @@ export function createServiceRef<TService>(
toString() {
return `serviceRef{${config.id}}`;
},
$$ref: 'service', // TODO: declare
$$type: '@backstage/ServiceRef',
__defaultFactory: defaultFactory,
} as ServiceRef<TService, typeof scope> & {
__defaultFactory?: (
@@ -48,7 +48,7 @@ describe('createSharedEnvironment', () => {
expect(env).toBeDefined();
const internalEnv = env() as unknown as InternalSharedBackendEnvironment;
expect(internalEnv).toEqual({
$$type: 'SharedBackendEnvironment',
$$type: '@backstage/SharedBackendEnvironment',
version: 'v1',
services: undefined,
});
@@ -31,7 +31,7 @@ export interface SharedBackendEnvironmentConfig {
* @public
*/
export interface SharedBackendEnvironment {
$$type: 'SharedBackendEnvironment';
$$type: '@backstage/SharedBackendEnvironment';
// NOTE: This type is opaque in order to allow for future API evolution without
// cluttering the external API. For example we might want to add support
@@ -93,7 +93,7 @@ export function createSharedEnvironment<
// Here to ensure type safety in this internal implementation.
const env: SharedBackendEnvironment & InternalSharedBackendEnvironment = {
$$type: 'SharedBackendEnvironment',
$$type: '@backstage/SharedBackendEnvironment',
version: 'v1',
services,
};
@@ -55,7 +55,7 @@ export function createExtensionPoint<T>(
toString() {
return `extensionPoint{${config.id}}`;
},
$$ref: 'extension-point', // TODO: declare
$$type: '@backstage/ExtensionPoint',
};
}
@@ -32,7 +32,7 @@ export type ExtensionPoint<T> = {
toString(): string;
$$ref: 'extension-point';
$$type: '@backstage/ExtensionPoint';
};
/**