1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | import * as nano from 'nano';
|
16 | import { CoreOptions, Request } from 'request';
|
17 |
|
18 | declare function cloudant(
|
19 | config: cloudant.Configuration | string,
|
20 | callback?: (error: any, client?: cloudant.ServerScope, pong?: any) => void
|
21 | ): cloudant.ServerScope;
|
22 |
|
23 | declare namespace cloudant {
|
24 | type Callback<R> = (error: any, response: R, headers?: any) => void;
|
25 |
|
26 | interface ApiKey {
|
27 | key: string;
|
28 | password: string;
|
29 | }
|
30 |
|
31 | interface Configuration {
|
32 | account?: string;
|
33 | password?: string;
|
34 | vcapInstanceName?: string;
|
35 | vcapServices?: string;
|
36 | vcapServiceName?: string;
|
37 | url?: string;
|
38 | cookie?: string;
|
39 | requestDefaults?: CoreOptions;
|
40 | log?(id: string, args: any): void;
|
41 | parseUrl?: boolean;
|
42 | request?(params: any): void;
|
43 | plugins?: any;
|
44 | maxAttempt?: number;
|
45 | }
|
46 |
|
47 | interface CORS {
|
48 | enable_cors: boolean;
|
49 | allow_credentials: boolean;
|
50 | origins: string[];
|
51 | }
|
52 |
|
53 | interface DatabasePartitionInfo {
|
54 | db_name: string;
|
55 | sizes: {
|
56 | active: number;
|
57 | external: number;
|
58 | };
|
59 | partition: string;
|
60 | doc_count: number;
|
61 | doc_del_count: number;
|
62 | }
|
63 |
|
64 | interface GeoParams {
|
65 | include_docs?: boolean;
|
66 | bookmark?: string;
|
67 | format?: string;
|
68 | limit?: number;
|
69 | skip?: number;
|
70 | stale?: string;
|
71 | bbox?: number[];
|
72 | lat?: number;
|
73 | lon?: number;
|
74 | rangex?: number;
|
75 | rangey?: number;
|
76 | radius?: number;
|
77 | g?: any;
|
78 | relation?: string;
|
79 | nearest?: boolean;
|
80 | }
|
81 |
|
82 | interface GeoResult {
|
83 | bookmark: string;
|
84 | features: any[];
|
85 | row: any[];
|
86 | type: string;
|
87 | }
|
88 |
|
89 | interface Query {
|
90 |
|
91 | (definition?: any, callback?: Callback<any>): Promise<any>;
|
92 |
|
93 |
|
94 | del(spec: QueryDeleteSpec, callback?: Callback<any>): Promise<any>;
|
95 | }
|
96 |
|
97 | interface QueryDeleteSpec {
|
98 | ddoc: string;
|
99 | name: string;
|
100 | }
|
101 |
|
102 | interface Security {
|
103 | [key: string]: any;
|
104 | }
|
105 |
|
106 |
|
107 |
|
108 |
|
109 | interface ServerScope extends nano.ServerScope {
|
110 | db: nano.DatabaseScope;
|
111 | use(db: string): DocumentScope<any>;
|
112 | scope(db: string): DocumentScope<any>;
|
113 |
|
114 |
|
115 | generate_api_key(callback?: Callback<ApiKey>): Promise<any>;
|
116 |
|
117 |
|
118 | get_cors(callback?: Callback<any>): Promise<any>;
|
119 |
|
120 |
|
121 | ping(callback?: Callback<any>): Promise<any>;
|
122 |
|
123 |
|
124 | set_cors(cors: CORS, callback?: Callback<any>): Promise<any>;
|
125 | }
|
126 |
|
127 |
|
128 |
|
129 |
|
130 | interface DocumentScope<D> extends nano.DocumentScope<D> {
|
131 |
|
132 | index: Query;
|
133 |
|
134 |
|
135 | bulk_get(options: nano.BulkModifyDocsWrapper, callback?: Callback<any>): Promise<any>;
|
136 |
|
137 |
|
138 | geo(
|
139 | designname: string,
|
140 | docname: string,
|
141 | params: GeoParams,
|
142 | callback?: Callback<GeoResult>
|
143 | ): Promise<any>;
|
144 |
|
145 |
|
146 | get_security(callback?: Callback<Security>): Promise<any>;
|
147 |
|
148 |
|
149 | set_security(Security: Security, callback?: Callback<any>): Promise<any>;
|
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 | partitionInfo(
|
158 | partitionKey: string,
|
159 | callback?: Callback<DatabasePartitionInfo>
|
160 | ): Promise<DatabasePartitionInfo>;
|
161 |
|
162 | partitionedFind(
|
163 | partitionKey: string,
|
164 | selector: nano.MangoQuery,
|
165 | callback?: Callback<nano.MangoResponse<D>>
|
166 | ): Promise<nano.MangoResponse<D>>;
|
167 |
|
168 | partitionedFindAsStream(
|
169 | partitionKey: string,
|
170 | selector: nano.MangoQuery
|
171 | ): Request;
|
172 |
|
173 | partitionedList(
|
174 | partitionKey: string,
|
175 | params: nano.DocumentFetchParams,
|
176 | callback?: Callback<nano.DocumentListResponse<D>>
|
177 | ): Promise<nano.DocumentListResponse<D>>;
|
178 |
|
179 | partitionedListAsStream(
|
180 | partitionKey: string,
|
181 | params: nano.DocumentFetchParams
|
182 | ): Request;
|
183 |
|
184 | partitionedSearch<V>(
|
185 | partitionKey: string,
|
186 | designname: string,
|
187 | searchname: string,
|
188 | params: nano.DocumentSearchParams,
|
189 | callback?: Callback<nano.DocumentSearchResponse<V>>
|
190 | ): Promise<nano.DocumentSearchResponse<V>>;
|
191 |
|
192 | partitionedSearchAsStream<V>(
|
193 | partitionKey: string,
|
194 | designname: string,
|
195 | searchname: string,
|
196 | params: nano.DocumentSearchParams
|
197 | ): Request;
|
198 |
|
199 | partitionedView<V>(
|
200 | partitionKey: string,
|
201 | designname: string,
|
202 | viewname: string,
|
203 | params: nano.DocumentViewParams,
|
204 | callback?: Callback<nano.DocumentViewResponse<V,D>>
|
205 | ): Promise<nano.DocumentViewResponse<V,D>>;
|
206 |
|
207 | partitionedViewAsStream<V>(
|
208 | partitionKey: string,
|
209 | designname: string,
|
210 | viewname: string,
|
211 | params: nano.DocumentViewParams
|
212 | ): Request;
|
213 | }
|
214 | }
|
215 |
|
216 | export = cloudant;
|