From b2426f70b2a52da878b6df1b37133643a7a5f8af Mon Sep 17 00:00:00 2001 From: tdurieux Date: Thu, 12 Aug 2021 18:52:08 +0200 Subject: [PATCH] improve type documentation --- src/types.ts | 54 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/src/types.ts b/src/types.ts index e5d97e7..a6faca1 100644 --- a/src/types.ts +++ b/src/types.ts @@ -32,29 +32,73 @@ export interface SourceBase { export type Source = GitHubDownload | GitHubStream | Zip; export interface StorageBase { + /** + * The type of storage + */ type: string; + /** + * check if the path exists + * @param path the path to check + */ exists(path: string): Promise; + /** + * Read the content of a file + * @param path the path to the file + */ read(path: string): stream.Readable; + /** + * Write data to a file + * @param path the path to the file + * @param data the content of the file + */ write(path: string, data: Buffer): Promise; + /** + * List the files from dir + * @param dir + */ listFiles(dir: string): Promise; - extractTar(p: string, data: stream.Readable): Promise; + /** + * Extract the content of tar to dir + * @param dir + * @param tar + */ + extractTar(dir: string, tar: stream.Readable): Promise; - rm(path: string): Promise; + /** + * Remove the path + * @param dir + */ + rm(dir: string): Promise; + /** + * Archive the content of dir + * @param dir + * @param opt + */ archive( dir: string, opt?: { + /** + * Archive format + */ format?: "zip" | "tar"; + /** + * Transformer to apply on the content of the file + */ fileTransformer?: (p: any) => Transformer; } ): archiver.Archiver; - mk(path: string): Promise; + /** + * Create a directory + * @param dir + */ + mk(dir: string): Promise; } export type Storage = S3Storage | FileSystem; @@ -75,12 +119,12 @@ export type RepositoryStatus = export type SourceStatus = "available" | "unavailable"; +export type TreeElement = Tree | TreeFile; + export interface Tree { [key: string]: TreeElement; } -export type TreeElement = Tree | TreeFile; - export interface TreeFile { sha: string; size: number;