From e3c1bb0e63fbd6adadcf7771ca41418976ff7705 Mon Sep 17 00:00:00 2001 From: Masoud Ghorbani Date: Sun, 18 Aug 2024 19:35:32 +0200 Subject: [PATCH] feat: update BaseProvider class documentation --- src/providers/base.ts | 30 +++++++++--------------------- src/types.ts | 4 +--- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/src/providers/base.ts b/src/providers/base.ts index b2aae77..d2d6324 100644 --- a/src/providers/base.ts +++ b/src/providers/base.ts @@ -6,7 +6,7 @@ import { InvalidConfigError } from '../errors' import { Storage, customOptions } from '../schemas/input' import { sync, syncMetadata, syncTags } from '../storages/s3/buckets' import { - ISyncCloudStorage, + IBaseProvider, MethodReturn, ProviderOptions, SyncMetadataReturn, @@ -16,10 +16,10 @@ import { import { logger } from '../utils/logger' /** - * Base Sync Cloud Storage class. - * @implements ISyncCloudStorage + * Base provider class for cloud frameworks. + * @implements {IBaseProvider} */ -export abstract class BaseProvider implements ISyncCloudStorage { +export abstract class BaseProvider implements IBaseProvider { readonly servicePath: string readonly options: ProviderOptions readonly client: S3Client @@ -51,12 +51,9 @@ export abstract class BaseProvider implements ISyncCloudStorage { /** * Get S3 client. - * @returns {S3Client} * @memberof BaseProvider * @see https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-s3 - * - * @example - * const client = this.getS3Client() + * @returns {S3Client} */ getS3Client(): S3Client { const endpoint = this.options.syncCloudStorage.offline @@ -72,11 +69,8 @@ export abstract class BaseProvider implements ISyncCloudStorage { /** * Sync storages. - * @private * @memberof BaseProvider * @returns {Promise<{ result: SyncResult[] }>} - * @example - * const result = await this.storages() */ async storages(): Promise<{ result: SyncResult[] }> { const isPluginDisable = this.disableCheck().result @@ -102,8 +96,6 @@ export abstract class BaseProvider implements ISyncCloudStorage { * @memberof BaseProvider * @see https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-s3 * @returns {Promise[]>} - * @example - * const result = await this.metadata() */ async metadata(): Promise[]> { return await Promise.allSettled( @@ -113,12 +105,9 @@ export abstract class BaseProvider implements ISyncCloudStorage { /** * Sync tags. - * @private * @memberof BaseProvider * @see https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-s3 * @returns {Promise} - * @example - * const result = await this.tags() */ async tags(): Promise { const isPluginDisable = this.disableCheck().result @@ -137,11 +126,8 @@ export abstract class BaseProvider implements ISyncCloudStorage { * @private * @returns {Promise} * @memberof BaseProvider - * - * @example - * await this.onExit() */ - async onExit(): Promise { + private async onExit(): Promise { if (this.client) { this.client.destroy() } @@ -149,9 +135,11 @@ export abstract class BaseProvider implements ISyncCloudStorage { /** * Check if the plugin is disabled. + * @private + * @memberof BaseProvider * @returns {MethodReturn} */ - disableCheck(): MethodReturn { + private disableCheck(): MethodReturn { if (this.options.syncCloudStorage.disabled) { logger.warning('SyncCloudStorage is disabled!') return { result: true } diff --git a/src/types.ts b/src/types.ts index 3193226..282c0ef 100644 --- a/src/types.ts +++ b/src/types.ts @@ -100,12 +100,10 @@ export const isFulfilledSyncResult = ( export type ProviderName = 'serverless' | 'cdk' -export interface ISyncCloudStorage { +export interface IBaseProvider { storages(servicePath: string): Promise<{ result: SyncResult[] }> metadata(): Promise[]> tags(): Promise - onExit(): Promise - disableCheck(): MethodReturn } export type Provider = IServerless | Construct