This repository has been archived by the owner on Dec 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
interface.ts
45 lines (41 loc) · 1.6 KB
/
interface.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
export type Content = string | Buffer;
/**
* WriteStream: a write stream intended writing a batch file
*/
export interface WriteStream {
write(chunk: unknown, encoding?: string, callback?: (error: Error | null | undefined) => void): boolean;
write(chunk: unknown, cb?: (error: Error | null | undefined) => void): boolean;
end(cb?: () => void): void;
end(chunk?: unknown, cb?: () => void): void;
end(chunk?: unknown, encoding?: string, cb?: () => void): void;
}
/**
* ReadStream: a read stream intended reading a batch file
*/
export interface ReadStream {
read(chunk: unknown, size: number): void;
end(chunk: unknown, cb?: () => void): void;
end(chunk: unknown, encoding?: string, cb?: () => void): void;
}
/**
* PassThroughCallback: a callback intended for receiving a write stream to create a batch file
*/
export interface WriteStreamCallback {
(stream: WriteStream): Promise<void>;
}
/**
* StoreInterface is the interface a storage adapter is expected to implement to
* be used with high-level methods in this SDK. The require methods consist of
* an put function, a dequeue function and a get function.
*/
export interface StoreInterface {
/**
* putStream() takes a pass-through stream to upload data to chosen hosting solution and
* returns the URL of the file once stored.
*
* @param targetPath - The path to and name of file
* @param doWriteToStream - A callback function that receives a writable to stream data to the chosen hosting solution
* @returns The URL of the hosted file
*/
putStream: (targetPath: string, doWriteToStream: WriteStreamCallback) => Promise<URL>;
}