couchbase 3.2.2 → 3.2.5

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 (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,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
@@ -284,7 +278,7 @@ class Collection {
284
278
  options = {};
285
279
  }
286
280
  const cas = options.cas || null;
287
- const cppDuraMode = bindingutilities_1.duraLevelToCppDuraMode(options.durabilityLevel);
281
+ const cppDuraMode = (0, bindingutilities_1.duraLevelToCppDuraMode)(options.durabilityLevel);
288
282
  const persistTo = options.durabilityPersistTo;
289
283
  const replicateTo = options.durabilityReplicateTo;
290
284
  const parentSpan = options.parentSpan;
@@ -342,13 +336,13 @@ 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) {
349
343
  options = {};
350
344
  }
351
- const cppDuraMode = bindingutilities_1.duraLevelToCppDuraMode(options.durabilityLevel);
345
+ const cppDuraMode = (0, bindingutilities_1.duraLevelToCppDuraMode)(options.durabilityLevel);
352
346
  const persistTo = options.durabilityPersistTo;
353
347
  const replicateTo = options.durabilityReplicateTo;
354
348
  const parentSpan = options.parentSpan;
@@ -451,7 +445,7 @@ class Collection {
451
445
  if (res && res.content) {
452
446
  for (let i = 0; i < res.content.length; ++i) {
453
447
  const itemRes = res.content[i];
454
- itemRes.error = bindingutilities_1.translateCppError(itemRes.error);
448
+ itemRes.error = (0, bindingutilities_1.translateCppError)(itemRes.error);
455
449
  if (itemRes.value && itemRes.value.length > 0) {
456
450
  itemRes.value = JSON.parse(itemRes.value);
457
451
  }
@@ -522,7 +516,7 @@ class Collection {
522
516
  }
523
517
  const expiry = options.preserveExpiry ? -1 : options.expiry;
524
518
  const cas = options.cas;
525
- const cppDuraMode = bindingutilities_1.duraLevelToCppDuraMode(options.durabilityLevel);
519
+ const cppDuraMode = (0, bindingutilities_1.duraLevelToCppDuraMode)(options.durabilityLevel);
526
520
  const persistTo = options.durabilityPersistTo;
527
521
  const replicateTo = options.durabilityReplicateTo;
528
522
  const parentSpan = options.parentSpan;
@@ -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) {
@@ -625,7 +619,7 @@ class Collection {
625
619
  }
626
620
  const expiry = options.preserveExpiry ? -1 : options.expiry;
627
621
  const cas = options.cas;
628
- const cppDuraMode = bindingutilities_1.duraLevelToCppDuraMode(options.durabilityLevel);
622
+ const cppDuraMode = (0, bindingutilities_1.duraLevelToCppDuraMode)(options.durabilityLevel);
629
623
  const persistTo = options.durabilityPersistTo;
630
624
  const replicateTo = options.durabilityReplicateTo;
631
625
  const transcoder = options.transcoder || this.transcoder;
@@ -653,7 +647,7 @@ class Collection {
653
647
  }
654
648
  const initial = options.initial;
655
649
  const expiry = options.expiry;
656
- const cppDuraMode = bindingutilities_1.duraLevelToCppDuraMode(options.durabilityLevel);
650
+ const cppDuraMode = (0, bindingutilities_1.duraLevelToCppDuraMode)(options.durabilityLevel);
657
651
  const persistTo = options.durabilityPersistTo;
658
652
  const replicateTo = options.durabilityReplicateTo;
659
653
  const parentSpan = options.parentSpan;
@@ -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.CollectionManager = exports.ScopeSpec = exports.CollectionSpec = void 0;
13
4
  const errors_1 = require("./errors");
@@ -101,97 +92,93 @@ class CollectionManager {
101
92
  * @param options Optional parameters for this operation.
102
93
  * @param callback A node-style callback to be invoked after execution.
103
94
  */
104
- getAllScopes(options, callback) {
105
- return __awaiter(this, arguments, void 0, function* () {
106
- if (options instanceof Function) {
107
- callback = arguments[0];
108
- options = undefined;
109
- }
110
- if (!options) {
111
- options = {};
112
- }
113
- const bucketName = this._bucket.name;
114
- const parentSpan = options.parentSpan;
115
- const timeout = options.timeout;
116
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
117
- const res = yield this._http.request({
118
- type: httpexecutor_1.HttpServiceType.Management,
119
- method: httpexecutor_1.HttpMethod.Post,
120
- path: `/pools/default/buckets/${bucketName}/scopes`,
121
- parentSpan: parentSpan,
122
- timeout: timeout,
123
- });
124
- if (res.statusCode !== 200) {
125
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
126
- const errText = res.body.toString().toLowerCase();
127
- if (errText.includes('not allowed on this version of cluster') ||
128
- res.statusCode === 404) {
129
- throw new errors_1.FeatureNotAvailableError(undefined, errCtx);
130
- }
131
- throw new errors_1.CouchbaseError('failed to get scopes', undefined, errCtx);
95
+ async getAllScopes(options, callback) {
96
+ if (options instanceof Function) {
97
+ callback = arguments[0];
98
+ options = undefined;
99
+ }
100
+ if (!options) {
101
+ options = {};
102
+ }
103
+ const bucketName = this._bucket.name;
104
+ const parentSpan = options.parentSpan;
105
+ const timeout = options.timeout;
106
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
107
+ const res = await this._http.request({
108
+ type: httpexecutor_1.HttpServiceType.Management,
109
+ method: httpexecutor_1.HttpMethod.Get,
110
+ path: `/pools/default/buckets/${bucketName}/scopes`,
111
+ parentSpan: parentSpan,
112
+ timeout: timeout,
113
+ });
114
+ if (res.statusCode !== 200) {
115
+ const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
116
+ const errText = res.body.toString().toLowerCase();
117
+ if (errText.includes('not allowed on this version of cluster') ||
118
+ res.statusCode === 404) {
119
+ throw new errors_1.FeatureNotAvailableError(undefined, errCtx);
132
120
  }
133
- const scopesData = JSON.parse(res.body.toString());
134
- const scopes = scopesData.map((scopeData) => ScopeSpec._fromNsData(scopeData));
135
- return scopes;
136
- }), callback);
137
- });
121
+ throw new errors_1.CouchbaseError('failed to get scopes', undefined, errCtx);
122
+ }
123
+ const scopesData = JSON.parse(res.body.toString());
124
+ const scopes = scopesData.scopes.map((scopeData) => ScopeSpec._fromNsData(scopeData));
125
+ return scopes;
126
+ }, callback);
138
127
  }
139
128
  /**
140
129
  * @internal
141
130
  */
142
- createCollection() {
143
- return __awaiter(this, arguments, void 0, function* () {
144
- let collectionSpec = arguments[0];
145
- let options = arguments[1];
146
- let callback = arguments[2];
147
- // Deprecated usage conversion for (name, scopeName, options, callback)
148
- if (typeof collectionSpec === 'string') {
149
- collectionSpec = {
150
- name: arguments[0],
151
- scopeName: arguments[1],
152
- };
153
- options = arguments[2];
154
- callback = arguments[3];
155
- }
156
- if (options instanceof Function) {
157
- callback = arguments[2];
158
- options = undefined;
159
- }
160
- if (!options) {
161
- options = {};
162
- }
163
- const bucketName = this._bucket.name;
164
- const parentSpan = options.parentSpan;
165
- const timeout = options.timeout;
166
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
167
- const collectionData = CollectionSpec._toNsData(collectionSpec);
168
- const res = yield this._http.request({
169
- type: httpexecutor_1.HttpServiceType.Management,
170
- method: httpexecutor_1.HttpMethod.Post,
171
- path: `/pools/default/buckets/${bucketName}/scopes/${collectionSpec.scopeName}/collections`,
172
- contentType: 'application/x-www-form-urlencoded',
173
- body: utilities_1.cbQsStringify(collectionData),
174
- parentSpan: parentSpan,
175
- timeout: timeout,
176
- });
177
- if (res.statusCode !== 200) {
178
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
179
- const errText = res.body.toString().toLowerCase();
180
- if (errText.includes('already exists') &&
181
- errText.includes('collection')) {
182
- throw new errors_1.CollectionExistsError(undefined, errCtx);
183
- }
184
- if (errText.includes('not found') && errText.includes('scope')) {
185
- throw new errors_1.ScopeNotFoundError(undefined, errCtx);
186
- }
187
- if (errText.includes('not allowed on this version of cluster') ||
188
- res.statusCode === 404) {
189
- throw new errors_1.FeatureNotAvailableError(undefined, errCtx);
190
- }
191
- throw new errors_1.CouchbaseError('failed to create collection', undefined, errCtx);
131
+ async createCollection() {
132
+ let collectionSpec = arguments[0];
133
+ let options = arguments[1];
134
+ let callback = arguments[2];
135
+ // Deprecated usage conversion for (name, scopeName, options, callback)
136
+ if (typeof collectionSpec === 'string') {
137
+ collectionSpec = {
138
+ name: arguments[0],
139
+ scopeName: arguments[1],
140
+ };
141
+ options = arguments[2];
142
+ callback = arguments[3];
143
+ }
144
+ if (options instanceof Function) {
145
+ callback = arguments[1];
146
+ options = undefined;
147
+ }
148
+ if (!options) {
149
+ options = {};
150
+ }
151
+ const bucketName = this._bucket.name;
152
+ const parentSpan = options.parentSpan;
153
+ const timeout = options.timeout;
154
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
155
+ const collectionData = CollectionSpec._toNsData(collectionSpec);
156
+ const res = await this._http.request({
157
+ type: httpexecutor_1.HttpServiceType.Management,
158
+ method: httpexecutor_1.HttpMethod.Post,
159
+ path: `/pools/default/buckets/${bucketName}/scopes/${collectionSpec.scopeName}/collections`,
160
+ contentType: 'application/x-www-form-urlencoded',
161
+ body: (0, utilities_1.cbQsStringify)(collectionData),
162
+ parentSpan: parentSpan,
163
+ timeout: timeout,
164
+ });
165
+ if (res.statusCode !== 200) {
166
+ const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
167
+ const errText = res.body.toString().toLowerCase();
168
+ if (errText.includes('already exists') &&
169
+ errText.includes('collection')) {
170
+ throw new errors_1.CollectionExistsError(undefined, errCtx);
192
171
  }
193
- }), callback);
194
- });
172
+ if (errText.includes('not found') && errText.includes('scope')) {
173
+ throw new errors_1.ScopeNotFoundError(undefined, errCtx);
174
+ }
175
+ if (errText.includes('not allowed on this version of cluster') ||
176
+ res.statusCode === 404) {
177
+ throw new errors_1.FeatureNotAvailableError(undefined, errCtx);
178
+ }
179
+ throw new errors_1.CouchbaseError('failed to create collection', undefined, errCtx);
180
+ }
181
+ }, callback);
195
182
  }
