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.
- package/binding.gyp +5 -0
- 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 +84 -17
- 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 -6
- package/deps/lcb/doc/Doxyfile +1 -1
- package/deps/lcb/example/minimal/query.c +9 -7
- 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 +55 -1
- package/deps/lcb/include/libcouchbase/error.h +6 -1
- 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 +353 -349
- package/deps/lcb/packaging/deb/control +1 -1
- package/deps/lcb/src/analytics/analytics_handle.cc +7 -5
- package/deps/lcb/src/analytics/analytics_handle.hh +28 -0
- package/deps/lcb/src/capi/cmd_counter.hh +18 -0
- package/deps/lcb/src/capi/cmd_exists.hh +18 -0
- package/deps/lcb/src/capi/cmd_get.hh +17 -0
- package/deps/lcb/src/capi/cmd_get_replica.hh +20 -1
- package/deps/lcb/src/capi/cmd_query.cc +13 -0
- package/deps/lcb/src/capi/cmd_query.hh +22 -14
- package/deps/lcb/src/capi/cmd_remove.hh +18 -0
- package/deps/lcb/src/capi/cmd_search.hh +6 -0
- package/deps/lcb/src/capi/cmd_store.hh +28 -21
- package/deps/lcb/src/capi/cmd_subdoc.hh +30 -0
- package/deps/lcb/src/capi/cmd_touch.hh +18 -0
- package/deps/lcb/src/capi/cmd_unlock.hh +18 -0
- package/deps/lcb/src/capi/cmd_view.hh +6 -0
- package/deps/lcb/src/capi/collection_qualifier.hh +6 -8
- package/deps/lcb/src/cntl.cc +42 -8
- 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/internal.h +2 -1
- package/deps/lcb/src/lcbio/ctx.cc +4 -2
- package/deps/lcb/src/mcserver/mcserver.cc +8 -5
- package/deps/lcb/src/mcserver/negotiate.cc +42 -17
- package/deps/lcb/src/n1ql/ixmgmt.cc +1 -2
- package/deps/lcb/src/n1ql/n1ql.cc +5 -1
- package/deps/lcb/src/n1ql/query_handle.cc +80 -44
- package/deps/lcb/src/n1ql/query_handle.hh +41 -3
- package/deps/lcb/src/operations/counter.cc +13 -1
- package/deps/lcb/src/operations/exists.cc +14 -2
- package/deps/lcb/src/operations/get.cc +14 -2
- package/deps/lcb/src/operations/get_replica.cc +18 -6
- package/deps/lcb/src/operations/observe.cc +1 -1
- package/deps/lcb/src/operations/remove.cc +13 -1
- package/deps/lcb/src/operations/store.cc +13 -1
- package/deps/lcb/src/operations/subdoc.cc +13 -2
- package/deps/lcb/src/operations/touch.cc +14 -2
- package/deps/lcb/src/operations/unlock.cc +14 -2
- package/deps/lcb/src/search/search_handle.cc +26 -8
- package/deps/lcb/src/search/search_handle.hh +29 -0
- package/deps/lcb/src/ssl/ssl_common.c +7 -8
- package/deps/lcb/src/tracing/span.cc +43 -10
- package/deps/lcb/src/tracing/tracing-internal.h +105 -93
- package/deps/lcb/src/utilities.cc +21 -0
- package/deps/lcb/src/utilities.h +3 -0
- 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/iotests/mock-environment.cc +25 -1
- package/deps/lcb/tests/iotests/mock-environment.h +49 -1
- package/deps/lcb/tests/iotests/mock-unit-test.cc +96 -5
- package/deps/lcb/tests/iotests/mock-unit-test.h +32 -0
- package/deps/lcb/tests/iotests/serverparams.h +7 -2
- 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 +14 -4
- package/deps/lcb/tests/iotests/t_n1ql.cc +17 -1
- package/deps/lcb/tests/iotests/t_ratelimit.cc +729 -0
- package/deps/lcb/tests/iotests/t_views.cc +1 -0
- package/deps/lcb/tests/iotests/testutil.cc +342 -0
- package/deps/lcb/tests/iotests/testutil.h +164 -0
- package/deps/lcb/tests/mocksupport/procutil.c +32 -28
- package/deps/lcb/tests/mocksupport/server.c +0 -1
- package/deps/lcb/tools/cbc.cc +7 -0
- package/dist/analyticsexecutor.js +2 -2
- package/dist/analyticsindexmanager.js +512 -524
- package/dist/binarycollection.d.ts +17 -0
- package/dist/binding.d.ts +2 -0
- package/dist/binding.js +1 -1
- package/dist/bindingutilities.js +9 -1
- package/dist/bucketmanager.d.ts +32 -23
- package/dist/bucketmanager.js +197 -189
- package/dist/cluster.js +37 -36
- package/dist/collection.js +17 -23
- package/dist/collectionmanager.js +181 -200
- package/dist/connection.js +6 -3
- package/dist/connspec.js +5 -1
- package/dist/couchbase.js +7 -14
- package/dist/datastructures.js +239 -310
- package/dist/diagnosticsexecutor.js +70 -85
- package/dist/errors.d.ts +18 -0
- package/dist/errors.js +26 -2
- package/dist/eventingfunctionmanager.js +267 -294
- package/dist/httpexecutor.js +31 -38
- package/dist/logging.js +1 -1
- package/dist/queryexecutor.js +3 -3
- package/dist/queryindexmanager.js +236 -263
- package/dist/scope.js +8 -2
- 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 +250 -263
- package/dist/utilities.d.ts +3 -2
- package/dist/utilities.js +16 -4
- package/dist/viewexecutor.js +1 -1
- package/dist/viewindexmanager.js +131 -150
- package/package.json +1 -1
- package/src/connection.cpp +2 -0
- package/src/constants.cpp +2 -0
- package/src/instance.cpp +8 -1
- package/src/instance.h +1 -0
- package/src/uv-plugin-all.cpp +1 -0
- package/dist/cas.d.ts +0 -0
- package/dist/cas.js +0 -1
package/dist/collection.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
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(() =>
|
|
149
|
-
const res =
|
|
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
|
-
}
|
|
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(() =>
|
|
222
|
-
const replicas =
|
|
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
|
-
}
|
|
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[
|
|
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[
|
|
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
|
-
|
|
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: (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
|
-
|
|
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
|
-
|
|
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 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
|
-
|
|
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
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
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
|
-
|
|
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
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
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
|
-
|
|
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;
|
package/dist/connection.js
CHANGED
|
@@ -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.
|
|
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.
|
|
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
|
|
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
|
/**
|