couchbase 3.2.0 → 3.2.4

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -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: 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,40 +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 allowed on this version of cluster') ||
231
- res.statusCode === 404) {
232
- throw new errors_1.FeatureNotAvailableError(undefined, errCtx);
233
- }
234
- 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);
235
215
  }
236
- }), callback);
237
- });
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);
238
226
  }
239
227
  /**
240
228
  * Creates a new scope.
@@ -243,44 +231,42 @@ class CollectionManager {
243
231
  * @param options Optional parameters for this operation.
244
232
  * @param callback A node-style callback to be invoked after execution.
245
233
  */
246
- createScope(scopeName, options, callback) {
247
- return __awaiter(this, arguments, void 0, function* () {
248
- if (options instanceof Function) {
249
- callback = arguments[1];
250
- options = undefined;
251
- }
252
- if (!options) {
253
- options = {};
254
- }
255
- const bucketName = this._bucket.name;
256
- const parentSpan = options.parentSpan;
257
- const timeout = options.timeout;
258
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
259
- const res = yield this._http.request({
260
- type: httpexecutor_1.HttpServiceType.Management,
261
- method: httpexecutor_1.HttpMethod.Post,
262
- path: `/pools/default/buckets/${bucketName}/scopes`,
263
- contentType: 'application/x-www-form-urlencoded',
264
- body: utilities_1.cbQsStringify({
265
- name: scopeName,
266
- }),
267
- parentSpan: parentSpan,
268
- timeout: timeout,
269
- });
270
- if (res.statusCode !== 200) {
271
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
272
- const errText = res.body.toString().toLowerCase();
273
- if (errText.includes('already exists') && errText.includes('scope')) {
274
- throw new errors_1.ScopeExistsError(undefined, errCtx);
275
- }
276
- if (errText.includes('not allowed on this version of cluster') ||
277
- res.statusCode === 404) {
278
- throw new errors_1.FeatureNotAvailableError(undefined, errCtx);
279
- }
280
- 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: 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);
281
262
  }
282
- }), callback);
283
- });
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);
284
270
  }
285
271
  /**
286
272
  * Drops a scope.
@@ -289,40 +275,38 @@ class CollectionManager {
289
275
  * @param options Optional parameters for this operation.
290
276
  * @param callback A node-style callback to be invoked after execution.
291
277
  */
292
- dropScope(scopeName, options, callback) {
293
- return __awaiter(this, arguments, void 0, function* () {
294
- if (options instanceof Function) {
295
- callback = arguments[2];
296
- options = undefined;
297
- }
298
- if (!options) {
299
- options = {};
300
- }
301
- const bucketName = this._bucket.name;
302
- const parentSpan = options.parentSpan;
303
- const timeout = options.timeout;
304
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
305
- const res = yield this._http.request({
306
- type: httpexecutor_1.HttpServiceType.Management,
307
- method: httpexecutor_1.HttpMethod.Delete,
308
- path: `/pools/default/buckets/${bucketName}/scopes/${scopeName}`,
309
- parentSpan: parentSpan,
310
- timeout: timeout,
311
- });
312
- if (res.statusCode !== 200) {
313
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
314
- const errText = res.body.toString().toLowerCase();
315
- if (errText.includes('not found') && errText.includes('scope')) {
316
- throw new errors_1.ScopeNotFoundError(undefined, errCtx);
317
- }
318
- if (errText.includes('not allowed on this version of cluster') ||
319
- res.statusCode === 404) {
320
- throw new errors_1.FeatureNotAvailableError(undefined, errCtx);
321
- }
322
- 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);
323
302
  }
324
- }), callback);
325
- });
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);
326
310
  }
327
311
  }
328
312
  exports.CollectionManager = CollectionManager;
