1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | import * as nano from 'nano';
|
16 | import { CoreOptions } 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 | url?: string;
|
37 | cookie?: string;
|
38 | requestDefaults?: CoreOptions;
|
39 | log?(id: string, args: any): void;
|
40 | parseUrl?: boolean;
|
41 | request?(params: any): void;
|
42 | plugins?: any;
|
43 | maxAttempt?: number;
|
44 | }
|
45 |
|
46 | interface CORS {
|
47 | enable_cors: boolean;
|
48 | allow_credentials: boolean;
|
49 | origins: string[];
|
50 | }
|
51 |
|
52 | interface GeoParams {
|
53 | include_docs?: boolean;
|
54 | bookmark?: string;
|
55 | format?: string;
|
56 | limit?: number;
|
57 | skip?: number;
|
58 | stale?: string;
|
59 | bbox?: number[];
|
60 | lat?: number;
|
61 | lon?: number;
|
62 | rangex?: number;
|
63 | rangey?: number;
|
64 | radius?: number;
|
65 | g?: any;
|
66 | relation?: string;
|
67 | nearest?: boolean;
|
68 | }
|
69 |
|
70 | interface GeoResult {
|
71 | bookmark: string;
|
72 | features: any[];
|
73 | row: any[];
|
74 | type: string;
|
75 | }
|
76 |
|
77 | interface Query {
|
78 |
|
79 | (definition?: any, callback?: Callback<any>): Promise<any>;
|
80 |
|
81 |
|
82 | del(spec: QueryDeleteSpec, callback?: Callback<any>): Promise<any>;
|
83 | }
|
84 |
|
85 | interface QueryDeleteSpec {
|
86 | ddoc: string;
|
87 | name: string;
|
88 | }
|
89 |
|
90 | interface SearchParams {
|
91 | q: string;
|
92 | include_docs?: boolean;
|
93 | bookmark?: string;
|
94 | limit?: number;
|
95 | skip?: number;
|
96 | stale?: string;
|
97 | }
|
98 |
|
99 | interface Security {
|
100 | [key: string]: any;
|
101 | }
|
102 |
|
103 |
|
104 |
|
105 |
|
106 | interface ServerScope extends nano.ServerScope {
|
107 | db: nano.DatabaseScope;
|
108 | use(db: string): DocumentScope<any>;
|
109 | scope(db: string): DocumentScope<any>;
|
110 |
|
111 |
|
112 | generate_api_key(callback?: Callback<ApiKey>): Promise<any>;
|
113 |
|
114 |
|
115 | get_cors(callback?: Callback<any>): Promise<any>;
|
116 |
|
117 |
|
118 | ping(callback?: Callback<any>): Promise<any>;
|
119 |
|
120 |
|
121 | set_cors(cors: CORS, callback?: Callback<any>): Promise<any>;
|
122 | }
|
123 |
|
124 |
|
125 |
|
126 |
|
127 | interface DocumentScope<D> extends nano.DocumentScope<D> {
|
128 |
|
129 | index: Query;
|
130 |
|
131 |
|
132 | bulk_get(options: nano.BulkModifyDocsWrapper, callback?: Callback<any>): Promise<any>;
|
133 |
|
134 |
|
135 | geo(
|
136 | designname: string,
|
137 | docname: string,
|
138 | params: GeoParams,
|
139 | callback?: Callback<GeoResult>
|
140 | ): Promise<any>;
|
141 |
|
142 |
|
143 | get_security(callback?: Callback<Security>): Promise<any>;
|
144 |
|
145 |
|
146 | set_security(Security: Security, callback?: Callback<any>): Promise<any>;
|
147 | }
|
148 | }
|
149 |
|
150 | export = cloudant;
|