couchbase 3.2.0 → 3.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/README.md +24 -18
  2. package/binding.gyp +88 -85
  3. package/deps/lcb/CMakeLists.txt +1 -1
  4. package/deps/lcb/CONTRIBUTING.md +1 -1
  5. package/deps/lcb/README.markdown +2 -2
  6. package/deps/lcb/RELEASE_NOTES.markdown +99 -14
  7. package/deps/lcb/cmake/Modules/GetVersionInfo.cmake +1 -1
  8. package/deps/lcb/contrib/cbsasl/src/scram-sha/scram_utils.cc +22 -26
  9. package/deps/lcb/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp +20 -7
  10. package/deps/lcb/doc/Doxyfile +1 -1
  11. package/deps/lcb/example/CMakeLists.txt +4 -4
  12. package/deps/lcb/example/libuvdirect/main.c +39 -12
  13. package/deps/lcb/example/minimal/durability.cc +149 -0
  14. package/deps/lcb/example/minimal/query.c +11 -9
  15. package/deps/lcb/gyp_config/common/libcouchbase/configuration.h +3 -3
  16. package/deps/lcb/gyp_config/linux/arm64/config.h +243 -0
  17. package/deps/lcb/include/libcouchbase/couchbase.h +80 -5
  18. package/deps/lcb/include/libcouchbase/error.h +2 -0
  19. package/deps/lcb/include/libcouchbase/ixmgmt.h +15 -10
  20. package/deps/lcb/include/libcouchbase/tracing.h +2 -2
  21. package/deps/lcb/include/memcached/protocol_binary.h +21 -0
  22. package/deps/lcb/libcouchbase.gyp +347 -349
  23. package/deps/lcb/packaging/deb/control +1 -1
  24. package/deps/lcb/src/analytics/analytics_handle.cc +13 -5
  25. package/deps/lcb/src/analytics/analytics_handle.hh +29 -0
  26. package/deps/lcb/src/bootstrap.cc +6 -3
  27. package/deps/lcb/src/capi/cmd_analytics.cc +12 -1
  28. package/deps/lcb/src/capi/cmd_analytics.hh +30 -0
  29. package/deps/lcb/src/capi/cmd_counter.hh +23 -0
  30. package/deps/lcb/src/capi/cmd_exists.hh +24 -1
  31. package/deps/lcb/src/capi/cmd_get.hh +22 -0
  32. package/deps/lcb/src/capi/cmd_get_replica.hh +23 -0
  33. package/deps/lcb/src/capi/cmd_http.hh +7 -0
  34. package/deps/lcb/src/capi/cmd_query.cc +11 -1
  35. package/deps/lcb/src/capi/cmd_query.hh +31 -0
  36. package/deps/lcb/src/capi/cmd_remove.hh +23 -0
  37. package/deps/lcb/src/capi/cmd_search.cc +6 -0
  38. package/deps/lcb/src/capi/cmd_search.hh +23 -0
  39. package/deps/lcb/src/capi/cmd_store.hh +33 -21
  40. package/deps/lcb/src/capi/cmd_subdoc.hh +35 -0
  41. package/deps/lcb/src/capi/cmd_touch.hh +23 -0
  42. package/deps/lcb/src/capi/cmd_unlock.hh +23 -0
  43. package/deps/lcb/src/capi/cmd_view.hh +6 -0
  44. package/deps/lcb/src/capi/collection_qualifier.hh +2 -2
  45. package/deps/lcb/src/cntl.cc +45 -11
  46. package/deps/lcb/src/crypto.cc +2 -2
  47. package/deps/lcb/src/dns-srv.cc +5 -3
  48. package/deps/lcb/src/errmap.cc +5 -9
  49. package/deps/lcb/src/errmap.h +7 -3
  50. package/deps/lcb/src/handler.cc +24 -18
  51. package/deps/lcb/src/hostlist.h +2 -2
  52. package/deps/lcb/src/http/http-priv.h +2 -2
  53. package/deps/lcb/src/http/http.cc +5 -2
  54. package/deps/lcb/src/instance.cc +20 -11
  55. package/deps/lcb/src/internal.h +9 -0
  56. package/deps/lcb/src/lcbio/connect.cc +14 -2
  57. package/deps/lcb/src/lcbio/connect.h +2 -2
  58. package/deps/lcb/src/lcbio/ctx.cc +4 -2
  59. package/deps/lcb/src/lcbio/ioutils.cc +9 -10
  60. package/deps/lcb/src/lcbio/manager.cc +1 -1
  61. package/deps/lcb/src/mcserver/mcserver.cc +9 -6
  62. package/deps/lcb/src/mcserver/negotiate.cc +39 -17
  63. package/deps/lcb/src/n1ql/ixmgmt.cc +1 -2
  64. package/deps/lcb/src/n1ql/query_handle.cc +41 -19
  65. package/deps/lcb/src/n1ql/query_handle.hh +28 -1
  66. package/deps/lcb/src/operations/counter.cc +18 -5
  67. package/deps/lcb/src/operations/exists.cc +25 -4
  68. package/deps/lcb/src/operations/get.cc +39 -19
  69. package/deps/lcb/src/operations/get_replica.cc +28 -8
  70. package/deps/lcb/src/operations/observe.cc +1 -1
  71. package/deps/lcb/src/operations/ping.cc +8 -8
  72. package/deps/lcb/src/operations/pktfwd.cc +2 -1
  73. package/deps/lcb/src/operations/remove.cc +39 -22
  74. package/deps/lcb/src/operations/store.cc +18 -5
  75. package/deps/lcb/src/operations/subdoc.cc +18 -6
  76. package/deps/lcb/src/operations/touch.cc +34 -16
  77. package/deps/lcb/src/operations/unlock.cc +24 -5
  78. package/deps/lcb/src/packetutils.h +3 -2
  79. package/deps/lcb/src/retryq.cc +24 -5
  80. package/deps/lcb/src/search/search.cc +1 -0
  81. package/deps/lcb/src/search/search_handle.cc +30 -8
  82. package/deps/lcb/src/search/search_handle.hh +29 -0
  83. package/deps/lcb/src/settings.cc +1 -1
  84. package/deps/lcb/src/ssl/ssl_common.c +6 -7
  85. package/deps/lcb/src/tracing/span.cc +47 -14
  86. package/deps/lcb/src/tracing/tracer.cc +11 -2
  87. package/deps/lcb/src/tracing/tracing-internal.h +105 -93
  88. package/deps/lcb/src/utilities.cc +43 -0
  89. package/deps/lcb/src/utilities.h +53 -0
  90. package/deps/lcb/src/vbucket/vbucket.c +34 -33
  91. package/deps/lcb/src/views/view_handle.cc +13 -5
  92. package/deps/lcb/src/views/view_handle.hh +29 -0
  93. package/deps/lcb/tests/CMakeLists.txt +21 -0
  94. package/deps/lcb/tests/basic/t_ctlcodes.cc +24 -3
  95. package/deps/lcb/tests/basic/t_jsparse.cc +8 -0
  96. package/deps/lcb/tests/basic/t_n1qlstrings.cc +73 -0
  97. package/deps/lcb/tests/iotests/mock-environment.cc +30 -1
  98. package/deps/lcb/tests/iotests/mock-environment.h +49 -0
  99. package/deps/lcb/tests/iotests/mock-unit-test.cc +104 -6
  100. package/deps/lcb/tests/iotests/mock-unit-test.h +34 -0
  101. package/deps/lcb/tests/iotests/t_collections.cc +1 -1
  102. package/deps/lcb/tests/iotests/t_confmon.cc +4 -2
  103. package/deps/lcb/tests/iotests/t_get.cc +109 -7
  104. package/deps/lcb/tests/iotests/t_http.cc +9 -4
  105. package/deps/lcb/tests/iotests/t_lock.cc +18 -0
  106. package/deps/lcb/tests/iotests/t_mutate.cc +157 -63
  107. package/deps/lcb/tests/iotests/t_n1ql.cc +330 -33
  108. package/deps/lcb/tests/iotests/t_views.cc +1 -0
  109. package/deps/lcb/tests/iotests/testutil.cc +168 -0
  110. package/deps/lcb/tests/iotests/testutil.h +116 -0
  111. package/deps/lcb/tests/mocksupport/procutil.c +32 -28
  112. package/deps/lcb/tests/mocksupport/server.c +0 -1
  113. package/deps/lcb/tests/mocksupport/timeout.c +2 -2
  114. package/deps/lcb/tools/cbc.cc +7 -0
  115. package/dist/analyticsindexmanager.js +512 -524
  116. package/dist/binding.d.ts +3 -0
  117. package/dist/bindingutilities.js +4 -0
  118. package/dist/bucket.js +1 -1
  119. package/dist/bucketmanager.d.ts +31 -1
  120. package/dist/bucketmanager.js +194 -186
  121. package/dist/cluster.d.ts +7 -0
  122. package/dist/cluster.js +48 -38
  123. package/dist/collection.js +11 -17
  124. package/dist/collectionmanager.js +181 -197
  125. package/dist/connection.d.ts +3 -1
  126. package/dist/connection.js +27 -16
  127. package/dist/couchbase.d.ts +1 -0
  128. package/dist/couchbase.js +3 -13
  129. package/dist/datastructures.js +239 -310
  130. package/dist/diagnosticsexecutor.js +70 -85
  131. package/dist/errors.d.ts +70 -0
  132. package/dist/errors.js +96 -2
  133. package/dist/eventingfunctionmanager.d.ts +804 -0
  134. package/dist/eventingfunctionmanager.js +993 -0
  135. package/dist/httpexecutor.d.ts +2 -1
  136. package/dist/httpexecutor.js +30 -37
  137. package/dist/queryindexmanager.js +240 -266
  138. package/dist/scope.js +10 -4
  139. package/dist/sdspecs.d.ts +1 -1
  140. package/dist/searchexecutor.js +3 -0
  141. package/dist/searchindexmanager.js +240 -271
  142. package/dist/searchquery.d.ts +17 -0
  143. package/dist/searchquery.js +22 -1
  144. package/dist/searchtypes.d.ts +7 -2
  145. package/dist/searchtypes.js +2 -2
  146. package/dist/usermanager.js +251 -264
  147. package/dist/utilities.d.ts +2 -0
  148. package/dist/utilities.js +7 -2
  149. package/dist/viewexecutor.js +1 -1
  150. package/dist/viewindexmanager.js +131 -150
  151. package/package.json +1 -1
  152. package/src/addondata.cpp +58 -0
  153. package/src/addondata.h +40 -0
  154. package/src/binding.cpp +3 -1
  155. package/src/cas.h +2 -2
  156. package/src/connection.cpp +25 -178
  157. package/src/connection.h +8 -65
  158. package/src/connection_ops.cpp +57 -34
  159. package/src/constants.cpp +3 -0
  160. package/src/instance.cpp +235 -0
  161. package/src/instance.h +102 -0
  162. package/src/{connection_callbacks.cpp → instance_callbacks.cpp} +34 -34
  163. package/src/logger.cpp +11 -1
  164. package/src/logger.h +3 -0
  165. package/src/metrics.cpp +10 -0
  166. package/src/metrics.h +3 -0
  167. package/src/mutationtoken.h +2 -2
  168. package/src/opbuilder.h +13 -15
  169. package/src/respreader.cpp +1 -0
  170. package/src/respreader.h +6 -4
  171. package/src/tracespan.h +11 -11
  172. package/src/tracing.cpp +11 -0
  173. package/src/tracing.h +3 -0
  174. package/src/valueparser.h +5 -0
  175. package/deps/lcb/example/observe/durability.c +0 -110
