version-bridge: updated API report + fixups

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2021-09-10 17:51:29 +02:00
parent ddedf7aab5
commit d6eb28c91a
4 changed files with 13 additions and 19 deletions
@@ -23,6 +23,7 @@ import { createVersionedValueMap, VersionedValue } from './VersionedValue';
* stored inside a global singleton.
*
* @param key - A key that uniquely identifies the context.
* @public
* @example
*
* ```ts
@@ -48,6 +49,7 @@ export function createVersionedContext<
* stored inside a global singleton.
*
* @param key - A key that uniquely identifies the context.
* @public
* @example
*
* ```ts
@@ -56,7 +58,7 @@ export function createVersionedContext<
* const myValue = versionedHolder.atVersion(1);
*
* // ...
* ````
* ```
*/
export function useVersionedContext<
Versions extends { [version in number]: any },
@@ -75,6 +77,7 @@ export function useVersionedContext<
* combinations of versions provided from a context.
*
* @param key - A key that uniquely identifies the context.
* @public
* @example
*
* ```ts
@@ -18,6 +18,8 @@
* The versioned value interface is a container for a set of values that
* can be looked up by version. It is intended to be used as a container
* for values that can be versioned independently of package versions.
*
* @public
*/
export type VersionedValue<Versions extends { [version: number]: any }> = {
atVersion<Version extends keyof Versions>(
@@ -27,6 +29,8 @@ export type VersionedValue<Versions extends { [version: number]: any }> = {
/**
* Creates a container for a map of versioned values that implements VersionedValue.
*
* @public
*/
export function createVersionedValueMap<
Versions extends { [version: number]: any },
@@ -32,6 +32,8 @@ const makeKey = (id: string) => `__@backstage/${id}__`;
/**
* Used to access a global singleton value, failing if it is not already set.
*
* @public
*/
export function getGlobalSingleton<T>(id: string): T {
const key = makeKey(id);
@@ -44,6 +46,8 @@ export function getGlobalSingleton<T>(id: string): T {
/**
* Serializes access to a global singleton value, with the first caller creating the value.
*
* @public
*/
export function getOrCreateGlobalSingleton<T>(
id: string,