forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
milkcocoa.d.ts
75 lines (68 loc) · 2.24 KB
/
milkcocoa.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
// Type definitions for Milkcocoa 0.2.8
// Project: https://mlkcca.com/
// Definitions by: odangosan <https://github.com/odangosan>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// Api Reference : https://mlkcca.com/document/api-js.html
declare module milkcocoa {
class MilkCocoa {
constructor(host: string, callback?: Function);
dataStore(path: string): DataStore;
addAccount(email: string, password: string, options?: {}, callback?: (err: MilkCocoa.Error.AddAccount, user: User) => void): void;
login(email: string, password: string, callback: (err: MilkCocoa.Error.Login, user: User) => void): void;
logout(callback?: (err: string) => void): void;
getCurrentUser(callback: (err: MilkCocoa.Error.GetCurrentUser, user: { id: string }) => void): void;
}
module MilkCocoa {
module Error {
enum AddAccount {
// FormatError = 1, AlreadyExist = 2
FormatError, AlreadyExist
}
enum Login {
// FormatError = 1, LoginError = 2, EmailNotVerificated = 3
FormatError, LoginError, EmailNotVerificated
}
enum GetCurrentUser {
// NotLoggedIn = 1
NotLoggedIn
}
}
}
interface DataStore {
push(object: {}, callback?: (data: DataStoreCallbackData) => void): void;
set(id: string, data: {}): void;
remove(id: string): void;
send(object: {}): void;
// event push, remove, set, send
on(event: string, callback: (data: DataStoreCallbackData) => void): void;
off(event: string): void;
get(id: string, callback: (data: {}) => void): void;
query(condition?: {}): Query;
child(path: string): DataStore;
parent(): DataStore;
root(): DataStore;
}
interface DataStoreCallbackData {
err: string;
path: string;
id: string;
value: any;
}
interface Query {
done(callback: (data: any) => void): void;
limit(number: number): Query;
skip(index: number): Query;
// mode asc, desc
sort(mode: string): Query;
}
interface User {
id: string;
email: string;
option: {};
}
}
import MilkCocoa = milkcocoa.MilkCocoa;
import User = milkcocoa.User;
import Query = milkcocoa.Query;
import DataStore = milkcocoa.DataStore;
import DataStoreCallbackData = milkcocoa.DataStoreCallbackData;