couchbase 3.2.2 → 3.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. package/binding.gyp +5 -0
  2. package/deps/lcb/CMakeLists.txt +1 -1
  3. package/deps/lcb/CONTRIBUTING.md +1 -1
  4. package/deps/lcb/README.markdown +2 -2
  5. package/deps/lcb/RELEASE_NOTES.markdown +84 -17
  6. package/deps/lcb/cmake/Modules/GetVersionInfo.cmake +1 -1
  7. package/deps/lcb/contrib/cbsasl/src/scram-sha/scram_utils.cc +22 -26
  8. package/deps/lcb/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp +20 -6
  9. package/deps/lcb/doc/Doxyfile +1 -1
  10. package/deps/lcb/example/minimal/query.c +9 -7
  11. package/deps/lcb/gyp_config/common/libcouchbase/configuration.h +3 -3
  12. package/deps/lcb/gyp_config/linux/arm64/config.h +243 -0
  13. package/deps/lcb/include/libcouchbase/couchbase.h +55 -1
  14. package/deps/lcb/include/libcouchbase/error.h +6 -1
  15. package/deps/lcb/include/libcouchbase/ixmgmt.h +15 -10
  16. package/deps/lcb/include/libcouchbase/tracing.h +2 -2
  17. package/deps/lcb/include/memcached/protocol_binary.h +21 -0
  18. package/deps/lcb/libcouchbase.gyp +353 -349
  19. package/deps/lcb/packaging/deb/control +1 -1
  20. package/deps/lcb/src/analytics/analytics_handle.cc +7 -5
  21. package/deps/lcb/src/analytics/analytics_handle.hh +28 -0
  22. package/deps/lcb/src/capi/cmd_counter.hh +18 -0
  23. package/deps/lcb/src/capi/cmd_exists.hh +18 -0
  24. package/deps/lcb/src/capi/cmd_get.hh +17 -0
  25. package/deps/lcb/src/capi/cmd_get_replica.hh +20 -1
  26. package/deps/lcb/src/capi/cmd_query.cc +13 -0
  27. package/deps/lcb/src/capi/cmd_query.hh +22 -14
  28. package/deps/lcb/src/capi/cmd_remove.hh +18 -0
  29. package/deps/lcb/src/capi/cmd_search.hh +6 -0
  30. package/deps/lcb/src/capi/cmd_store.hh +28 -21
  31. package/deps/lcb/src/capi/cmd_subdoc.hh +30 -0
  32. package/deps/lcb/src/capi/cmd_touch.hh +18 -0
  33. package/deps/lcb/src/capi/cmd_unlock.hh +18 -0
  34. package/deps/lcb/src/capi/cmd_view.hh +6 -0
  35. package/deps/lcb/src/capi/collection_qualifier.hh +6 -8
  36. package/deps/lcb/src/cntl.cc +42 -8
  37. package/deps/lcb/src/dns-srv.cc +5 -3
  38. package/deps/lcb/src/errmap.cc +5 -9
  39. package/deps/lcb/src/errmap.h +7 -3
  40. package/deps/lcb/src/handler.cc +24 -18
  41. package/deps/lcb/src/internal.h +2 -1
  42. package/deps/lcb/src/lcbio/ctx.cc +4 -2
  43. package/deps/lcb/src/mcserver/mcserver.cc +8 -5
  44. package/deps/lcb/src/mcserver/negotiate.cc +42 -17
  45. package/deps/lcb/src/n1ql/ixmgmt.cc +1 -2
  46. package/deps/lcb/src/n1ql/n1ql.cc +5 -1
  47. package/deps/lcb/src/n1ql/query_handle.cc +80 -44
  48. package/deps/lcb/src/n1ql/query_handle.hh +41 -3
  49. package/deps/lcb/src/operations/counter.cc +13 -1
  50. package/deps/lcb/src/operations/exists.cc +14 -2
  51. package/deps/lcb/src/operations/get.cc +14 -2
  52. package/deps/lcb/src/operations/get_replica.cc +18 -6
  53. package/deps/lcb/src/operations/observe.cc +1 -1
  54. package/deps/lcb/src/operations/remove.cc +13 -1
  55. package/deps/lcb/src/operations/store.cc +13 -1
  56. package/deps/lcb/src/operations/subdoc.cc +13 -2
  57. package/deps/lcb/src/operations/touch.cc +14 -2
  58. package/deps/lcb/src/operations/unlock.cc +14 -2
  59. package/deps/lcb/src/search/search_handle.cc +26 -8
  60. package/deps/lcb/src/search/search_handle.hh +29 -0
  61. package/deps/lcb/src/ssl/ssl_common.c +7 -8
  62. package/deps/lcb/src/tracing/span.cc +43 -10
  63. package/deps/lcb/src/tracing/tracing-internal.h +105 -93
  64. package/deps/lcb/src/utilities.cc +21 -0
  65. package/deps/lcb/src/utilities.h +3 -0
  66. package/deps/lcb/src/views/view_handle.cc +13 -5
  67. package/deps/lcb/src/views/view_handle.hh +29 -0
  68. package/deps/lcb/tests/CMakeLists.txt +21 -0
  69. package/deps/lcb/tests/basic/t_ctlcodes.cc +24 -3
  70. package/deps/lcb/tests/basic/t_jsparse.cc +8 -0
  71. package/deps/lcb/tests/iotests/mock-environment.cc +25 -1
  72. package/deps/lcb/tests/iotests/mock-environment.h +49 -1
  73. package/deps/lcb/tests/iotests/mock-unit-test.cc +96 -5
  74. package/deps/lcb/tests/iotests/mock-unit-test.h +32 -0
  75. package/deps/lcb/tests/iotests/serverparams.h +7 -2
  76. package/deps/lcb/tests/iotests/t_collections.cc +1 -1
  77. package/deps/lcb/tests/iotests/t_confmon.cc +4 -2
  78. package/deps/lcb/tests/iotests/t_get.cc +14 -4
  79. package/deps/lcb/tests/iotests/t_n1ql.cc +17 -1
  80. package/deps/lcb/tests/iotests/t_ratelimit.cc +729 -0
  81. package/deps/lcb/tests/iotests/t_views.cc +1 -0
  82. package/deps/lcb/tests/iotests/testutil.cc +342 -0
  83. package/deps/lcb/tests/iotests/testutil.h +164 -0
  84. package/deps/lcb/tests/mocksupport/procutil.c +32 -28
  85. package/deps/lcb/tests/mocksupport/server.c +0 -1
  86. package/deps/lcb/tools/cbc.cc +7 -0
  87. package/dist/analyticsexecutor.js +2 -2
  88. package/dist/analyticsindexmanager.js +512 -524
  89. package/dist/binarycollection.d.ts +17 -0
  90. package/dist/binding.d.ts +2 -0
  91. package/dist/binding.js +1 -1
  92. package/dist/bindingutilities.js +9 -1
  93. package/dist/bucketmanager.d.ts +32 -23
  94. package/dist/bucketmanager.js +197 -189
  95. package/dist/cluster.js +37 -36
  96. package/dist/collection.js +17 -23
  97. package/dist/collectionmanager.js +181 -200
  98. package/dist/connection.js +6 -3
  99. package/dist/connspec.js +5 -1
  100. package/dist/couchbase.js +7 -14
  101. package/dist/datastructures.js +239 -310
  102. package/dist/diagnosticsexecutor.js +70 -85
  103. package/dist/errors.d.ts +18 -0
  104. package/dist/errors.js +26 -2
  105. package/dist/eventingfunctionmanager.js +267 -294
  106. package/dist/httpexecutor.js +31 -38
  107. package/dist/logging.js +1 -1
  108. package/dist/queryexecutor.js +3 -3
  109. package/dist/queryindexmanager.js +236 -263
  110. package/dist/scope.js +8 -2
  111. package/dist/searchexecutor.js +3 -0
  112. package/dist/searchindexmanager.js +240 -271
  113. package/dist/searchquery.d.ts +17 -0
  114. package/dist/searchquery.js +22 -1
  115. package/dist/searchtypes.d.ts +7 -2
  116. package/dist/searchtypes.js +2 -2
  117. package/dist/usermanager.js +250 -263
  118. package/dist/utilities.d.ts +3 -2
  119. package/dist/utilities.js +16 -4
  120. package/dist/viewexecutor.js +1 -1
  121. package/dist/viewindexmanager.js +131 -150
  122. package/package.json +1 -1
  123. package/src/connection.cpp +2 -0
  124. package/src/constants.cpp +2 -0
  125. package/src/instance.cpp +8 -1
  126. package/src/instance.h +1 -0
  127. package/src/uv-plugin-all.cpp +1 -0
  128. package/dist/cas.d.ts +0 -0
  129. package/dist/cas.js +0 -1
