forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lls.d.ts
127 lines (103 loc) · 3.94 KB
/
lls.d.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// Type definitions for LargeLocalStorage v0.1.3
// Project: https://github.com/tantaman/LargeLocalStorage
// Definitions by: Borislav Zhivkov <https://github.com/borislavjivkov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace LargeLocalStorageInterfaces {
interface LargeLocalStorageService {
new(options: Options): LargeLocalStorageService;
initialized: Promise<number>;
/**
* Gets all of the attachments for a document.
*/
getAllAttachments(docKey?: string): Promise<Entry[]>;
/**
* Gets all attachments URLs for a document.
*/
getAllAttachmentURLs(docKey?: string): Promise<Entry[]>;
/**
* Get the attachment identified by attachKey
*/
getAttachment(attachKey: string): Promise<any>;
/**
* Get the attachment identified by docKey and attachKey
*/
getAttachment(docKey: string, attachKey: string): Promise<any>;
/**
* Get the URL for a given attachment.
*/
getAttachmentURL(attachKey: string): Promise<string>;
/**
* Get the URL for a given attachment.
*/
getAttachmentURL(docKey: string, attachKey: string): Promise<string>;
/**
* Returns the actual capacity of the storage or -1 if it is unknown.
*/
getCapacity(): number;
/**
* Get the contents of a document identified by docKey
*/
getContents(docKey: string): Promise<any>;
/**
* List all attachments under a given key. List all documents if no key is provided.
*/
ls(docKey?: string): Promise<string[]>;
/**
* Whether or not LLS is ready to store data. The initialized property can be used to await initialization.
*/
ready(): boolean;
/**
* Revoke the attachment URL as required by the underlying storage system.
*/
revokeAttachmentURL(url: string): void;
/**
* Remove the specified document and all of its attachments.
*/
rm(docKey?: string): Promise<any>;
/**
* Remove an attachment from a document.
*/
rmAttachment(docKey: string, attachKey: string): Promise<void>;
/**
* Set an attachment for a given document. Identified by attachKey.
*/
setAttachment(attachKey: string, attachment: any): Promise<void>;
/**
* Set an attachment for a given document. Identified by docKey and attachKey.
*/
setAttachment(docKey: string, attachKey: string, attachment: any): Promise<void>;
/**
* Set the contents identified by docKey to data. The document will be created if it does not exist.
*/
setContents(docKey: string, data: any): Promise<void>;
}
interface Options {
/**
* Desired capacity in bytes.
*/
size: number;
/**
* Optional name for your LLS database. Defaults to lls. This is the name given to the underlying IndexedDB or WebSQL DB or FSAPI Folder. LLS's with different names are independent.
*/
name?: string;
/**
* Force LLS to use a specific storage implementation: 'IndexedDB' or 'WebSQL' or 'FilesystemAPI'.
*/
forceProvider?: string;
}
interface Entry {
data: any;
docKey: string;
attachKey: string;
url: string;
}
interface Promise<T> {
then<U>(onFulfilled?: (value: T) => U | Promise<U>, onRejected?: (error: any) => U | Promise<U>): Promise<U>;
then<U>(onFulfilled?: (value: T) => U | Promise<U>, onRejected?: (error: any) => void): Promise<U>;
catch<U>(onRejected?: (error: any) => U | Promise<U>): Promise<U>;
}
}
declare module "lls" {
var LargeLocalStorage: LargeLocalStorageInterfaces.LargeLocalStorageService;
export = LargeLocalStorage;
}