196
183
  /**
197
184
  * Drops a collection from a scope.
@@ -201,43 +188,41 @@ class CollectionManager {
201
188
  * @param options Optional parameters for this operation.
202
189
  * @param callback A node-style callback to be invoked after execution.
203
190
  */
204
- dropCollection(collectionName, scopeName, options, callback) {
205
- return __awaiter(this, arguments, void 0, function* () {
206
- if (options instanceof Function) {
207
- callback = arguments[2];
208
- options = undefined;
209
- }
210
- if (!options) {
211
- options = {};
212
- }
213
- const bucketName = this._bucket.name;
214
- const parentSpan = options.parentSpan;
215
- const timeout = options.timeout;
216
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
217
- const res = yield this._http.request({
218
- type: httpexecutor_1.HttpServiceType.Management,
219
- method: httpexecutor_1.HttpMethod.Delete,
220
- path: `/pools/default/buckets/${bucketName}/scopes/${scopeName}/collections/${collectionName}`,
221
- parentSpan: parentSpan,
222
- timeout: timeout,
223
- });
224
- if (res.statusCode !== 200) {
225
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
226
- const errText = res.body.toString().toLowerCase();
227
- if (errText.includes('not found') && errText.includes('collection')) {
228
- throw new errors_1.CollectionNotFoundError(undefined, errCtx);
229
- }
230
- if (errText.includes('not found') && errText.includes('scope')) {
231
- throw new errors_1.ScopeNotFoundError(undefined, errCtx);
232
- }
233
- if (errText.includes('not allowed on this version of cluster') ||
234
- res.statusCode === 404) {
235
- throw new errors_1.FeatureNotAvailableError(undefined, errCtx);
236
- }
237
- throw new errors_1.CouchbaseError('failed to drop collection', undefined, errCtx);
191
+ async dropCollection(collectionName, scopeName, options, callback) {
192
+ if (options instanceof Function) {
193
+ callback = arguments[2];
194
+ options = undefined;
195
+ }
196
+ if (!options) {
197
+ options = {};
198
+ }
199
+ const bucketName = this._bucket.name;
200
+ const parentSpan = options.parentSpan;
201
+ const timeout = options.timeout;
202
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
203
+ const res = await this._http.request({
204
+ type: httpexecutor_1.HttpServiceType.Management,
205
+ method: httpexecutor_1.HttpMethod.Delete,
206
+ path: `/pools/default/buckets/${bucketName}/scopes/${scopeName}/collections/${collectionName}`,
207
+ parentSpan: parentSpan,
208
+ timeout: timeout,
209
+ });
210
+ if (res.statusCode !== 200) {
211
+ const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
212
+ const errText = res.body.toString().toLowerCase();
213
+ if (errText.includes('not found') && errText.includes('collection')) {
214
+ throw new errors_1.CollectionNotFoundError(undefined, errCtx);
238
215
  }
239
- }), callback);
240
- });
216
+ if (errText.includes('not found') && errText.includes('scope')) {
217
+ throw new errors_1.ScopeNotFoundError(undefined, errCtx);
218
+ }
219
+ if (errText.includes('not allowed on this version of cluster') ||
220
+ res.statusCode === 404) {
221
+ throw new errors_1.FeatureNotAvailableError(undefined, errCtx);
222
+ }
223
+ throw new errors_1.CouchbaseError('failed to drop collection', undefined, errCtx);
224
+ }
225
+ }, callback);
241
226
  }
