forked from hibas123/SecureFileWrapper
63 lines
1.9 KiB
TypeScript
63 lines
1.9 KiB
TypeScript
import Lock from "./lock";
|
|
export interface IFileVersion {
|
|
version: string;
|
|
time: Date;
|
|
preview: string;
|
|
deleted: boolean;
|
|
}
|
|
export interface IFile {
|
|
_id: string;
|
|
type: string;
|
|
name: string;
|
|
folder: string;
|
|
deleted: boolean;
|
|
active: IFileVersion;
|
|
versions: IFileVersion[];
|
|
user: string;
|
|
application: string;
|
|
}
|
|
export interface IHistory {
|
|
file: IFile;
|
|
history: IFileVersion[];
|
|
}
|
|
export declare class NoConnection extends Error {
|
|
type: string;
|
|
constructor();
|
|
}
|
|
export declare class Unauthorized extends Error {
|
|
type: string;
|
|
constructor();
|
|
}
|
|
export declare class NoPermission extends Error {
|
|
type: string;
|
|
constructor();
|
|
}
|
|
export declare class NotFound extends Error {
|
|
type: string;
|
|
constructor();
|
|
}
|
|
export declare class BadRequest extends Error {
|
|
type: string;
|
|
constructor();
|
|
}
|
|
export default class SecureFileWrapper {
|
|
private server;
|
|
private _jwtObservableServer;
|
|
jwtObservable: {
|
|
subscribe: (callback: import("./observable").ObserverCallback<((jwt: string) => void)[]>) => void;
|
|
unsubscribe: (callback: import("./observable").ObserverCallback<((jwt: string) => void)[]>) => void;
|
|
};
|
|
jwt: string;
|
|
auth_lock: Lock;
|
|
constructor(server: string);
|
|
getJWT(): Promise<void>;
|
|
makeRequest(endpoint: string, method: "POST" | "GET" | "PUT" | "DELETE", query: any, body?: ArrayBuffer | ArrayBufferView, second?: boolean): any;
|
|
list(folder?: string): Promise<IFile[]>;
|
|
create(name: string, data: ArrayBuffer | ArrayBufferView, type: "text" | "binary", folder?: string, preview?: string): Promise<IFile>;
|
|
get(id: string, version?: string): Promise<ArrayBuffer>;
|
|
update(id: string, data: ArrayBuffer | ArrayBufferView, preview?: string): Promise<IFile>;
|
|
delete(id: string): Promise<boolean>;
|
|
history(id: string): Promise<IHistory>;
|
|
restore(id: string, version: string): Promise<void>;
|
|
}
|