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/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");
@@ -17,6 +8,7 @@ const bucketmanager_1 = require("./bucketmanager");
17
8
  const connection_1 = require("./connection");
18
9
  const diagnosticsexecutor_1 = require("./diagnosticsexecutor");
19
10
  const errors_1 = require("./errors");
11
+ const eventingfunctionmanager_1 = require("./eventingfunctionmanager");
20
12
  const logging_1 = require("./logging");
21
13
  const logging_2 = require("./logging");
22
14
  const metrics_1 = require("./metrics");
@@ -108,14 +100,12 @@ class Cluster {
108
100
  /**
109
101
  @internal
110
102
  */
111
- static connect(connStr, options, callback) {
112
- return __awaiter(this, void 0, void 0, function* () {
113
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
114
- const cluster = new Cluster(connStr, options);
115
- yield cluster._clusterConnect();
116
- return cluster;
117
- }), callback);
118
- });
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);
119
109
  }
120
110
  /**
121
111
  * Creates a Bucket object reference to a specific bucket.
@@ -160,6 +150,14 @@ class Cluster {
160
150
  searchIndexes() {
161
151
  return new searchindexmanager_1.SearchIndexManager(this);
162
152
  }
153
+ /**
154
+ * Returns a EventingFunctionManager which can be used to manage the eventing
155
+ * functions of this cluster.
156
+ * Volatile: This API is subject to change at any time.
157
+ */
158
+ eventingFunctions() {
159
+ return new eventingfunctionmanager_1.EventingFunctionManager(this);
160
+ }
163
161
  /**
164
162
  * Executes a N1QL query against the cluster.
165
163
  *
@@ -169,7 +167,7 @@ class Cluster {
169
167
  */
170
168
  query(statement, options, callback) {
171
169
  if (options instanceof Function) {
172
- callback = arguments[0];
170
+ callback = arguments[1];
173
171
  options = undefined;
174
172
  }
175
173
  if (!options) {
@@ -189,7 +187,7 @@ class Cluster {
189
187
  */
190
188
  analyticsQuery(statement, options, callback) {
191
189
  if (options instanceof Function) {
192
- callback = arguments[0];
190
+ callback = arguments[1];
193
191
  options = undefined;
194
192
  }
195
193
  if (!options) {
@@ -210,7 +208,7 @@ class Cluster {
210
208
  */
211
209
  searchQuery(indexName, query, options, callback) {
212
210
  if (options instanceof Function) {
213
- callback = arguments[0];
211
+ callback = arguments[2];
214
212
  options = undefined;
215
213
  }
216
214
  if (!options) {
@@ -272,12 +270,12 @@ class Cluster {
272
270
  * @param callback A node-style callback to be invoked after execution.
273
271
  */
274
272
  close(callback) {
275
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
276
- const closeOneConn = (conn) => __awaiter(this, void 0, void 0, function* () {
273
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
274
+ const closeOneConn = async (conn) => {
277
275
  return utilities_1.PromiseHelper.wrap((wrapCallback) => {
278
276
  conn.close(wrapCallback);
279
277
  });
280
- });
278
+ };
281
279
  let allConns = Object.values(this._conns);
282
280
  this._conns = {};
283
281
  if (this._clusterConn) {
@@ -285,11 +283,25 @@ class Cluster {
285
283
  this._clusterConn = null;
286
284
  }
287
285
  this._closed = true;
288
- yield Promise.all(allConns.map((conn) => closeOneConn(conn)));
289
- }), callback);
286
+ await Promise.all(allConns.map((conn) => closeOneConn(conn)));
287
+ }, callback);
290
288
  }
291
289
  _buildConnOpts(extraOpts) {
292
- 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
+ };
293
305
  if (this._auth) {
294
306
  const passAuth = this._auth;
295
307
  if (passAuth.username || passAuth.password) {
@@ -304,18 +316,16 @@ class Cluster {
304
316
  }
305
317
  return connOpts;
306
318
  }
307
- _clusterConnect() {
308
- return __awaiter(this, void 0, void 0, function* () {
309
- return new Promise((resolve, reject) => {
310
- const connOpts = this._buildConnOpts({});
311
- const conn = new connection_1.Connection(connOpts);
312
- conn.connect((err) => {
313
- if (err) {
314
- return reject(err);
315
- }
316
- this._clusterConn = conn;
317
- resolve(null);
318
- });
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);
319
329
  });
320
330
  });
321
331
  }
@@ -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
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -145,8 +136,11 @@ class Collection {
145
136
  spec.push(sdspecs_1.LookupInSpec.get(''));
146
137
  needReproject = true;
147
138
  }
148
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
149
- const res = yield this.lookupIn(key, spec, Object.assign(Object.assign({}, options), { parentSpan: options.parentSpan }));
139
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
140
+ const res = await this.lookupIn(key, spec, {
141
+ ...options,
142
+ parentSpan: options.parentSpan,
143
+ });
150
144
  let content = null;
151
145
  let expiry = undefined;
152
146
  if (expiryStart >= 0) {
@@ -178,7 +172,7 @@ class Collection {
178
172
  cas: res.cas,
179
173
  expiryTime: expiry,
180
174
  });
181
- }), callback);
175
+ }, callback);
182
176
  }
183
177
  /**
184
178
  * Checks whether a specific document exists or not.
@@ -218,10 +212,10 @@ class Collection {
218
212
  * @param callback A node-style callback to be invoked after execution.
219
213
  */
220
214
  getAnyReplica(key, options, callback) {
221
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
222
- const replicas = yield this._getReplica(binding_1.default.LCB_REPLICA_MODE_ANY, key, options);
215
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
216
+ const replicas = await this._getReplica(binding_1.default.LCB_REPLICA_MODE_ANY, key, options);
223
217
  return replicas[0];
224
- }), callback);
218
+ }, callback);
225
219
  }
226
220
  /**
227
221
  * Retrieves the value of the document from all available replicas. Note that
@@ -342,7 +336,7 @@ class Collection {
342
336
  */
343
337
  touch(key, expiry, options, callback) {
344
338
  if (options instanceof Function) {
345
- callback = arguments[1];
339
+ callback = arguments[2];
346
340
  options = undefined;
347
341
  }
348
342
  if (!options) {
@@ -592,7 +586,7 @@ class Collection {
592
586
  }
593
587
  _getReplica(mode, key, options, callback) {
594
588
  if (options instanceof Function) {
595
- callback = arguments[1];
589
+ callback = arguments[2];
596
590
  options = undefined;
597
591
  }
598
592
  if (!options) {