move TechDocsStorage api from @backstage/plugin-techdocs to @backstage/plugin-techdocs-react

Signed-off-by: Anders Näsman <andersn@spotify.com>
This commit is contained in:
Anders Näsman
2022-04-25 15:51:17 +02:00
parent 54f06e9c00
commit a68de3c984
8 changed files with 78 additions and 9 deletions
+29
View File
@@ -22,6 +22,9 @@ export function createTechDocsAddonExtension<TComponentProps>(
// @alpha (undocumented)
export const defaultTechDocsReaderPageValue: TechDocsReaderPageValue;
// @public
export type SyncResult = 'cached' | 'updated';
// @alpha
export const TECHDOCS_ADDONS_WRAPPER_KEY = 'techdocs.addons.wrapper.v1';
@@ -103,6 +106,32 @@ export type TechDocsReaderPageValue = {
onReady?: () => void;
};
// @public
export interface TechDocsStorageApi {
// (undocumented)
getApiOrigin(): Promise<string>;
// (undocumented)
getBaseUrl(
oldBaseUrl: string,
entityId: CompoundEntityRef,
path: string,
): Promise<string>;
// (undocumented)
getBuilder(): Promise<string>;
// (undocumented)
getEntityDocs(entityId: CompoundEntityRef, path: string): Promise<string>;
// (undocumented)
getStorageUrl(): Promise<string>;
// (undocumented)
syncEntityDocs(
entityId: CompoundEntityRef,
logHandler?: (line: string) => void,
): Promise<SyncResult>;
}
// @public
export const techdocsStorageApiRef: ApiRef<TechDocsStorageApi>;
// @alpha
export const useShadowRoot: () => ShadowRoot | undefined;
+37
View File
@@ -39,3 +39,40 @@ export interface TechDocsApi {
export const techdocsApiRef = createApiRef<TechDocsApi>({
id: 'plugin.techdocs.service',
});
/**
* The outcome of a docs sync operation.
*
* @public
*/
export type SyncResult = 'cached' | 'updated';
/**
* API which talks to TechDocs storage to fetch files to render.
*
* @public
*/
export interface TechDocsStorageApi {
getApiOrigin(): Promise<string>;
getStorageUrl(): Promise<string>;
getBuilder(): Promise<string>;
getEntityDocs(entityId: CompoundEntityRef, path: string): Promise<string>;
syncEntityDocs(
entityId: CompoundEntityRef,
logHandler?: (line: string) => void,
): Promise<SyncResult>;
getBaseUrl(
oldBaseUrl: string,
entityId: CompoundEntityRef,
path: string,
): Promise<string>;
}
/**
* Utility API reference for the {@link TechDocsStorageApi}.
*
* @public
*/
export const techdocsStorageApiRef = createApiRef<TechDocsStorageApi>({
id: 'plugin.techdocs.storageservice',
});
+2 -2
View File
@@ -26,8 +26,8 @@ export {
TechDocsAddons,
TECHDOCS_ADDONS_WRAPPER_KEY,
} from './addons';
export { techdocsApiRef } from './api';
export type { TechDocsApi } from './api';
export { techdocsApiRef, techdocsStorageApiRef } from './api';
export type { SyncResult, TechDocsApi, TechDocsStorageApi } from './api';
export {
defaultTechDocsReaderPageValue,
TechDocsReaderPageProvider,