techdocs-common: Use request/response in type names

This commit is contained in:
Himanshu Mishra
2020-12-08 16:07:34 +01:00
parent 2783ec0184
commit a3b99fab84
3 changed files with 8 additions and 8 deletions
@@ -21,7 +21,7 @@ import { Logger } from 'winston';
import { Entity, EntityName } from '@backstage/catalog-model';
import { Config } from '@backstage/config';
import { getHeadersForFileExtension, supportedFileType } from './helpers';
import { PublisherBase, PublisherBaseParams } from './types';
import { PublisherBase, PublishRequest } from './types';
export class GoogleGCSPublish implements PublisherBase {
static fromConfig(config: Config, logger: Logger): PublisherBase {
@@ -82,7 +82,7 @@ export class GoogleGCSPublish implements PublisherBase {
* Upload all the files from the generated `directory` to the GCS bucket.
* Directory structure used in the bucket is - entityNamespace/entityKind/entityName/index.html
*/
publish({ entity, directory }: PublisherBaseParams): Promise<{}> {
publish({ entity, directory }: PublishRequest): Promise<{}> {
return new Promise((resolve, reject) => {
// Path of all files to upload, relative to the root of the source directory
// e.g. ['index.html', 'sub-page/index.html', 'assets/images/favicon.png']
@@ -23,7 +23,7 @@ import {
PluginEndpointDiscovery,
} from '@backstage/backend-common';
import { Config } from '@backstage/config';
import { PublisherBase, PublisherBaseParams } from './types';
import { PublisherBase, PublishRequest } from './types';
/* `remoteUrl` is the URL which serves files from the local publisher's static directory. */
export type LocalPublishReturn = Promise<{ remoteUrl: string }>;
@@ -52,7 +52,7 @@ export class LocalPublish implements PublisherBase {
this.discovery = discovery;
}
publish({ entity, directory }: PublisherBaseParams): LocalPublishReturn {
publish({ entity, directory }: PublishRequest): LocalPublishReturn {
const entityNamespace = entity.metadata.namespace ?? 'default';
const publishDir = resolvePackagePath(
@@ -21,13 +21,13 @@ import express from 'express';
*/
export type PublisherType = 'local' | 'google_gcs';
export type PublisherBaseParams = {
export type PublishRequest = {
entity: Entity;
/* The Path to the directory where the generated files are stored. */
directory: string;
};
export type PublisherBaseReturn = Promise<{}>;
export type PublishResponse = {};
/**
* Base class for a TechDocs publisher (e.g. Local, Google GCS Bucket, AWS S3, etc.)
@@ -38,10 +38,10 @@ export interface PublisherBase {
/**
* Store the generated static files onto a storage service (either local filesystem or external service).
*
* @param options Object containing the entity from the service
* @param request Object containing the entity from the service
* catalog, and the directory that contains the generated static files from TechDocs.
*/
publish(options: PublisherBaseParams): PublisherBaseReturn;
publish(request: PublishRequest): Promise<PublishResponse>;
/**
* Retrieve TechDocs Metadata about a site e.g. name, contributors, last updated, etc.