@@ -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 Object.assign(Object.assign({}, BucketSettings._toNsData(data)), { conflictResolutionType: data.conflictResolutionType });
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
- return __awaiter(this, arguments, void 0, function* () {
240
- if (options instanceof Function) {
241
- callback = arguments[1];
242
- options = undefined;
243
- }
244
- if (!options) {
245
- options = {};
246
- }
247
- const parentSpan = options.parentSpan;
248
- const timeout = options.timeout;
249
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
250
- const bucketData = CreateBucketSettings._toNsData(settings);
251
- const res = yield this._http.request({
252
- type: httpexecutor_1.HttpServiceType.Management,
253
- method: httpexecutor_1.HttpMethod.Post,
254
- path: `/pools/default/buckets`,
255
- contentType: 'application/x-www-form-urlencoded',
256
- body: utilities_1.cbQsStringify(bucketData),
257
- parentSpan: parentSpan,
258
- timeout: timeout,
259
- });
260
- if (res.statusCode !== 202) {
261
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
262
- const errText = res.body.toString().toLowerCase();
263
- if (errText.includes('already exists')) {
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
- }), callback);
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
- return __awaiter(this, arguments, void 0, function* () {
280
- if (options instanceof Function) {
281
- callback = arguments[1];
282
- options = undefined;
283
- }
284
- if (!options) {
285
- options = {};
286
- }
287
- const parentSpan = options.parentSpan;
288
- const timeout = options.timeout;
289
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
290
- const bucketData = BucketSettings._toNsData(settings);
291
- const res = yield this._http.request({
292
- type: httpexecutor_1.HttpServiceType.Management,
293
- method: httpexecutor_1.HttpMethod.Post,
294
- path: `/pools/default/buckets/${settings.name}`,
295
- contentType: 'application/x-www-form-urlencoded',
296
- body: utilities_1.cbQsStringify(bucketData),
297
- parentSpan: parentSpan,
298
- timeout: timeout,
299
- });
300
- if (res.statusCode !== 200) {
301
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
302
- const errText = res.body.toString().toLowerCase();
303
- if (errText.includes('not found')) {
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
- }), callback);
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
- return __awaiter(this, arguments, void 0, function* () {
320
- if (options instanceof Function) {
321
- callback = arguments[1];
322
- options = undefined;
323
- }
324
- if (!options) {
325
- options = {};
326
- }
327
- const parentSpan = options.parentSpan;
328
- const timeout = options.timeout;
329
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
330
- const res = yield this._http.request({
331
- type: httpexecutor_1.HttpServiceType.Management,
332
- method: httpexecutor_1.HttpMethod.Delete,
333
- path: `/pools/default/buckets/${bucketName}`,
334
- parentSpan: parentSpan,
335
- timeout: timeout,
336
- });
337
- if (res.statusCode !== 200) {
338
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
339
- const errText = res.body.toString().toLowerCase();
340
- if (errText.includes('not found')) {
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
- }), callback);
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
- return __awaiter(this, arguments, void 0, function* () {
357
- if (options instanceof Function) {
358
- callback = arguments[1];
359
- options = undefined;
360
- }
361
- if (!options) {
362
- options = {};
363
- }
364
- const parentSpan = options.parentSpan;
365
- const timeout = options.timeout;
366
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
367
- const res = yield this._http.request({
368
- type: httpexecutor_1.HttpServiceType.Management,
369
- method: httpexecutor_1.HttpMethod.Get,
370
- path: `/pools/default/buckets/${bucketName}`,
371
- parentSpan: parentSpan,
372
- timeout: timeout,
373
- });
374
- if (res.statusCode !== 200) {
375
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
376
- const errText = res.body.toString().toLowerCase();
377
- if (errText.includes('not found')) {
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
- const bucketData = JSON.parse(res.body.toString());
383
- return BucketSettings._fromNsData(bucketData);
384
- }), callback);
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
- return __awaiter(this, arguments, void 0, function* () {
395
- if (options instanceof Function) {
396
- callback = arguments[1];
397
- options = undefined;
398
- }
399
- if (!options) {
400
- options = {};
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 parentSpan = options.parentSpan;
403
- const timeout = options.timeout;
404
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
405
- const res = yield this._http.request({
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
- return __awaiter(this, arguments, void 0, function* () {
431
- if (options instanceof Function) {
432
- callback = arguments[1];
433
- options = undefined;
434
- }
435
- if (!options) {
436
- options = {};
437
- }
438
- const parentSpan = options.parentSpan;
439
- const timeout = options.timeout;
440
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
441
- const res = yield this._http.request({
442
- type: httpexecutor_1.HttpServiceType.Management,
443
- method: httpexecutor_1.HttpMethod.Post,
444
- path: `/pools/default/buckets/${bucketName}/controller/doFlush`,
445
- parentSpan: parentSpan,
446
- timeout: timeout,
447
- });
448
- if (res.statusCode !== 200) {
449
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
450
- const errText = res.body.toString().toLowerCase();
451
- if (errText.includes('not found')) {
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
- }), callback);
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 __awaiter(this, void 0, void 0, function* () {
114
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
115
- const cluster = new Cluster(connStr, options);
116
- yield cluster._clusterConnect();
117
- return cluster;
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(() => __awaiter(this, void 0, void 0, function* () {
285
- const closeOneConn = (conn) => __awaiter(this, void 0, void 0, function* () {
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
- yield Promise.all(allConns.map((conn) => closeOneConn(conn)));
298
- }), callback);
286
+ await Promise.all(allConns.map((conn) => closeOneConn(conn)));
287
+ }, callback);
299
288
  }
300
289
  _buildConnOpts(extraOpts) {
301
- const connOpts = Object.assign({ connStr: this._connStr, trustStorePath: this._trustStorePath, tracer: this._tracer, meter: this._meter, logFunc: this._logFunc, kvTimeout: this._kvTimeout, kvDurableTimeout: this._kvDurableTimeout, viewTimeout: this._viewTimeout, queryTimeout: this._queryTimeout, analyticsTimeout: this._analyticsTimeout, searchTimeout: this._searchTimeout, managementTimeout: this._managementTimeout }, extraOpts);
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 __awaiter(this, void 0, void 0, function* () {
318
- return new Promise((resolve, reject) => {
319
- const connOpts = this._buildConnOpts({});
320
- const conn = new connection_1.Connection(connOpts);
321
- conn.connect((err) => {
322
- if (err) {
323
- return reject(err);
324
- }
325
- this._clusterConn = conn;
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
  });