Skip to content

Commit

Permalink
fix return types for .fetch() and .watch(), export additional types
Browse files Browse the repository at this point in the history
  • Loading branch information
marshall007 committed Sep 20, 2016
1 parent 4b72b87 commit 47bd80f
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions client/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,40 @@
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 {
watch (options?: { rawChanges: boolean }): TermBase;
fetch (): TermBase;

findAll (...values: IdValue[]): TermBase;
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;
}

type WriteOp = Object | Object[];

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>;
remove (docs: IdValue[]): Observable<any>;
removeAll (docs: IdValue[]): Observable<any>;
}

interface User extends TermBase {}
interface User extends Feed {}

interface HorizonInstance {
(name: string): Collection;
Expand Down Expand Up @@ -70,5 +73,11 @@ declare namespace hz {
}
}

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;

0 comments on commit 47bd80f

Please sign in to comment.