242
227
  /**
243
228
  * Creates a new scope.
@@ -246,44 +231,42 @@ class CollectionManager {
246
231
  * @param options Optional parameters for this operation.
247
232
  * @param callback A node-style callback to be invoked after execution.
248
233
  */
249
- createScope(scopeName, options, callback) {
250
- return __awaiter(this, arguments, void 0, function* () {
251
- if (options instanceof Function) {
252
- callback = arguments[1];
253
- options = undefined;
254
- }
255
- if (!options) {
256
- options = {};
257
- }
258
- const bucketName = this._bucket.name;
259
- const parentSpan = options.parentSpan;
260
- const timeout = options.timeout;
261
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
262
- const res = yield this._http.request({
263
- type: httpexecutor_1.HttpServiceType.Management,
264
- method: httpexecutor_1.HttpMethod.Post,
265
- path: `/pools/default/buckets/${bucketName}/scopes`,
266
- contentType: 'application/x-www-form-urlencoded',
267
- body: utilities_1.cbQsStringify({
268
- name: scopeName,
269
- }),
270
- parentSpan: parentSpan,
271
- timeout: timeout,
272
- });
273
- if (res.statusCode !== 200) {
274
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
275
- const errText = res.body.toString().toLowerCase();
276
- if (errText.includes('already exists') && errText.includes('scope')) {
277
- throw new errors_1.ScopeExistsError(undefined, errCtx);
278
- }
279
- if (errText.includes('not allowed on this version of cluster') ||
280
- res.statusCode === 404) {
281
- throw new errors_1.FeatureNotAvailableError(undefined, errCtx);
282
- }
283
- throw new errors_1.CouchbaseError('failed to create scope', undefined, errCtx);
234
+ async createScope(scopeName, options, callback) {
235
+ if (options instanceof Function) {
236
+ callback = arguments[1];
237
+ options = undefined;
238
+ }
239
+ if (!options) {
240
+ options = {};
241
+ }
242
+ const bucketName = this._bucket.name;
243
+ const parentSpan = options.parentSpan;
244
+ const timeout = options.timeout;
245
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
246
+ const res = await this._http.request({
247
+ type: httpexecutor_1.HttpServiceType.Management,
248
+ method: httpexecutor_1.HttpMethod.Post,
249
+ path: `/pools/default/buckets/${bucketName}/scopes`,
250
+ contentType: 'application/x-www-form-urlencoded',
251
+ body: (0, utilities_1.cbQsStringify)({
252
+ name: scopeName,
253
+ }),
254
+ parentSpan: parentSpan,
255
+ timeout: timeout,
256
+ });
257
+ if (res.statusCode !== 200) {
258
+ const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
259
+ const errText = res.body.toString().toLowerCase();
260
+ if (errText.includes('already exists') && errText.includes('scope')) {
261
+ throw new errors_1.ScopeExistsError(undefined, errCtx);
284
262
  }
285
- }), callback);
286
- });
263
+ if (errText.includes('not allowed on this version of cluster') ||
264
+ res.statusCode === 404) {
265
+ throw new errors_1.FeatureNotAvailableError(undefined, errCtx);
266
+ }
267
+ throw new errors_1.CouchbaseError('failed to create scope', undefined, errCtx);
268
+ }
269
+ }, callback);
287
270
  }
