-
Notifications
You must be signed in to change notification settings - Fork 349
/
index.d.ts
86 lines (64 loc) · 2.27 KB
/
index.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
import { Observable } from 'rxjs';
declare namespace hz {
interface Feed {
watch (options?: { rawChanges: boolean }): Observable<any>;
fetch (): Observable<any>;
}
type Bound = 'open' | 'closed';
type Direction = 'ascending' | 'descending';
type Primitive = boolean | number | string | Date;
type IdValue = Primitive | Primitive[] | { id: Primitive };
type WriteOp = Object | Object[];
interface TermBase extends Feed {
find (value: IdValue): TermBase;
findAll (...values: IdValue[]): TermBase;
order (fields: string[], direction?: Direction): TermBase;
limit (size: Number): TermBase;
above (spec: any, bound?: Bound): TermBase;
below (spec: any, bound?: Bound): TermBase;
}
interface Collection extends TermBase {
store (docs: WriteOp): Observable<any>;
upsert (docs: WriteOp): Observable<any>;
insert (docs: WriteOp): Observable<any>;
replace (docs: WriteOp): Observable<any>;
update (docs: WriteOp): Observable<any>;
remove (docs: IdValue): Observable<any>;
removeAll (docs: IdValue[]): Observable<any>;
}
interface User extends Feed {}
interface HorizonInstance {
(name: string): Collection;
currentUser (): User;
hasAuthToken (): boolean;
authEndpoint (name: string): Observable<string>;
aggregate (aggs: any): TermBase;
model (fn: Function): TermBase;
disconnect (): void;
connect (): void;
status (): Observable<any>;
onReady (): Observable<any>;
onDisconnected (): Observable<any>;
onSocketError (): Observable<any>;
}
interface HorizonOptions {
host?: string;
path?: string;
secure?: boolean;
authType?: string;
lazyWrites?: boolean;
keepalive?: number;
WebSocketCtor?: any;
}
interface Horizon {
(options: HorizonOptions): HorizonInstance;
clearAuthTokens (): void;
}
}
export type HorizonOptions = hz.HorizonOptions;
export type HorizonInstance = hz.HorizonInstance;
export type TermBase = hz.TermBase;
export type Collection = hz.Collection;
export type User = hz.User;
declare var Horizon: hz.Horizon;
export default Horizon;