From 47bd80f82b011372783118ee78d107b5653bfa1f Mon Sep 17 00:00:00 2001 From: marshall007 Date: Tue, 20 Sep 2016 14:17:05 -0500 Subject: [PATCH] fix return types for `.fetch()` and `.watch()`, export additional types Fixes #834 --- client/index.d.ts | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/client/index.d.ts b/client/index.d.ts index 91925c19d..11b2305d4 100644 --- a/client/index.d.ts +++ b/client/index.d.ts @@ -2,17 +2,21 @@ import { Observable } from 'rxjs'; declare namespace hz { + + interface Feed { + watch (options?: { rawChanges: boolean }): Observable; + fetch (): Observable; + } + 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; @@ -20,19 +24,18 @@ declare namespace hz { below (spec: any, bound?: Bound): TermBase; } - type WriteOp = Object | Object[]; - interface Collection extends TermBase { store (docs: WriteOp): Observable; upsert (docs: WriteOp): Observable; insert (docs: WriteOp): Observable; replace (docs: WriteOp): Observable; update (docs: WriteOp): Observable; + remove (docs: IdValue): Observable; - remove (docs: IdValue[]): Observable; + removeAll (docs: IdValue[]): Observable; } - interface User extends TermBase {} + interface User extends Feed {} interface HorizonInstance { (name: string): Collection; @@ -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;