288
271
  /**
289
272
  * Drops a scope.
@@ -292,40 +275,38 @@ class CollectionManager {
292
275
  * @param options Optional parameters for this operation.
293
276
  * @param callback A node-style callback to be invoked after execution.
294
277
  */
295
- dropScope(scopeName, options, callback) {
296
- return __awaiter(this, arguments, void 0, function* () {
297
- if (options instanceof Function) {
298
- callback = arguments[2];
299
- options = undefined;
300
- }
301
- if (!options) {
302
- options = {};
303
- }
304
- const bucketName = this._bucket.name;
305
- const parentSpan = options.parentSpan;
306
- const timeout = options.timeout;
307
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
308
- const res = yield this._http.request({
309
- type: httpexecutor_1.HttpServiceType.Management,
310
- method: httpexecutor_1.HttpMethod.Delete,
311
- path: `/pools/default/buckets/${bucketName}/scopes/${scopeName}`,
312
- parentSpan: parentSpan,
313
- timeout: timeout,
314
- });
315
- if (res.statusCode !== 200) {
316
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
317
- const errText = res.body.toString().toLowerCase();
318
- if (errText.includes('not found') && errText.includes('scope')) {
319
- throw new errors_1.ScopeNotFoundError(undefined, errCtx);
320
- }
321
- if (errText.includes('not allowed on this version of cluster') ||
322
- res.statusCode === 404) {
323
- throw new errors_1.FeatureNotAvailableError(undefined, errCtx);
324
- }
325
- throw new errors_1.CouchbaseError('failed to drop scope', undefined, errCtx);
278
+ async dropScope(scopeName, options, callback) {
279
+ if (options instanceof Function) {
280
+ callback = arguments[1];
281
+ options = undefined;
282
+ }
283
+ if (!options) {
284
+ options = {};
285
+ }
286
+ const bucketName = this._bucket.name;
287
+ const parentSpan = options.parentSpan;
288
+ const timeout = options.timeout;
289
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
290
+ const res = await this._http.request({
291
+ type: httpexecutor_1.HttpServiceType.Management,
292
+ method: httpexecutor_1.HttpMethod.Delete,
293
+ path: `/pools/default/buckets/${bucketName}/scopes/${scopeName}`,
294
+ parentSpan: parentSpan,
295
+ timeout: timeout,
296
+ });
297
+ if (res.statusCode !== 200) {
298
+ const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
299
+ const errText = res.body.toString().toLowerCase();
300
+ if (errText.includes('not found') && errText.includes('scope')) {
301
+ throw new errors_1.ScopeNotFoundError(undefined, errCtx);
326
302
  }
327
- }), callback);
328
- });
303
+ if (errText.includes('not allowed on this version of cluster') ||
304
+ res.statusCode === 404) {
305
+ throw new errors_1.FeatureNotAvailableError(undefined, errCtx);
306
+ }
307
+ throw new errors_1.CouchbaseError('failed to drop scope', undefined, errCtx);
308
+ }
309
+ }, callback);
329
310
  }
