UNPKG

11.3 kBTypeScriptView Raw
1import { AnalyticsIndexManager } from './analyticsindexmanager';
2import { AnalyticsMetaData, AnalyticsQueryOptions, AnalyticsResult } from './analyticstypes';
3import { Authenticator } from './authenticators';
4import { CppConnection } from './binding';
5import { Bucket } from './bucket';
6import { BucketManager } from './bucketmanager';
7import { DiagnosticsOptions, DiagnosticsResult, PingOptions, PingResult } from './diagnosticstypes';
8import { EventingFunctionManager } from './eventingfunctionmanager';
9import { QueryIndexManager } from './queryindexmanager';
10import { QueryMetaData, QueryOptions, QueryResult } from './querytypes';
11import { SearchIndexManager } from './searchindexmanager';
12import { SearchQuery } from './searchquery';
13import { SearchMetaData, SearchQueryOptions, SearchRequest, SearchResult, SearchRow } from './searchtypes';
14import { StreamableRowPromise } from './streamablepromises';
15import { Transactions, TransactionsConfig } from './transactions';
16import { Transcoder } from './transcoders';
17import { UserManager } from './usermanager';
18import { NodeCallback } from './utilities';
19/**
20 * Specifies the timeout options for the client.
21 *
22 * @category Core
23 */
24export interface TimeoutConfig {
25 /**
26 * Specifies the default timeout for KV operations, specified in millseconds.
27 */
28 kvTimeout?: number;
29 /**
30 * Specifies the default timeout for durable KV operations, specified in millseconds.
31 */
32 kvDurableTimeout?: number;
33 /**
34 * Specifies the default timeout for views operations, specified in millseconds.
35 */
36 viewTimeout?: number;
37 /**
38 * Specifies the default timeout for query operations, specified in millseconds.
39 */
40 queryTimeout?: number;
41 /**
42 * Specifies the default timeout for analytics query operations, specified in millseconds.
43 */
44 analyticsTimeout?: number;
45 /**
46 * Specifies the default timeout for search query operations, specified in millseconds.
47 */
48 searchTimeout?: number;
49 /**
50 * Specifies the default timeout for management operations, specified in millseconds.
51 */
52 managementTimeout?: number;
53 /**
54 * Specifies the default timeout allocated to complete bootstrap, specified in millseconds.
55 */
56 bootstrapTimeout?: number;
57 /**
58 * Specifies the default timeout for attempting to connect to a node’s KV service via a socket, specified in millseconds.
59 */
60 connectTimeout?: number;
61 /**
62 * Specifies the default timeout to resolve DNS name of the node to IP address, specified in millseconds.
63 */
64 resolveTimeout?: number;
65}
66/**
67 * Specifies security options for the client.
68 *
69 * @category Core
70 */
71export interface SecurityConfig {
72 /**
73 * Specifies the path to a trust store file to be used when validating the
74 * authenticity of the server when connecting over SSL.
75 */
76 trustStorePath?: string;
77}
78/**
79 * Specifies DNS options for the client.
80 *
81 * Volatile: This API is subject to change at any time.
82 *
83 * @category Core
84 */
85export interface DnsConfig {
86 /**
87 * Specifies the nameserver to be used for DNS query when connecting.
88 */
89 nameserver?: string;
90 /**
91 * Specifies the port to be used for DNS query when connecting.
92 */
93 port?: number;
94 /**
95 * Specifies the default timeout for DNS SRV operations, specified in millseconds.
96 */
97 dnsSrvTimeout?: number;
98}
99/**
100 * Specifies the options which can be specified when connecting
101 * to a cluster.
102 *
103 * @category Core
104 */
105export interface ConnectOptions {
106 /**
107 * Specifies a username to use for an implicitly created IPasswordAuthenticator
108 * used for authentication with the cluster.
109 */
110 username?: string;
111 /**
112 * Specifies a password to be used in concert with username for authentication.
113 *
114 * @see ConnectOptions.username
115 */
116 password?: string;
117 /**
118 * Specifies a specific authenticator to use when connecting to the cluster.
119 */
120 authenticator?: Authenticator;
121 /**
122 * Specifies the security config for connections of this cluster.
123 */
124 security?: SecurityConfig;
125 /**
126 * Specifies the default timeouts for various operations performed by the SDK.
127 */
128 timeouts?: TimeoutConfig;
129 /**
130 * Specifies the default transcoder to use when encoding or decoding document values.
131 */
132 transcoder?: Transcoder;
133 /**
134 * Specifies the options for transactions.
135 */
136 transactions?: TransactionsConfig;
137 /**
138 * Specifies the DNS config for connections of this cluster.
139 *
140 * Volatile: This API is subject to change at any time.
141 *
142 */
143 dnsConfig?: DnsConfig;
144 /**
145 * Applies the specified ConfigProfile options to the cluster.
146 *
147 * Volatile: This API is subject to change at any time.
148 *
149 */
150 configProfile?: string;
151}
152/**
153 * Exposes the operations which are available to be performed against a cluster.
154 * Namely the ability to access to Buckets as well as performing management
155 * operations against the cluster.
156 *
157 * @category Core
158 */
159export declare class Cluster {
160 private _connStr;
161 private _trustStorePath;
162 private _kvTimeout;
163 private _kvDurableTimeout;
164 private _viewTimeout;
165 private _queryTimeout;
166 private _analyticsTimeout;
167 private _searchTimeout;
168 private _managementTimeout;
169 private _connectTimeout;
170 private _bootstrapTimeout;
171 private _resolveTimeout;
172 private _auth;
173 private _conn;
174 private _transcoder;
175 private _txnConfig;
176 private _transactions?;
177 private _openBuckets;
178 private _dnsConfig;
179 /**
180 * @internal
181 */
182 get conn(): CppConnection;
183 /**
184 @internal
185 */
186 get transcoder(): Transcoder;
187 /**
188 @internal
189 */
190 get kvTimeout(): number;
191 /**
192 @internal
193 */
194 get kvDurableTimeout(): number;
195 /**
196 @internal
197 */
198 get viewTimeout(): number;
199 /**
200 @internal
201 */
202 get queryTimeout(): number;
203 /**
204 @internal
205 */
206 get analyticsTimeout(): number;
207 /**
208 @internal
209 */
210 get searchTimeout(): number;
211 /**
212 @internal
213 */
214 get managementTimeout(): number;
215 /**
216 @internal
217 */
218 get bootstrapTimeout(): number | undefined;
219 /**
220 @internal
221 */
222 get connectTimeout(): number | undefined;
223 /**
224 @internal
225 */
226 get resolveTimeout(): number | undefined;
227 /**
228 @internal
229 @deprecated Use the static sdk-level {@link connect} method instead.
230 */
231 constructor(connStr: string, options?: ConnectOptions);
232 /**
233 @internal
234 */
235 static connect(connStr: string, options?: ConnectOptions, callback?: NodeCallback<Cluster>): Promise<Cluster>;
236 /**
237 * Creates a Bucket object reference to a specific bucket.
238 *
239 * @param bucketName The name of the bucket to reference.
240 */
241 bucket(bucketName: string): Bucket;
242 /**
243 * Returns a UserManager which can be used to manage the users
244 * of this cluster.
245 */
246 users(): UserManager;
247 /**
248 * Returns a BucketManager which can be used to manage the buckets
249 * of this cluster.
250 */
251 buckets(): BucketManager;
252 /**
253 * Returns a QueryIndexManager which can be used to manage the query indexes
254 * of this cluster.
255 */
256 queryIndexes(): QueryIndexManager;
257 /**
258 * Returns a AnalyticsIndexManager which can be used to manage the analytics
259 * indexes of this cluster.
260 */
261 analyticsIndexes(): AnalyticsIndexManager;
262 /**
263 * Returns a SearchIndexManager which can be used to manage the search
264 * indexes of this cluster.
265 */
266 searchIndexes(): SearchIndexManager;
267 /**
268 * Returns a EventingFunctionManager which can be used to manage the eventing
269 * functions of this cluster.
270 * Uncommitted: This API is subject to change in the future.
271 */
272 eventingFunctions(): EventingFunctionManager;
273 /**
274 * Returns a Transactions object which can be used to perform transactions
275 * on this cluster.
276 */
277 transactions(): Transactions;
278 /**
279 * Executes a N1QL query against the cluster.
280 *
281 * @param statement The N1QL statement to execute.
282 * @param options Optional parameters for this operation.
283 * @param callback A node-style callback to be invoked after execution.
284 */
285 query<TRow = any>(statement: string, options?: QueryOptions, callback?: NodeCallback<QueryResult<TRow>>): StreamableRowPromise<QueryResult<TRow>, TRow, QueryMetaData>;
286 /**
287 * Executes an analytics query against the cluster.
288 *
289 * @param statement The analytics statement to execute.
290 * @param options Optional parameters for this operation.
291 * @param callback A node-style callback to be invoked after execution.
292 */
293 analyticsQuery<TRow = any>(statement: string, options?: AnalyticsQueryOptions, callback?: NodeCallback<AnalyticsResult<TRow>>): StreamableRowPromise<AnalyticsResult<TRow>, TRow, AnalyticsMetaData>;
294 /**
295 * Executes a search query against the cluster.
296 *
297 * @param indexName The name of the index to query.
298 * @param query The SearchQuery describing the query to execute.
299 * @param options Optional parameters for this operation.
300 * @param callback A node-style callback to be invoked after execution.
301 */
302 searchQuery(indexName: string, query: SearchQuery, options?: SearchQueryOptions, callback?: NodeCallback<SearchResult>): StreamableRowPromise<SearchResult, SearchRow, SearchMetaData>;
303 /**
304 * Executes a search query against the cluster.
305 *
306 * @param indexName The name of the index to query.
307 * @param request The SearchRequest describing the search to execute.
308 * @param options Optional parameters for this operation.
309 * @param callback A node-style callback to be invoked after execution.
310 */
311 search(indexName: string, request: SearchRequest, options?: SearchQueryOptions, callback?: NodeCallback<SearchResult>): StreamableRowPromise<SearchResult, SearchRow, SearchMetaData>;
312 /**
313 * Returns a diagnostics report about the currently active connections with the
314 * cluster. Includes information about remote and local addresses, last activity,
315 * and other diagnostics information.
316 *
317 * @param options Optional parameters for this operation.
318 * @param callback A node-style callback to be invoked after execution.
319 */
320 diagnostics(options?: DiagnosticsOptions, callback?: NodeCallback<DiagnosticsResult>): Promise<DiagnosticsResult>;
321 /**
322 * Performs a ping operation against the cluster. Pinging the services which
323 * are specified (or all services if none are specified). Returns a report
324 * which describes the outcome of the ping operations which were performed.
325 *
326 * @param options Optional parameters for this operation.
327 * @param callback A node-style callback to be invoked after execution.
328 */
329 ping(options?: PingOptions, callback?: NodeCallback<PingResult>): Promise<PingResult>;
330 /**
331 * Shuts down this cluster object. Cleaning up all resources associated with it.
332 *
333 * @param callback A node-style callback to be invoked after execution.
334 */
335 close(callback?: NodeCallback<void>): Promise<void>;
336 private _connect;
337}