@@ -36,7 +36,8 @@ export declare class Connection {
36
36
  private _connected;
37
37
  private _opened;
38
38
  private _closed;
39
- private _httpWaiters;
39
+ private _closedErr;
40
+ private _connectWaiters;
40
41
  constructor(options: ConnectionOptions);
41
42
  connect(callback: (err: Error | null) => void): void;
42
43
  selectBucket(bucketName: string, callback: (err: Error | null) => void): void;
@@ -58,6 +59,7 @@ export declare class Connection {
58
59
  httpRequest(...args: CppCbToNew<CppConnection['httpRequest']>): ReturnType<CppConnection['httpRequest']>;
59
60
  ping(...args: CppCbToNew<CppConnection['ping']>): ReturnType<CppConnection['ping']>;
60
61
  diag(...args: CppCbToNew<CppConnection['diag']>): ReturnType<CppConnection['diag']>;
62
+ private _proxyOnBootstrap;
61
63
  private _proxyToConn;
62
64
  }
63
65
  export {};
@@ -25,9 +25,10 @@ function getClientString() {
25
25
  class Connection {
26
26
  constructor(options) {
27
27
  this._closed = false;
28
+ this._closedErr = null;
28
29
  this._connected = false;
29
30
  this._opened = false;
30
- this._httpWaiters = [];
31
+ this._connectWaiters = [];
31
32
  const lcbDsnObj = connspec_1.ConnSpec.parse(options.connStr);
32
33
  // This function converts a timeout value expressed in milliseconds into
33
34
  // a string for the connection string, represented in seconds.
@@ -49,6 +50,9 @@ class Connection {
49
50
  if (options.kvConnectTimeout) {
50
51
  lcbDsnObj.options.config_total_timeout = fmtTmt(options.kvConnectTimeout);
51
52
  }
53
+ else {
54
+ lcbDsnObj.options.config_total_timeout = '30s';
55
+ }
52
56
  if (options.kvTimeout) {
53
57
  lcbDsnObj.options.timeout = fmtTmt(options.kvTimeout);
54
58
  }
@@ -82,7 +86,8 @@ class Connection {
82
86
  lcbDsnObj.options.tracing_threshold_queue_flush_interval = fmtTmt(tracerOpts.emitInterval);
83
87
  }
84
88
  if (tracerOpts.sampleSize) {
85
- lcbDsnObj.options.tracing_threshold_queue_size = tracerOpts.sampleSize.toString();
89
+ lcbDsnObj.options.tracing_threshold_queue_size =
90
+ tracerOpts.sampleSize.toString();
86
91
  }
87
92
  if (tracerOpts.kvThreshold) {
88
93
  lcbDsnObj.options.tracing_threshold_kv = fmtTmt(tracerOpts.kvThreshold);
@@ -142,13 +147,16 @@ class Connection {
142
147
  this._inst.connect((err) => {
143
148
  if (err) {
144
149
  this._closed = true;
145
- callback(bindingutilities_1.translateCppError(err));
150
+ this._closedErr = bindingutilities_1.translateCppError(err);
151
+ callback(this._closedErr);
152
+ this._connectWaiters.forEach((waitFn) => waitFn());
153
+ this._connectWaiters = [];
146
154
  return;
147
155
  }
148
156
  this._connected = true;
149
157
  callback(null);
150
- this._httpWaiters.forEach((waitFn) => waitFn(err));
151
- this._httpWaiters = [];
158
+ this._connectWaiters.forEach((waitFn) => waitFn());
159
+ this._connectWaiters = [];
152
160
  });
153
161
  }
154
162
  selectBucket(bucketName, callback) {
@@ -165,6 +173,7 @@ class Connection {
165
173
  return;
166
174
  }
167
175
  this._closed = true;
176
+ this._closedErr = new errors_1.ConnectionClosedError();
168
177
  this._inst.shutdown();
169
178
  callback(null);
170
179
  }
@@ -211,27 +220,29 @@ class Connection {
211
220
  return this._proxyToConn(this._inst, this._inst.searchQuery, ...args);
212
221
  }
213
222
  httpRequest(...args) {
214
- if (this._connected) {
215
- return this._proxyToConn(this._inst, this._inst.httpRequest, ...args);
216
- }
217
- else {
218
- this._httpWaiters.push(() => {
219
- return this._proxyToConn(this._inst, this._inst.httpRequest, ...args);
220
- });
221
- }
223
+ return this._proxyOnBootstrap(this._inst, this._inst.httpRequest, ...args);
222
224
  }
223
225
  ping(...args) {
224
- return this._proxyToConn(this._inst, this._inst.ping, ...args);
226
+ return this._proxyOnBootstrap(this._inst, this._inst.ping, ...args);
225
227
  }
226
228
  diag(...args) {
227
229
  return this._proxyToConn(this._inst, this._inst.diag, ...args);
228
230
  }
231
+ _proxyOnBootstrap(thisArg, fn, ...newArgs) {
232
+ if (this._closed || this._connected) {
233
+ return this._proxyToConn(thisArg, fn, ...newArgs);
234
+ }
235
+ else {
236
+ this._connectWaiters.push(() => {
237
+ return this._proxyToConn(thisArg, fn, ...newArgs);
238
+ });
239
+ }
240
+ }
229
241
  _proxyToConn(thisArg, fn, ...newArgs) {
230
242
  const wrappedArgs = newArgs;
231
243
  const callback = wrappedArgs.pop();
232
244
  if (this._closed) {
233
- const closeErr = new errors_1.ConnectionClosedError();
234
- return callback(closeErr);
245
+ return callback(this._closedErr);
235
246
  }
236
247
  wrappedArgs.push((err, ...cbArgs) => {
237
248
  const translatedErr = bindingutilities_1.translateCppError(err);
@@ -30,6 +30,7 @@ export * from './datastructures';
30
30
  export * from './diagnosticstypes';
31
31
  export * from './errorcontexts';
32
32
  export * from './errors';
33
+ export * from './eventingfunctionmanager';
33
34
  export * from './generaltypes';
34
35
  export * from './logging';
35
36
  export * from './metrics';
package/dist/couchbase.js CHANGED
@@ -9,15 +9,6 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
9
9
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
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
12
  var __importDefault = (this && this.__importDefault) || function (mod) {
22
13
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
14
  };
@@ -35,10 +26,8 @@ const cluster_1 = require("./cluster");
35
26
  *
36
27
  * @category Core
37
28
  */
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
- });
29
+ async function connect(connStr, options, callback) {
30
+ return cluster_1.Cluster.connect(connStr, options, callback);
42
31
  }
43
32
  exports.connect = connect;
44
33
  /**
@@ -60,6 +49,7 @@ __exportStar(require("./datastructures"), exports);
60
49
  __exportStar(require("./diagnosticstypes"), exports);
61
50
  __exportStar(require("./errorcontexts"), exports);
62
51
  __exportStar(require("./errors"), exports);
52
+ __exportStar(require("./eventingfunctionmanager"), exports);
63
53
  __exportStar(require("./generaltypes"), exports);
64
54
  __exportStar(require("./logging"), exports);
65
55
  __exportStar(require("./metrics"), exports);