mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-07-07 14:17:51 +02:00
improve type documentation
This commit is contained in:
+49
-5
@@ -32,29 +32,73 @@ export interface SourceBase {
|
|||||||
export type Source = GitHubDownload | GitHubStream | Zip;
|
export type Source = GitHubDownload | GitHubStream | Zip;
|
||||||
|
|
||||||
export interface StorageBase {
|
export interface StorageBase {
|
||||||
|
/**
|
||||||
|
* The type of storage
|
||||||
|
*/
|
||||||
type: string;
|
type: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check if the path exists
|
||||||
|
* @param path the path to check
|
||||||
|
*/
|
||||||
exists(path: string): Promise<boolean>;
|
exists(path: string): Promise<boolean>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read the content of a file
|
||||||
|
* @param path the path to the file
|
||||||
|
*/
|
||||||
read(path: string): stream.Readable;
|
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<void>;
|
write(path: string, data: Buffer): Promise<void>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List the files from dir
|
||||||
|
* @param dir
|
||||||
|
*/
|
||||||
listFiles(dir: string): Promise<Tree>;
|
listFiles(dir: string): Promise<Tree>;
|
||||||
|
|
||||||
extractTar(p: string, data: stream.Readable): Promise<void>;
|
/**
|
||||||
|
* Extract the content of tar to dir
|
||||||
|
* @param dir
|
||||||
|
* @param tar
|
||||||
|
*/
|
||||||
|
extractTar(dir: string, tar: stream.Readable): Promise<void>;
|
||||||
|
|
||||||
rm(path: string): Promise<void>;
|
/**
|
||||||
|
* Remove the path
|
||||||
|
* @param dir
|
||||||
|
*/
|
||||||
|
rm(dir: string): Promise<void>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Archive the content of dir
|
||||||
|
* @param dir
|
||||||
|
* @param opt
|
||||||
|
*/
|
||||||
archive(
|
archive(
|
||||||
dir: string,
|
dir: string,
|
||||||
opt?: {
|
opt?: {
|
||||||
|
/**
|
||||||
|
* Archive format
|
||||||
|
*/
|
||||||
format?: "zip" | "tar";
|
format?: "zip" | "tar";
|
||||||
|
/**
|
||||||
|
* Transformer to apply on the content of the file
|
||||||
|
*/
|
||||||
fileTransformer?: (p: any) => Transformer;
|
fileTransformer?: (p: any) => Transformer;
|
||||||
}
|
}
|
||||||
): archiver.Archiver;
|
): archiver.Archiver;
|
||||||
|
|
||||||
mk(path: string): Promise<void>;
|
/**
|
||||||
|
* Create a directory
|
||||||
|
* @param dir
|
||||||
|
*/
|
||||||
|
mk(dir: string): Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Storage = S3Storage | FileSystem;
|
export type Storage = S3Storage | FileSystem;
|
||||||
@@ -75,12 +119,12 @@ export type RepositoryStatus =
|
|||||||
|
|
||||||
export type SourceStatus = "available" | "unavailable";
|
export type SourceStatus = "available" | "unavailable";
|
||||||
|
|
||||||
|
export type TreeElement = Tree | TreeFile;
|
||||||
|
|
||||||
export interface Tree {
|
export interface Tree {
|
||||||
[key: string]: TreeElement;
|
[key: string]: TreeElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TreeElement = Tree | TreeFile;
|
|
||||||
|
|
||||||
export interface TreeFile {
|
export interface TreeFile {
|
||||||
sha: string;
|
sha: string;
|
||||||
size: number;
|
size: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user