couchbase 3.2.2 → 3.2.5
Sign up to get free protection for your applications and to get access to all the features.
- package/binding.gyp +5 -0
- package/deps/lcb/CMakeLists.txt +1 -1
- package/deps/lcb/CONTRIBUTING.md +1 -1
- package/deps/lcb/README.markdown +2 -2
- package/deps/lcb/RELEASE_NOTES.markdown +84 -17
- package/deps/lcb/cmake/Modules/GetVersionInfo.cmake +1 -1
- package/deps/lcb/contrib/cbsasl/src/scram-sha/scram_utils.cc +22 -26
- package/deps/lcb/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp +20 -6
- package/deps/lcb/doc/Doxyfile +1 -1
- package/deps/lcb/example/minimal/query.c +9 -7
- package/deps/lcb/gyp_config/common/libcouchbase/configuration.h +3 -3
- package/deps/lcb/gyp_config/linux/arm64/config.h +243 -0
- package/deps/lcb/include/libcouchbase/couchbase.h +55 -1
- package/deps/lcb/include/libcouchbase/error.h +6 -1
- package/deps/lcb/include/libcouchbase/ixmgmt.h +15 -10
- package/deps/lcb/include/libcouchbase/tracing.h +2 -2
- package/deps/lcb/include/memcached/protocol_binary.h +21 -0
- package/deps/lcb/libcouchbase.gyp +353 -349
- package/deps/lcb/packaging/deb/control +1 -1
- package/deps/lcb/src/analytics/analytics_handle.cc +7 -5
- package/deps/lcb/src/analytics/analytics_handle.hh +28 -0
- package/deps/lcb/src/capi/cmd_counter.hh +18 -0
- package/deps/lcb/src/capi/cmd_exists.hh +18 -0
- package/deps/lcb/src/capi/cmd_get.hh +17 -0
- package/deps/lcb/src/capi/cmd_get_replica.hh +20 -1
- package/deps/lcb/src/capi/cmd_query.cc +13 -0
- package/deps/lcb/src/capi/cmd_query.hh +22 -14
- package/deps/lcb/src/capi/cmd_remove.hh +18 -0
- package/deps/lcb/src/capi/cmd_search.hh +6 -0
- package/deps/lcb/src/capi/cmd_store.hh +28 -21
- package/deps/lcb/src/capi/cmd_subdoc.hh +30 -0
- package/deps/lcb/src/capi/cmd_touch.hh +18 -0
- package/deps/lcb/src/capi/cmd_unlock.hh +18 -0
- package/deps/lcb/src/capi/cmd_view.hh +6 -0
- package/deps/lcb/src/capi/collection_qualifier.hh +6 -8
- package/deps/lcb/src/cntl.cc +42 -8
- package/deps/lcb/src/dns-srv.cc +5 -3
- package/deps/lcb/src/errmap.cc +5 -9
- package/deps/lcb/src/errmap.h +7 -3
- package/deps/lcb/src/handler.cc +24 -18
- package/deps/lcb/src/internal.h +2 -1
- package/deps/lcb/src/lcbio/ctx.cc +4 -2
- package/deps/lcb/src/mcserver/mcserver.cc +8 -5
- package/deps/lcb/src/mcserver/negotiate.cc +42 -17
- package/deps/lcb/src/n1ql/ixmgmt.cc +1 -2
- package/deps/lcb/src/n1ql/n1ql.cc +5 -1
- package/deps/lcb/src/n1ql/query_handle.cc +80 -44
- package/deps/lcb/src/n1ql/query_handle.hh +41 -3
- package/deps/lcb/src/operations/counter.cc +13 -1
- package/deps/lcb/src/operations/exists.cc +14 -2
- package/deps/lcb/src/operations/get.cc +14 -2
- package/deps/lcb/src/operations/get_replica.cc +18 -6
- package/deps/lcb/src/operations/observe.cc +1 -1
- package/deps/lcb/src/operations/remove.cc +13 -1
- package/deps/lcb/src/operations/store.cc +13 -1
- package/deps/lcb/src/operations/subdoc.cc +13 -2
- package/deps/lcb/src/operations/touch.cc +14 -2
- package/deps/lcb/src/operations/unlock.cc +14 -2
- package/deps/lcb/src/search/search_handle.cc +26 -8
- package/deps/lcb/src/search/search_handle.hh +29 -0
- package/deps/lcb/src/ssl/ssl_common.c +7 -8
- package/deps/lcb/src/tracing/span.cc +43 -10
- package/deps/lcb/src/tracing/tracing-internal.h +105 -93
- package/deps/lcb/src/utilities.cc +21 -0
- package/deps/lcb/src/utilities.h +3 -0
- package/deps/lcb/src/views/view_handle.cc +13 -5
- package/deps/lcb/src/views/view_handle.hh +29 -0
- package/deps/lcb/tests/CMakeLists.txt +21 -0
- package/deps/lcb/tests/basic/t_ctlcodes.cc +24 -3
- package/deps/lcb/tests/basic/t_jsparse.cc +8 -0
- package/deps/lcb/tests/iotests/mock-environment.cc +25 -1
- package/deps/lcb/tests/iotests/mock-environment.h +49 -1
- package/deps/lcb/tests/iotests/mock-unit-test.cc +96 -5
- package/deps/lcb/tests/iotests/mock-unit-test.h +32 -0
- package/deps/lcb/tests/iotests/serverparams.h +7 -2
- package/deps/lcb/tests/iotests/t_collections.cc +1 -1
- package/deps/lcb/tests/iotests/t_confmon.cc +4 -2
- package/deps/lcb/tests/iotests/t_get.cc +14 -4
- package/deps/lcb/tests/iotests/t_n1ql.cc +17 -1
- package/deps/lcb/tests/iotests/t_ratelimit.cc +729 -0
- package/deps/lcb/tests/iotests/t_views.cc +1 -0
- package/deps/lcb/tests/iotests/testutil.cc +342 -0
- package/deps/lcb/tests/iotests/testutil.h +164 -0
- package/deps/lcb/tests/mocksupport/procutil.c +32 -28
- package/deps/lcb/tests/mocksupport/server.c +0 -1
- package/deps/lcb/tools/cbc.cc +7 -0
- package/dist/analyticsexecutor.js +2 -2
- package/dist/analyticsindexmanager.js +512 -524
- package/dist/binarycollection.d.ts +17 -0
- package/dist/binding.d.ts +2 -0
- package/dist/binding.js +1 -1
- package/dist/bindingutilities.js +9 -1
- package/dist/bucketmanager.d.ts +32 -23
- package/dist/bucketmanager.js +197 -189
- package/dist/cluster.js +37 -36
- package/dist/collection.js +17 -23
- package/dist/collectionmanager.js +181 -200
- package/dist/connection.js +6 -3
- package/dist/connspec.js +5 -1
- package/dist/couchbase.js +7 -14
- package/dist/datastructures.js +239 -310
- package/dist/diagnosticsexecutor.js +70 -85
- package/dist/errors.d.ts +18 -0
- package/dist/errors.js +26 -2
- package/dist/eventingfunctionmanager.js +267 -294
- package/dist/httpexecutor.js +31 -38
- package/dist/logging.js +1 -1
- package/dist/queryexecutor.js +3 -3
- package/dist/queryindexmanager.js +236 -263
- package/dist/scope.js +8 -2
- package/dist/searchexecutor.js +3 -0
- package/dist/searchindexmanager.js +240 -271
- package/dist/searchquery.d.ts +17 -0
- package/dist/searchquery.js +22 -1
- package/dist/searchtypes.d.ts +7 -2
- package/dist/searchtypes.js +2 -2
- package/dist/usermanager.js +250 -263
- package/dist/utilities.d.ts +3 -2
- package/dist/utilities.js +16 -4
- package/dist/viewexecutor.js +1 -1
- package/dist/viewindexmanager.js +131 -150
- package/package.json +1 -1
- package/src/connection.cpp +2 -0
- package/src/constants.cpp +2 -0
- package/src/instance.cpp +8 -1
- package/src/instance.h +1 -0
- package/src/uv-plugin-all.cpp +1 -0
- package/dist/cas.d.ts +0 -0
- package/dist/cas.js +0 -1
package/dist/bucketmanager.js
CHANGED
@@ -1,15 +1,6 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
exports.BucketManager = exports.BucketSettings = exports.CompressionMode = exports.EvictionPolicy = exports.BucketType = exports.ConflictResolutionType = void 0;
|
3
|
+
exports.BucketManager = exports.BucketSettings = exports.CompressionMode = exports.EvictionPolicy = exports.StorageBackend = exports.BucketType = exports.ConflictResolutionType = void 0;
|
13
4
|
const errors_1 = require("./errors");
|
14
5
|
const httpexecutor_1 = require("./httpexecutor");
|
15
6
|
const utilities_1 = require("./utilities");
|
@@ -31,6 +22,13 @@ var ConflictResolutionType;
|
|
31
22
|
* Indicates that the seqno of the document should be used for conflict resolution.
|
32
23
|
*/
|
33
24
|
ConflictResolutionType["SequenceNumber"] = "seqno";
|
25
|
+
/**
|
26
|
+
* Indicates that custom conflict resolution should be used.
|
27
|
+
*
|
28
|
+
* @experimental This mode is only available in Couchbase Server 7.1 with the
|
29
|
+
* "developer-preview" mode enabled.
|
30
|
+
*/
|
31
|
+
ConflictResolutionType["Custom"] = "custom";
|
34
32
|
})(ConflictResolutionType = exports.ConflictResolutionType || (exports.ConflictResolutionType = {}));
|
35
33
|
/**
|
36
34
|
* Represents the type of a bucket.
|
@@ -52,6 +50,22 @@ var BucketType;
|
|
52
50
|
*/
|
53
51
|
BucketType["Ephemeral"] = "ephemeral";
|
54
52
|
})(BucketType = exports.BucketType || (exports.BucketType = {}));
|
53
|
+
/**
|
54
|
+
* Represents the storage backend to use for a bucket.
|
55
|
+
*
|
56
|
+
* @category Management
|
57
|
+
*/
|
58
|
+
var StorageBackend;
|
59
|
+
(function (StorageBackend) {
|
60
|
+
/**
|
61
|
+
* Indicates the bucket should use the Couchstore storage engine.
|
62
|
+
*/
|
63
|
+
StorageBackend["Couchstore"] = "couchstore";
|
64
|
+
/**
|
65
|
+
* Indicates the bucket should use the Magma storage engine.
|
66
|
+
*/
|
67
|
+
StorageBackend["Magma"] = "magma";
|
68
|
+
})(StorageBackend = exports.StorageBackend || (exports.StorageBackend = {}));
|
55
69
|
/**
|
56
70
|
* Represents the eviction policy that should be used for a bucket.
|
57
71
|
*
|
@@ -115,6 +129,7 @@ class BucketSettings {
|
|
115
129
|
this.numReplicas = data.numReplicas;
|
116
130
|
this.replicaIndexes = data.replicaIndexes;
|
117
131
|
this.bucketType = data.bucketType;
|
132
|
+
this.storageBackend = data.storageBackend;
|
118
133
|
this.evictionPolicy = data.evictionPolicy;
|
119
134
|
this.maxExpiry = data.maxExpiry;
|
120
135
|
this.compressionMode = data.compressionMode;
|
@@ -149,7 +164,7 @@ class BucketSettings {
|
|
149
164
|
* @deprecated Use {@link IBucketSettings.minimumDurabilityLevel} instead.
|
150
165
|
*/
|
151
166
|
get durabilityMinLevel() {
|
152
|
-
return utilities_1.duraLevelToNsServerStr(this.minimumDurabilityLevel);
|
167
|
+
return (0, utilities_1.duraLevelToNsServerStr)(this.minimumDurabilityLevel);
|
153
168
|
}
|
154
169
|
/**
|
155
170
|
* @internal
|
@@ -162,11 +177,12 @@ class BucketSettings {
|
|
162
177
|
replicaNumber: data.numReplicas,
|
163
178
|
replicaIndexes: data.replicaIndexes,
|
164
179
|
bucketType: data.bucketType,
|
180
|
+
storageBackend: data.storageBackend,
|
165
181
|
evictionPolicy: data.evictionPolicy,
|
166
182
|
maxTTL: data.maxTTL || data.maxExpiry,
|
167
183
|
compressionMode: data.compressionMode,
|
168
184
|
durabilityMinLevel: data.durabilityMinLevel ||
|
169
|
-
utilities_1.duraLevelToNsServerStr(data.minimumDurabilityLevel),
|
185
|
+
(0, utilities_1.duraLevelToNsServerStr)(data.minimumDurabilityLevel),
|
170
186
|
};
|
171
187
|
}
|
172
188
|
/**
|
@@ -180,10 +196,11 @@ class BucketSettings {
|
|
180
196
|
numReplicas: data.replicaNumber,
|
181
197
|
replicaIndexes: data.replicaIndexes,
|
182
198
|
bucketType: data.bucketType,
|
199
|
+
storageBackend: data.storageBackend,
|
183
200
|
evictionPolicy: data.evictionPolicy,
|
184
201
|
maxExpiry: data.maxTTL,
|
185
202
|
compressionMode: data.compressionMode,
|
186
|
-
minimumDurabilityLevel: utilities_1.nsServerStrToDuraLevel(data.durabilityMinLevel),
|
203
|
+
minimumDurabilityLevel: (0, utilities_1.nsServerStrToDuraLevel)(data.durabilityMinLevel),
|
187
204
|
maxTTL: 0,
|
188
205
|
durabilityMinLevel: '',
|
189
206
|
ejectionMethod: '',
|
@@ -209,7 +226,10 @@ class CreateBucketSettings extends BucketSettings {
|
|
209
226
|
* @internal
|
210
227
|
*/
|
211
228
|
static _toNsData(data) {
|
212
|
-
return
|
229
|
+
return {
|
230
|
+
...BucketSettings._toNsData(data),
|
231
|
+
conflictResolutionType: data.conflictResolutionType,
|
232
|
+
};
|
213
233
|
}
|
214
234
|
}
|
215
235
|
/**
|
@@ -235,38 +255,36 @@ class BucketManager {
|
|
235
255
|
* @param options Optional parameters for this operation.
|
236
256
|
* @param callback A node-style callback to be invoked after execution.
|
237
257
|
*/
|
238
|
-
createBucket(settings, options, callback) {
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
throw new errors_1.BucketExistsError(undefined, errCtx);
|
265
|
-
}
|
266
|
-
throw new errors_1.CouchbaseError('failed to create bucket', undefined, errCtx);
|
258
|
+
async createBucket(settings, options, callback) {
|
259
|
+
if (options instanceof Function) {
|
260
|
+
callback = arguments[1];
|
261
|
+
options = undefined;
|
262
|
+
}
|
263
|
+
if (!options) {
|
264
|
+
options = {};
|
265
|
+
}
|
266
|
+
const parentSpan = options.parentSpan;
|
267
|
+
const timeout = options.timeout;
|
268
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
269
|
+
const bucketData = CreateBucketSettings._toNsData(settings);
|
270
|
+
const res = await this._http.request({
|
271
|
+
type: httpexecutor_1.HttpServiceType.Management,
|
272
|
+
method: httpexecutor_1.HttpMethod.Post,
|
273
|
+
path: `/pools/default/buckets`,
|
274
|
+
contentType: 'application/x-www-form-urlencoded',
|
275
|
+
body: (0, utilities_1.cbQsStringify)(bucketData),
|
276
|
+
parentSpan: parentSpan,
|
277
|
+
timeout: timeout,
|
278
|
+
});
|
279
|
+
if (res.statusCode !== 202) {
|
280
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
281
|
+
const errText = res.body.toString().toLowerCase();
|
282
|
+
if (errText.includes('already exists')) {
|
283
|
+
throw new errors_1.BucketExistsError(undefined, errCtx);
|
267
284
|
}
|
268
|
-
|
269
|
-
|
285
|
+
throw new errors_1.CouchbaseError('failed to create bucket', undefined, errCtx);
|
286
|
+
}
|
287
|
+
}, callback);
|
270
288
|
}
|
271
289
|
/**
|
272
290
|
* Updates the settings for an existing bucket.
|
@@ -275,38 +293,36 @@ class BucketManager {
|
|
275
293
|
* @param options Optional parameters for this operation.
|
276
294
|
* @param callback A node-style callback to be invoked after execution.
|
277
295
|
*/
|
278
|
-
updateBucket(settings, options, callback) {
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
throw new errors_1.BucketNotFoundError(undefined, errCtx);
|
305
|
-
}
|
306
|
-
throw new errors_1.CouchbaseError('failed to update bucket', undefined, errCtx);
|
296
|
+
async updateBucket(settings, options, callback) {
|
297
|
+
if (options instanceof Function) {
|
298
|
+
callback = arguments[1];
|
299
|
+
options = undefined;
|
300
|
+
}
|
301
|
+
if (!options) {
|
302
|
+
options = {};
|
303
|
+
}
|
304
|
+
const parentSpan = options.parentSpan;
|
305
|
+
const timeout = options.timeout;
|
306
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
307
|
+
const bucketData = BucketSettings._toNsData(settings);
|
308
|
+
const res = await this._http.request({
|
309
|
+
type: httpexecutor_1.HttpServiceType.Management,
|
310
|
+
method: httpexecutor_1.HttpMethod.Post,
|
311
|
+
path: `/pools/default/buckets/${settings.name}`,
|
312
|
+
contentType: 'application/x-www-form-urlencoded',
|
313
|
+
body: (0, utilities_1.cbQsStringify)(bucketData),
|
314
|
+
parentSpan: parentSpan,
|
315
|
+
timeout: timeout,
|
316
|
+
});
|
317
|
+
if (res.statusCode !== 200) {
|
318
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
319
|
+
const errText = res.body.toString().toLowerCase();
|
320
|
+
if (errText.includes('not found')) {
|
321
|
+
throw new errors_1.BucketNotFoundError(undefined, errCtx);
|
307
322
|
}
|
308
|
-
|
309
|
-
|
323
|
+
throw new errors_1.CouchbaseError('failed to update bucket', undefined, errCtx);
|
324
|
+
}
|
325
|
+
}, callback);
|
310
326
|
}
|
311
327
|
/**
|
312
328
|
* Drops an existing bucket.
|
@@ -315,35 +331,33 @@ class BucketManager {
|
|
315
331
|
* @param options Optional parameters for this operation.
|
316
332
|
* @param callback A node-style callback to be invoked after execution.
|
317
333
|
*/
|
318
|
-
dropBucket(bucketName, options, callback) {
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
throw new errors_1.BucketNotFoundError(undefined, errCtx);
|
342
|
-
}
|
343
|
-
throw new errors_1.CouchbaseError('failed to drop bucket', undefined, errCtx);
|
334
|
+
async dropBucket(bucketName, options, callback) {
|
335
|
+
if (options instanceof Function) {
|
336
|
+
callback = arguments[1];
|
337
|
+
options = undefined;
|
338
|
+
}
|
339
|
+
if (!options) {
|
340
|
+
options = {};
|
341
|
+
}
|
342
|
+
const parentSpan = options.parentSpan;
|
343
|
+
const timeout = options.timeout;
|
344
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
345
|
+
const res = await this._http.request({
|
346
|
+
type: httpexecutor_1.HttpServiceType.Management,
|
347
|
+
method: httpexecutor_1.HttpMethod.Delete,
|
348
|
+
path: `/pools/default/buckets/${bucketName}`,
|
349
|
+
parentSpan: parentSpan,
|
350
|
+
timeout: timeout,
|
351
|
+
});
|
352
|
+
if (res.statusCode !== 200) {
|
353
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
354
|
+
const errText = res.body.toString().toLowerCase();
|
355
|
+
if (errText.includes('not found')) {
|
356
|
+
throw new errors_1.BucketNotFoundError(undefined, errCtx);
|
344
357
|
}
|
345
|
-
|
346
|
-
|
358
|
+
throw new errors_1.CouchbaseError('failed to drop bucket', undefined, errCtx);
|
359
|
+
}
|
360
|
+
}, callback);
|
347
361
|
}
|
348
362
|
/**
|
349
363
|
* Fetches the settings in use for a specified bucket.
|
@@ -352,37 +366,35 @@ class BucketManager {
|
|
352
366
|
* @param options Optional parameters for this operation.
|
353
367
|
* @param callback A node-style callback to be invoked after execution.
|
354
368
|
*/
|
355
|
-
getBucket(bucketName, options, callback) {
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
throw new errors_1.BucketNotFoundError(undefined, errCtx);
|
379
|
-
}
|
380
|
-
throw new errors_1.CouchbaseError('failed to get bucket', undefined, errCtx);
|
369
|
+
async getBucket(bucketName, options, callback) {
|
370
|
+
if (options instanceof Function) {
|
371
|
+
callback = arguments[1];
|
372
|
+
options = undefined;
|
373
|
+
}
|
374
|
+
if (!options) {
|
375
|
+
options = {};
|
376
|
+
}
|
377
|
+
const parentSpan = options.parentSpan;
|
378
|
+
const timeout = options.timeout;
|
379
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
380
|
+
const res = await this._http.request({
|
381
|
+
type: httpexecutor_1.HttpServiceType.Management,
|
382
|
+
method: httpexecutor_1.HttpMethod.Get,
|
383
|
+
path: `/pools/default/buckets/${bucketName}`,
|
384
|
+
parentSpan: parentSpan,
|
385
|
+
timeout: timeout,
|
386
|
+
});
|
387
|
+
if (res.statusCode !== 200) {
|
388
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
389
|
+
const errText = res.body.toString().toLowerCase();
|
390
|
+
if (errText.includes('not found')) {
|
391
|
+
throw new errors_1.BucketNotFoundError(undefined, errCtx);
|
381
392
|
}
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
393
|
+
throw new errors_1.CouchbaseError('failed to get bucket', undefined, errCtx);
|
394
|
+
}
|
395
|
+
const bucketData = JSON.parse(res.body.toString());
|
396
|
+
return BucketSettings._fromNsData(bucketData);
|
397
|
+
}, callback);
|
386
398
|
}
|
387
399
|
/**
|
388
400
|
* Returns a list of existing buckets in the cluster.
|
@@ -390,34 +402,32 @@ class BucketManager {
|
|
390
402
|
* @param options Optional parameters for this operation.
|
391
403
|
* @param callback A node-style callback to be invoked after execution.
|
392
404
|
*/
|
393
|
-
getAllBuckets(options, callback) {
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
405
|
+
async getAllBuckets(options, callback) {
|
406
|
+
if (options instanceof Function) {
|
407
|
+
callback = arguments[0];
|
408
|
+
options = undefined;
|
409
|
+
}
|
410
|
+
if (!options) {
|
411
|
+
options = {};
|
412
|
+
}
|
413
|
+
const parentSpan = options.parentSpan;
|
414
|
+
const timeout = options.timeout;
|
415
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
416
|
+
const res = await this._http.request({
|
417
|
+
type: httpexecutor_1.HttpServiceType.Management,
|
418
|
+
method: httpexecutor_1.HttpMethod.Get,
|
419
|
+
path: `/pools/default/buckets`,
|
420
|
+
parentSpan: parentSpan,
|
421
|
+
timeout: timeout,
|
422
|
+
});
|
423
|
+
if (res.statusCode !== 200) {
|
424
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
425
|
+
throw new errors_1.CouchbaseError('failed to get buckets', undefined, errCtx);
|
401
426
|
}
|
402
|
-
const
|
403
|
-
const
|
404
|
-
return
|
405
|
-
|
406
|
-
type: httpexecutor_1.HttpServiceType.Management,
|
407
|
-
method: httpexecutor_1.HttpMethod.Get,
|
408
|
-
path: `/pools/default/buckets`,
|
409
|
-
parentSpan: parentSpan,
|
410
|
-
timeout: timeout,
|
411
|
-
});
|
412
|
-
if (res.statusCode !== 200) {
|
413
|
-
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
414
|
-
throw new errors_1.CouchbaseError('failed to get buckets', undefined, errCtx);
|
415
|
-
}
|
416
|
-
const bucketsData = JSON.parse(res.body.toString());
|
417
|
-
const buckets = bucketsData.map((bucketData) => BucketSettings._fromNsData(bucketData));
|
418
|
-
return buckets;
|
419
|
-
}), callback);
|
420
|
-
});
|
427
|
+
const bucketsData = JSON.parse(res.body.toString());
|
428
|
+
const buckets = bucketsData.map((bucketData) => BucketSettings._fromNsData(bucketData));
|
429
|
+
return buckets;
|
430
|
+
}, callback);
|
421
431
|
}
|
422
432
|
/**
|
423
433
|
* Flushes the bucket, deleting all the existing data that is stored in it.
|
@@ -426,35 +436,33 @@ class BucketManager {
|
|
426
436
|
* @param options Optional parameters for this operation.
|
427
437
|
* @param callback A node-style callback to be invoked after execution.
|
428
438
|
*/
|
429
|
-
flushBucket(bucketName, options, callback) {
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
throw new errors_1.BucketNotFoundError(undefined, errCtx);
|
453
|
-
}
|
454
|
-
throw new errors_1.CouchbaseError('failed to get bucket', undefined, errCtx);
|
439
|
+
async flushBucket(bucketName, options, callback) {
|
440
|
+
if (options instanceof Function) {
|
441
|
+
callback = arguments[1];
|
442
|
+
options = undefined;
|
443
|
+
}
|
444
|
+
if (!options) {
|
445
|
+
options = {};
|
446
|
+
}
|
447
|
+
const parentSpan = options.parentSpan;
|
448
|
+
const timeout = options.timeout;
|
449
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
450
|
+
const res = await this._http.request({
|
451
|
+
type: httpexecutor_1.HttpServiceType.Management,
|
452
|
+
method: httpexecutor_1.HttpMethod.Post,
|
453
|
+
path: `/pools/default/buckets/${bucketName}/controller/doFlush`,
|
454
|
+
parentSpan: parentSpan,
|
455
|
+
timeout: timeout,
|
456
|
+
});
|
457
|
+
if (res.statusCode !== 200) {
|
458
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
459
|
+
const errText = res.body.toString().toLowerCase();
|
460
|
+
if (errText.includes('not found')) {
|
461
|
+
throw new errors_1.BucketNotFoundError(undefined, errCtx);
|
455
462
|
}
|
456
|
-
|
457
|
-
|
463
|
+
throw new errors_1.CouchbaseError('failed to get bucket', undefined, errCtx);
|
464
|
+
}
|
465
|
+
}, callback);
|
458
466
|
}
|
459
467
|
}
|
460
468
|
exports.BucketManager = BucketManager;
|
package/dist/cluster.js
CHANGED
@@ -1,13 +1,4 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
3
|
exports.Cluster = void 0;
|
13
4
|
const analyticsexecutor_1 = require("./analyticsexecutor");
|
@@ -109,14 +100,12 @@ class Cluster {
|
|
109
100
|
/**
|
110
101
|
@internal
|
111
102
|
*/
|
112
|
-
static connect(connStr, options, callback) {
|
113
|
-
return
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
}), callback);
|
119
|
-
});
|
103
|
+
static async connect(connStr, options, callback) {
|
104
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
105
|
+
const cluster = new Cluster(connStr, options);
|
106
|
+
await cluster._clusterConnect();
|
107
|
+
return cluster;
|
108
|
+
}, callback);
|
120
109
|
}
|
121
110
|
/**
|
122
111
|
* Creates a Bucket object reference to a specific bucket.
|
@@ -281,12 +270,12 @@ class Cluster {
|
|
281
270
|
* @param callback A node-style callback to be invoked after execution.
|
282
271
|
*/
|
283
272
|
close(callback) {
|
284
|
-
return utilities_1.PromiseHelper.wrapAsync(() =>
|
285
|
-
const closeOneConn = (conn) =>
|
273
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
274
|
+
const closeOneConn = async (conn) => {
|
286
275
|
return utilities_1.PromiseHelper.wrap((wrapCallback) => {
|
287
276
|
conn.close(wrapCallback);
|
288
277
|
});
|
289
|
-
}
|
278
|
+
};
|
290
279
|
let allConns = Object.values(this._conns);
|
291
280
|
this._conns = {};
|
292
281
|
if (this._clusterConn) {
|
@@ -294,11 +283,25 @@ class Cluster {
|
|
294
283
|
this._clusterConn = null;
|
295
284
|
}
|
296
285
|
this._closed = true;
|
297
|
-
|
298
|
-
}
|
286
|
+
await Promise.all(allConns.map((conn) => closeOneConn(conn)));
|
287
|
+
}, callback);
|
299
288
|
}
|
300
289
|
_buildConnOpts(extraOpts) {
|
301
|
-
const connOpts =
|
290
|
+
const connOpts = {
|
291
|
+
connStr: this._connStr,
|
292
|
+
trustStorePath: this._trustStorePath,
|
293
|
+
tracer: this._tracer,
|
294
|
+
meter: this._meter,
|
295
|
+
logFunc: this._logFunc,
|
296
|
+
kvTimeout: this._kvTimeout,
|
297
|
+
kvDurableTimeout: this._kvDurableTimeout,
|
298
|
+
viewTimeout: this._viewTimeout,
|
299
|
+
queryTimeout: this._queryTimeout,
|
300
|
+
analyticsTimeout: this._analyticsTimeout,
|
301
|
+
searchTimeout: this._searchTimeout,
|
302
|
+
managementTimeout: this._managementTimeout,
|
303
|
+
...extraOpts,
|
304
|
+
};
|
302
305
|
if (this._auth) {
|
303
306
|
const passAuth = this._auth;
|
304
307
|
if (passAuth.username || passAuth.password) {
|
@@ -313,18 +316,16 @@ class Cluster {
|
|
313
316
|
}
|
314
317
|
return connOpts;
|
315
318
|
}
|
316
|
-
_clusterConnect() {
|
317
|
-
return
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
resolve(null);
|
327
|
-
});
|
319
|
+
async _clusterConnect() {
|
320
|
+
return new Promise((resolve, reject) => {
|
321
|
+
const connOpts = this._buildConnOpts({});
|
322
|
+
const conn = new connection_1.Connection(connOpts);
|
323
|
+
conn.connect((err) => {
|
324
|
+
if (err) {
|
325
|
+
return reject(err);
|
326
|
+
}
|
327
|
+
this._clusterConn = conn;
|
328
|
+
resolve(null);
|
328
329
|
});
|
329
330
|
});
|
330
331
|
}
|
@@ -377,7 +378,7 @@ class Cluster {
|
|
377
378
|
conn = new connection_1.Connection(connOpts);
|
378
379
|
conn.connect((err) => {
|
379
380
|
if (err) {
|
380
|
-
logging_1.libLogger('failed to connect to bucket: %O', err);
|
381
|
+
(0, logging_1.libLogger)('failed to connect to bucket: %O', err);
|
381
382
|
conn.close(() => undefined);
|
382
383
|
}
|
383
384
|
});
|