refactor(techdocs-common): clean up publish api
Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
@@ -17,6 +17,10 @@ export { Publisher } from './publish';
|
||||
export type {
|
||||
PublisherBase,
|
||||
PublisherType,
|
||||
TechDocsMetadata,
|
||||
PublisherFactory,
|
||||
PublishRequest,
|
||||
PublishResponse,
|
||||
MigrateRequest,
|
||||
ReadinessResponse,
|
||||
TechDocsMetadata,
|
||||
} from './types';
|
||||
|
||||
@@ -14,29 +14,28 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { PluginEndpointDiscovery } from '@backstage/backend-common';
|
||||
import { Config } from '@backstage/config';
|
||||
import { Logger } from 'winston';
|
||||
import { AwsS3Publish } from './awsS3';
|
||||
import { AzureBlobStoragePublish } from './azureBlobStorage';
|
||||
import { GoogleGCSPublish } from './googleStorage';
|
||||
import { LocalPublish } from './local';
|
||||
import { OpenStackSwiftPublish } from './openStackSwift';
|
||||
import { PublisherBase, PublisherType } from './types';
|
||||
|
||||
type factoryOptions = {
|
||||
logger: Logger;
|
||||
discovery: PluginEndpointDiscovery;
|
||||
};
|
||||
import { PublisherFactory, PublisherBase, PublisherType } from './types';
|
||||
|
||||
/**
|
||||
* Factory class to create a TechDocs publisher based on defined publisher type in app config.
|
||||
* Uses `techdocs.publisher.type`.
|
||||
* @public
|
||||
*/
|
||||
export class Publisher {
|
||||
/**
|
||||
* Returns a instance of Tech Docs publisher
|
||||
* @param config - A Backstage configuration
|
||||
* @param options - Options for configuring the publisher factory
|
||||
*/
|
||||
static async fromConfig(
|
||||
config: Config,
|
||||
{ logger, discovery }: factoryOptions,
|
||||
{ logger, discovery }: PublisherFactory,
|
||||
): Promise<PublisherBase> {
|
||||
const publisherType = (config.getOptionalString(
|
||||
'techdocs.publisher.type',
|
||||
|
||||
@@ -14,10 +14,22 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { Entity, EntityName } from '@backstage/catalog-model';
|
||||
import { PluginEndpointDiscovery } from '@backstage/backend-common';
|
||||
import { Logger } from 'winston';
|
||||
import express from 'express';
|
||||
|
||||
/**
|
||||
* Options for building publishers
|
||||
* @public
|
||||
*/
|
||||
export type PublisherFactory = {
|
||||
logger: Logger;
|
||||
discovery: PluginEndpointDiscovery;
|
||||
};
|
||||
|
||||
/**
|
||||
* Key for all the different types of TechDocs publishers that are supported.
|
||||
* @public
|
||||
*/
|
||||
export type PublisherType =
|
||||
| 'local'
|
||||
@@ -26,6 +38,10 @@ export type PublisherType =
|
||||
| 'azureBlobStorage'
|
||||
| 'openStackSwift';
|
||||
|
||||
/**
|
||||
* Request publish definition
|
||||
* @public
|
||||
*/
|
||||
export type PublishRequest = {
|
||||
entity: Entity;
|
||||
/* The Path to the directory where the generated files are stored. */
|
||||
@@ -35,6 +51,7 @@ export type PublishRequest = {
|
||||
/**
|
||||
* Response containing metadata about where files were published and what may
|
||||
* have been published or updated.
|
||||
* @public
|
||||
*/
|
||||
export type PublishResponse = {
|
||||
/**
|
||||
@@ -51,7 +68,6 @@ export type PublishResponse = {
|
||||
|
||||
/**
|
||||
* Result for the validation check.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type ReadinessResponse = {
|
||||
@@ -62,6 +78,7 @@ export type ReadinessResponse = {
|
||||
/**
|
||||
* Type to hold metadata found in techdocs_metadata.json and associated with each site
|
||||
* @param etag - ETag of the resource used to generate the site. Usually the latest commit sha of the source repository.
|
||||
* @public
|
||||
*/
|
||||
export type TechDocsMetadata = {
|
||||
site_name: string;
|
||||
@@ -71,6 +88,10 @@ export type TechDocsMetadata = {
|
||||
files?: string[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Tech Docs entity triplet migration request
|
||||
* @public
|
||||
*/
|
||||
export type MigrateRequest = {
|
||||
/**
|
||||
* Whether or not to remove the source file. Defaults to false (acting like a
|
||||
|
||||
Reference in New Issue
Block a user