package/dist/binding.d.ts CHANGED
@@ -184,6 +184,8 @@ export interface CppBinding {
184
184
  LCB_ERR_SCOPE_NOT_FOUND: CppErrType;
185
185
  LCB_ERR_INDEX_NOT_FOUND: CppErrType;
186
186
  LCB_ERR_INDEX_EXISTS: CppErrType;
187
+ LCB_ERR_RATE_LIMITED: CppErrType;
188
+ LCB_ERR_QUOTA_LIMITED: CppErrType;
187
189
  LCB_ERR_DOCUMENT_NOT_FOUND: CppErrType;
188
190
  LCB_ERR_DOCUMENT_UNRETRIEVABLE: CppErrType;
189
191
  LCB_ERR_DOCUMENT_LOCKED: CppErrType;
@@ -298,6 +300,7 @@ export interface CppBinding {
298
300
  LCB_HTTP_TYPE_QUERY: CppHttpType;
299
301
  LCB_HTTP_TYPE_SEARCH: CppHttpType;
300
302
  LCB_HTTP_TYPE_ANALYTICS: CppHttpType;
303
+ LCB_HTTP_TYPE_EVENTING: CppHttpType;
301
304
  LCB_HTTP_METHOD_GET: CppHttpMethod;
302
305
  LCB_HTTP_METHOD_POST: CppHttpMethod;
303
306
  LCB_HTTP_METHOD_PUT: CppHttpMethod;
@@ -214,6 +214,10 @@ function translateCppError(err) {
214
214
  return new errs.IndexNotFoundError(codeErr, context);
215
215
  case binding_1.default.LCB_ERR_INDEX_EXISTS:
216
216
  return new errs.IndexExistsError(codeErr, context);
217
+ case binding_1.default.LCB_ERR_RATE_LIMITED:
218
+ return new errs.RateLimitedError(codeErr, context);
219
+ case binding_1.default.LCB_ERR_QUOTA_LIMITED:
220
+ return new errs.QuotaLimitedError(codeErr, context);
217
221
  /* KeyValue Error Definitions */
218
222
  case binding_1.default.LCB_ERR_DOCUMENT_NOT_FOUND:
219
223
  return new errs.DocumentNotFoundError(codeErr, context);
package/dist/bucket.js CHANGED
@@ -103,7 +103,7 @@ class Bucket {
103
103
  */
104
104
  viewQuery(designDoc, viewName, options, callback) {
105
105
  if (options instanceof Function) {
106
- callback = arguments[0];
106
+ callback = arguments[2];
107
107
  options = undefined;
108
108
  }
109
109
  if (!options) {
@@ -18,7 +18,14 @@ export declare enum ConflictResolutionType {
18
18
  /**
19
19
  * Indicates that the seqno of the document should be used for conflict resolution.
20
20
  */
21
- SequenceNumber = "seqno"
21
+ SequenceNumber = "seqno",
22
+ /**
23
+ * Indicates that custom conflict resolution should be used.
24
+ *
25
+ * @experimental This mode is only available in Couchbase Server 7.1 with the
26
+ * "developer-preview" mode enabled.
27
+ */
28
+ Custom = "custom"
22
29
  }
23
30
  /**
24
31
  * Represents the type of a bucket.
@@ -39,6 +46,21 @@ export declare enum BucketType {
39
46
  */
40
47
  Ephemeral = "ephemeral"
41
48
  }
49
+ /**
50
+ * Represents the storage backend to use for a bucket.
51
+ *
52
+ * @category Management
53
+ */
54
+ export declare enum StorageBackend {
55
+ /**
56
+ * Indicates the bucket should use the Couchstore storage engine.
57
+ */
58
+ Couchstore = "couchstore",
59
+ /**
60
+ * Indicates the bucket should use the Magma storage engine.
61
+ */
62
+ Magma = "magma"
63
+ }
42
64
  /**
43
65
  * Represents the eviction policy that should be used for a bucket.
44
66
  *
@@ -117,6 +139,10 @@ export interface IBucketSettings {
117
139
  * Specifies the type of bucket that should be used.
118
140
  */
119
141
  bucketType: BucketType | string;
142
+ /**
143
+ * Specifies the storage backend to use for the bucket.
144
+ */
145
+ storageBackend: StorageBackend | string;
120
146
  /**
121
147
  * Specifies the ejection method that should be used.
122
148
  */
@@ -189,6 +215,10 @@ export declare class BucketSettings implements IBucketSettings {
189
215
  * Specifies the type of bucket that should be used.
190
216
  */
191
217
  bucketType: BucketType;
218
+ /**
219
+ * Specifies the storage backend to use for the bucket.
220
+ */
221
+ storageBackend: StorageBackend | string;
192
222
  /**
193
223
  * Specifies the ejection method that should be used.
194
224
  */
@@ -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;
@@ -162,6 +177,7 @@ 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,
@@ -180,6 +196,7 @@ 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,
@@ -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: 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: 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.d.ts CHANGED
@@ -5,6 +5,7 @@ import { Bucket } from './bucket';
5
5
  import { BucketManager } from './bucketmanager';
6
6
  import { Connection } from './connection';
7
7
  import { DiagnosticsOptions, DiagnosticsResult, PingOptions, PingResult } from './diagnosticstypes';
8
+ import { EventingFunctionManager } from './eventingfunctionmanager';
8
9
  import { LogFunc } from './logging';
9
10
  import { Meter } from './metrics';
10
11
  import { QueryIndexManager } from './queryindexmanager';
@@ -158,6 +159,12 @@ export declare class Cluster {
158
159
  * indexes of this cluster.
159
160
  */
160
161
  searchIndexes(): SearchIndexManager;
162
+ /**
163
+ * Returns a EventingFunctionManager which can be used to manage the eventing
164
+ * functions of this cluster.
165
+ * Volatile: This API is subject to change at any time.
166
+ */
167
+ eventingFunctions(): EventingFunctionManager;
161
168
  /**
162
169
  * Executes a N1QL query against the cluster.
163
170
  *