This repository has been archived on 2019-08-30. You can view files and clone it, but cannot push or open issues or pull requests.
SecureFileWrapper/lib/index.d.ts

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>;
}