couchbase 3.2.0 → 3.2.4
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +24 -18
- package/binding.gyp +88 -85
- package/deps/lcb/CMakeLists.txt +1 -1
- package/deps/lcb/CONTRIBUTING.md +1 -1
- package/deps/lcb/README.markdown +2 -2
- package/deps/lcb/RELEASE_NOTES.markdown +99 -14
- package/deps/lcb/cmake/Modules/GetVersionInfo.cmake +1 -1
- package/deps/lcb/contrib/cbsasl/src/scram-sha/scram_utils.cc +22 -26
- package/deps/lcb/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp +20 -7
- package/deps/lcb/doc/Doxyfile +1 -1
- package/deps/lcb/example/CMakeLists.txt +4 -4
- package/deps/lcb/example/libuvdirect/main.c +39 -12
- package/deps/lcb/example/minimal/durability.cc +149 -0
- package/deps/lcb/example/minimal/query.c +11 -9
- package/deps/lcb/gyp_config/common/libcouchbase/configuration.h +3 -3
- package/deps/lcb/gyp_config/linux/arm64/config.h +243 -0
- package/deps/lcb/include/libcouchbase/couchbase.h +80 -5
- package/deps/lcb/include/libcouchbase/error.h +2 -0
- package/deps/lcb/include/libcouchbase/ixmgmt.h +15 -10
- package/deps/lcb/include/libcouchbase/tracing.h +2 -2
- package/deps/lcb/include/memcached/protocol_binary.h +21 -0
- package/deps/lcb/libcouchbase.gyp +347 -349
- package/deps/lcb/packaging/deb/control +1 -1
- package/deps/lcb/src/analytics/analytics_handle.cc +13 -5
- package/deps/lcb/src/analytics/analytics_handle.hh +29 -0
- package/deps/lcb/src/bootstrap.cc +6 -3
- package/deps/lcb/src/capi/cmd_analytics.cc +12 -1
- package/deps/lcb/src/capi/cmd_analytics.hh +30 -0
- package/deps/lcb/src/capi/cmd_counter.hh +23 -0
- package/deps/lcb/src/capi/cmd_exists.hh +24 -1
- package/deps/lcb/src/capi/cmd_get.hh +22 -0
- package/deps/lcb/src/capi/cmd_get_replica.hh +23 -0
- package/deps/lcb/src/capi/cmd_http.hh +7 -0
- package/deps/lcb/src/capi/cmd_query.cc +11 -1
- package/deps/lcb/src/capi/cmd_query.hh +31 -0
- package/deps/lcb/src/capi/cmd_remove.hh +23 -0
- package/deps/lcb/src/capi/cmd_search.cc +6 -0
- package/deps/lcb/src/capi/cmd_search.hh +23 -0
- package/deps/lcb/src/capi/cmd_store.hh +33 -21
- package/deps/lcb/src/capi/cmd_subdoc.hh +35 -0
- package/deps/lcb/src/capi/cmd_touch.hh +23 -0
- package/deps/lcb/src/capi/cmd_unlock.hh +23 -0
- package/deps/lcb/src/capi/cmd_view.hh +6 -0
- package/deps/lcb/src/capi/collection_qualifier.hh +2 -2
- package/deps/lcb/src/cntl.cc +45 -11
- package/deps/lcb/src/crypto.cc +2 -2
- package/deps/lcb/src/dns-srv.cc +5 -3
- package/deps/lcb/src/errmap.cc +5 -9
- package/deps/lcb/src/errmap.h +7 -3
- package/deps/lcb/src/handler.cc +24 -18
- package/deps/lcb/src/hostlist.h +2 -2
- package/deps/lcb/src/http/http-priv.h +2 -2
- package/deps/lcb/src/http/http.cc +5 -2
- package/deps/lcb/src/instance.cc +20 -11
- package/deps/lcb/src/internal.h +9 -0
- package/deps/lcb/src/lcbio/connect.cc +14 -2
- package/deps/lcb/src/lcbio/connect.h +2 -2
- package/deps/lcb/src/lcbio/ctx.cc +4 -2
- package/deps/lcb/src/lcbio/ioutils.cc +9 -10
- package/deps/lcb/src/lcbio/manager.cc +1 -1
- package/deps/lcb/src/mcserver/mcserver.cc +9 -6
- package/deps/lcb/src/mcserver/negotiate.cc +39 -17
- package/deps/lcb/src/n1ql/ixmgmt.cc +1 -2
- package/deps/lcb/src/n1ql/query_handle.cc +41 -19
- package/deps/lcb/src/n1ql/query_handle.hh +28 -1
- package/deps/lcb/src/operations/counter.cc +18 -5
- package/deps/lcb/src/operations/exists.cc +25 -4
- package/deps/lcb/src/operations/get.cc +39 -19
- package/deps/lcb/src/operations/get_replica.cc +28 -8
- package/deps/lcb/src/operations/observe.cc +1 -1
- package/deps/lcb/src/operations/ping.cc +8 -8
- package/deps/lcb/src/operations/pktfwd.cc +2 -1
- package/deps/lcb/src/operations/remove.cc +39 -22
- package/deps/lcb/src/operations/store.cc +18 -5
- package/deps/lcb/src/operations/subdoc.cc +18 -6
- package/deps/lcb/src/operations/touch.cc +34 -16
- package/deps/lcb/src/operations/unlock.cc +24 -5
- package/deps/lcb/src/packetutils.h +3 -2
- package/deps/lcb/src/retryq.cc +24 -5
- package/deps/lcb/src/search/search.cc +1 -0
- package/deps/lcb/src/search/search_handle.cc +30 -8
- package/deps/lcb/src/search/search_handle.hh +29 -0
- package/deps/lcb/src/settings.cc +1 -1
- package/deps/lcb/src/ssl/ssl_common.c +6 -7
- package/deps/lcb/src/tracing/span.cc +47 -14
- package/deps/lcb/src/tracing/tracer.cc +11 -2
- package/deps/lcb/src/tracing/tracing-internal.h +105 -93
- package/deps/lcb/src/utilities.cc +43 -0
- package/deps/lcb/src/utilities.h +53 -0
- package/deps/lcb/src/vbucket/vbucket.c +34 -33
- package/deps/lcb/src/views/view_handle.cc +13 -5
- package/deps/lcb/src/views/view_handle.hh +29 -0
- package/deps/lcb/tests/CMakeLists.txt +21 -0
- package/deps/lcb/tests/basic/t_ctlcodes.cc +24 -3
- package/deps/lcb/tests/basic/t_jsparse.cc +8 -0
- package/deps/lcb/tests/basic/t_n1qlstrings.cc +73 -0
- package/deps/lcb/tests/iotests/mock-environment.cc +30 -1
- package/deps/lcb/tests/iotests/mock-environment.h +49 -0
- package/deps/lcb/tests/iotests/mock-unit-test.cc +104 -6
- package/deps/lcb/tests/iotests/mock-unit-test.h +34 -0
- package/deps/lcb/tests/iotests/t_collections.cc +1 -1
- package/deps/lcb/tests/iotests/t_confmon.cc +4 -2
- package/deps/lcb/tests/iotests/t_get.cc +109 -7
- package/deps/lcb/tests/iotests/t_http.cc +9 -4
- package/deps/lcb/tests/iotests/t_lock.cc +18 -0
- package/deps/lcb/tests/iotests/t_mutate.cc +157 -63
- package/deps/lcb/tests/iotests/t_n1ql.cc +330 -33
- package/deps/lcb/tests/iotests/t_views.cc +1 -0
- package/deps/lcb/tests/iotests/testutil.cc +168 -0
- package/deps/lcb/tests/iotests/testutil.h +116 -0
- package/deps/lcb/tests/mocksupport/procutil.c +32 -28
- package/deps/lcb/tests/mocksupport/server.c +0 -1
- package/deps/lcb/tests/mocksupport/timeout.c +2 -2
- package/deps/lcb/tools/cbc.cc +7 -0
- package/dist/analyticsindexmanager.js +512 -524
- package/dist/binding.d.ts +3 -0
- package/dist/bindingutilities.js +4 -0
- package/dist/bucket.js +1 -1
- package/dist/bucketmanager.d.ts +31 -1
- package/dist/bucketmanager.js +194 -186
- package/dist/cluster.d.ts +7 -0
- package/dist/cluster.js +48 -38
- package/dist/collection.js +11 -17
- package/dist/collectionmanager.js +181 -197
- package/dist/connection.d.ts +3 -1
- package/dist/connection.js +27 -16
- package/dist/couchbase.d.ts +1 -0
- package/dist/couchbase.js +3 -13
- package/dist/datastructures.js +239 -310
- package/dist/diagnosticsexecutor.js +70 -85
- package/dist/errors.d.ts +70 -0
- package/dist/errors.js +96 -2
- package/dist/eventingfunctionmanager.d.ts +804 -0
- package/dist/eventingfunctionmanager.js +993 -0
- package/dist/httpexecutor.d.ts +2 -1
- package/dist/httpexecutor.js +30 -37
- package/dist/queryindexmanager.js +240 -266
- package/dist/scope.js +10 -4
- package/dist/sdspecs.d.ts +1 -1
- package/dist/searchexecutor.js +3 -0
- package/dist/searchindexmanager.js +240 -271
- package/dist/searchquery.d.ts +17 -0
- package/dist/searchquery.js +22 -1
- package/dist/searchtypes.d.ts +7 -2
- package/dist/searchtypes.js +2 -2
- package/dist/usermanager.js +251 -264
- package/dist/utilities.d.ts +2 -0
- package/dist/utilities.js +7 -2
- package/dist/viewexecutor.js +1 -1
- package/dist/viewindexmanager.js +131 -150
- package/package.json +1 -1
- package/src/addondata.cpp +58 -0
- package/src/addondata.h +40 -0
- package/src/binding.cpp +3 -1
- package/src/cas.h +2 -2
- package/src/connection.cpp +25 -178
- package/src/connection.h +8 -65
- package/src/connection_ops.cpp +57 -34
- package/src/constants.cpp +3 -0
- package/src/instance.cpp +235 -0
- package/src/instance.h +102 -0
- package/src/{connection_callbacks.cpp → instance_callbacks.cpp} +34 -34
- package/src/logger.cpp +11 -1
- package/src/logger.h +3 -0
- package/src/metrics.cpp +10 -0
- package/src/metrics.h +3 -0
- package/src/mutationtoken.h +2 -2
- package/src/opbuilder.h +13 -15
- package/src/respreader.cpp +1 -0
- package/src/respreader.h +6 -4
- package/src/tracespan.h +11 -11
- package/src/tracing.cpp +11 -0
- package/src/tracing.h +3 -0
- package/src/valueparser.h +5 -0
- 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
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
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
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
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
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
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
|
-
|
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
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
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
|
-
|
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
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
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
|
-
|
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
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
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
|
-
|
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;
|
package/dist/connection.d.ts
CHANGED
@@ -36,7 +36,8 @@ export declare class Connection {
|
|
36
36
|
private _connected;
|
37
37
|
private _opened;
|
38
38
|
private _closed;
|
39
|
-
private
|
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 {};
|
package/dist/connection.js
CHANGED
@@ -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.
|
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 =
|
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
|
-
|
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.
|
151
|
-
this.
|
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
|
-
|
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.
|
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
|
-
|
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);
|
package/dist/couchbase.d.ts
CHANGED
@@ -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
|
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);
|