330
311
  }
331
312
  exports.CollectionManager = CollectionManager;
@@ -50,6 +50,9 @@ class Connection {
50
50
  if (options.kvConnectTimeout) {
51
51
  lcbDsnObj.options.config_total_timeout = fmtTmt(options.kvConnectTimeout);
52
52
  }
53
+ else {
54
+ lcbDsnObj.options.config_total_timeout = '30s';
55
+ }
53
56
  if (options.kvTimeout) {
54
57
  lcbDsnObj.options.timeout = fmtTmt(options.kvTimeout);
55
58
  }
@@ -144,7 +147,7 @@ class Connection {
144
147
  this._inst.connect((err) => {
145
148
  if (err) {
146
149
  this._closed = true;
147
- this._closedErr = bindingutilities_1.translateCppError(err);
150
+ this._closedErr = (0, bindingutilities_1.translateCppError)(err);
148
151
  callback(this._closedErr);
149
152
  this._connectWaiters.forEach((waitFn) => waitFn());
150
153
  this._connectWaiters = [];
@@ -159,7 +162,7 @@ class Connection {
159
162
  selectBucket(bucketName, callback) {
160
163
  this._inst.selectBucket(bucketName, (err) => {
161
164
  if (err) {
162
- return callback(bindingutilities_1.translateCppError(err));
165
+ return callback((0, bindingutilities_1.translateCppError)(err));
163
166
  }
164
167
  this._opened = true;
165
168
  callback(null);
@@ -242,7 +245,7 @@ class Connection {
242
245
  return callback(this._closedErr);
243
246
  }
244
247
  wrappedArgs.push((err, ...cbArgs) => {
245
- const translatedErr = bindingutilities_1.translateCppError(err);
248
+ const translatedErr = (0, bindingutilities_1.translateCppError)(err);
246
249
  callback.apply(undefined, [translatedErr, ...cbArgs]);
247
250
  });
248
251
  fn.apply(thisArg, wrappedArgs);
package/dist/connspec.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
package/dist/couchbase.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -9,15 +13,6 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
9
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
15
  };
12
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
- return new (P || (P = Promise))(function (resolve, reject) {
15
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
- step((generator = generator.apply(thisArg, _arguments || [])).next());
19
- });
20
- };
21
16
  var __importDefault = (this && this.__importDefault) || function (mod) {
22
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
18
  };
@@ -35,10 +30,8 @@ const cluster_1 = require("./cluster");
35
30
  *
36
31
  * @category Core
37
32
  */
38
- function connect(connStr, options, callback) {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- return cluster_1.Cluster.connect(connStr, options, callback);
41
- });
33
+ async function connect(connStr, options, callback) {
34
+ return cluster_1.Cluster.connect(connStr, options, callback);
42
35
  }
43
36
  exports.connect = connect;
44
37
  /**