couchbase 3.2.0 → 3.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
package/dist/binding.d.ts
CHANGED
|
@@ -184,6 +184,8 @@ export interface CppBinding {
|
|
|
184
184
|
LCB_ERR_SCOPE_NOT_FOUND: CppErrType;
|
|
185
185
|
LCB_ERR_INDEX_NOT_FOUND: CppErrType;
|
|
186
186
|
LCB_ERR_INDEX_EXISTS: CppErrType;
|
|
187
|
+
LCB_ERR_RATE_LIMITED: CppErrType;
|
|
188
|
+
LCB_ERR_QUOTA_LIMITED: CppErrType;
|
|
187
189
|
LCB_ERR_DOCUMENT_NOT_FOUND: CppErrType;
|
|
188
190
|
LCB_ERR_DOCUMENT_UNRETRIEVABLE: CppErrType;
|
|
189
191
|
LCB_ERR_DOCUMENT_LOCKED: CppErrType;
|
|
@@ -298,6 +300,7 @@ export interface CppBinding {
|
|
|
298
300
|
LCB_HTTP_TYPE_QUERY: CppHttpType;
|
|
299
301
|
LCB_HTTP_TYPE_SEARCH: CppHttpType;
|
|
300
302
|
LCB_HTTP_TYPE_ANALYTICS: CppHttpType;
|
|
303
|
+
LCB_HTTP_TYPE_EVENTING: CppHttpType;
|
|
301
304
|
LCB_HTTP_METHOD_GET: CppHttpMethod;
|
|
302
305
|
LCB_HTTP_METHOD_POST: CppHttpMethod;
|
|
303
306
|
LCB_HTTP_METHOD_PUT: CppHttpMethod;
|
package/dist/bindingutilities.js
CHANGED
|
@@ -214,6 +214,10 @@ function translateCppError(err) {
|
|
|
214
214
|
return new errs.IndexNotFoundError(codeErr, context);
|
|
215
215
|
case binding_1.default.LCB_ERR_INDEX_EXISTS:
|
|
216
216
|
return new errs.IndexExistsError(codeErr, context);
|
|
217
|
+
case binding_1.default.LCB_ERR_RATE_LIMITED:
|
|
218
|
+
return new errs.RateLimitedError(codeErr, context);
|
|
219
|
+
case binding_1.default.LCB_ERR_QUOTA_LIMITED:
|
|
220
|
+
return new errs.QuotaLimitedError(codeErr, context);
|
|
217
221
|
/* KeyValue Error Definitions */
|
|
218
222
|
case binding_1.default.LCB_ERR_DOCUMENT_NOT_FOUND:
|
|
219
223
|
return new errs.DocumentNotFoundError(codeErr, context);
|
package/dist/bucket.js
CHANGED
package/dist/bucketmanager.d.ts
CHANGED
|
@@ -18,7 +18,14 @@ export declare enum ConflictResolutionType {
|
|
|
18
18
|
/**
|
|
19
19
|
* Indicates that the seqno of the document should be used for conflict resolution.
|
|
20
20
|
*/
|
|
21
|
-
SequenceNumber = "seqno"
|
|
21
|
+
SequenceNumber = "seqno",
|
|
22
|
+
/**
|
|
23
|
+
* Indicates that custom conflict resolution should be used.
|
|
24
|
+
*
|
|
25
|
+
* @experimental This mode is only available in Couchbase Server 7.1 with the
|
|
26
|
+
* "developer-preview" mode enabled.
|
|
27
|
+
*/
|
|
28
|
+
Custom = "custom"
|
|
22
29
|
}
|
|
23
30
|
/**
|
|
24
31
|
* Represents the type of a bucket.
|
|
@@ -39,6 +46,21 @@ export declare enum BucketType {
|
|
|
39
46
|
*/
|
|
40
47
|
Ephemeral = "ephemeral"
|
|
41
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Represents the storage backend to use for a bucket.
|
|
51
|
+
*
|
|
52
|
+
* @category Management
|
|
53
|
+
*/
|
|
54
|
+
export declare enum StorageBackend {
|
|
55
|
+
/**
|
|
56
|
+
* Indicates the bucket should use the Couchstore storage engine.
|
|
57
|
+
*/
|
|
58
|
+
Couchstore = "couchstore",
|
|
59
|
+
/**
|
|
60
|
+
* Indicates the bucket should use the Magma storage engine.
|
|
61
|
+
*/
|
|
62
|
+
Magma = "magma"
|
|
63
|
+
}
|
|
42
64
|
/**
|
|
43
65
|
* Represents the eviction policy that should be used for a bucket.
|
|
44
66
|
*
|
|
@@ -117,6 +139,10 @@ export interface IBucketSettings {
|
|
|
117
139
|
* Specifies the type of bucket that should be used.
|
|
118
140
|
*/
|
|
119
141
|
bucketType: BucketType | string;
|
|
142
|
+
/**
|
|
143
|
+
* Specifies the storage backend to use for the bucket.
|
|
144
|
+
*/
|
|
145
|
+
storageBackend: StorageBackend | string;
|
|
120
146
|
/**
|
|
121
147
|
* Specifies the ejection method that should be used.
|
|
122
148
|
*/
|
|
@@ -189,6 +215,10 @@ export declare class BucketSettings implements IBucketSettings {
|
|
|
189
215
|
* Specifies the type of bucket that should be used.
|
|
190
216
|
*/
|
|
191
217
|
bucketType: BucketType;
|
|
218
|
+
/**
|
|
219
|
+
* Specifies the storage backend to use for the bucket.
|
|
220
|
+
*/
|
|
221
|
+
storageBackend: StorageBackend | string;
|
|
192
222
|
/**
|
|
193
223
|
* Specifies the ejection method that should be used.
|
|
194
224
|
*/
|
package/dist/bucketmanager.js
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
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
|
-
exports.BucketManager = exports.BucketSettings = exports.CompressionMode = exports.EvictionPolicy = exports.BucketType = exports.ConflictResolutionType = void 0;
|
|
3
|
+
exports.BucketManager = exports.BucketSettings = exports.CompressionMode = exports.EvictionPolicy = exports.StorageBackend = exports.BucketType = exports.ConflictResolutionType = void 0;
|
|
13
4
|
const errors_1 = require("./errors");
|
|
14
5
|
const httpexecutor_1 = require("./httpexecutor");
|
|
15
6
|
const utilities_1 = require("./utilities");
|
|
@@ -31,6 +22,13 @@ var ConflictResolutionType;
|
|
|
31
22
|
* Indicates that the seqno of the document should be used for conflict resolution.
|
|
32
23
|
*/
|
|
33
24
|
ConflictResolutionType["SequenceNumber"] = "seqno";
|
|
25
|
+
/**
|
|
26
|
+
* Indicates that custom conflict resolution should be used.
|
|
27
|
+
*
|
|
28
|
+
* @experimental This mode is only available in Couchbase Server 7.1 with the
|
|
29
|
+
* "developer-preview" mode enabled.
|
|
30
|
+
*/
|
|
31
|
+
ConflictResolutionType["Custom"] = "custom";
|
|
34
32
|
})(ConflictResolutionType = exports.ConflictResolutionType || (exports.ConflictResolutionType = {}));
|
|
35
33
|
/**
|
|
36
34
|
* Represents the type of a bucket.
|
|
@@ -52,6 +50,22 @@ var BucketType;
|
|
|
52
50
|
*/
|
|
53
51
|
BucketType["Ephemeral"] = "ephemeral";
|
|
54
52
|
})(BucketType = exports.BucketType || (exports.BucketType = {}));
|
|
53
|
+
/**
|
|
54
|
+
* Represents the storage backend to use for a bucket.
|
|
55
|
+
*
|
|
56
|
+
* @category Management
|
|
57
|
+
*/
|
|
58
|
+
var StorageBackend;
|
|
59
|
+
(function (StorageBackend) {
|
|
60
|
+
/**
|
|
61
|
+
* Indicates the bucket should use the Couchstore storage engine.
|
|
62
|
+
*/
|
|
63
|
+
StorageBackend["Couchstore"] = "couchstore";
|
|
64
|
+
/**
|
|
65
|
+
* Indicates the bucket should use the Magma storage engine.
|
|
66
|
+
*/
|
|
67
|
+
StorageBackend["Magma"] = "magma";
|
|
68
|
+
})(StorageBackend = exports.StorageBackend || (exports.StorageBackend = {}));
|
|
55
69
|
/**
|
|
56
70
|
* Represents the eviction policy that should be used for a bucket.
|
|
57
71
|
*
|
|
@@ -115,6 +129,7 @@ class BucketSettings {
|
|
|
115
129
|
this.numReplicas = data.numReplicas;
|
|
116
130
|
this.replicaIndexes = data.replicaIndexes;
|
|
117
131
|
this.bucketType = data.bucketType;
|
|
132
|
+
this.storageBackend = data.storageBackend;
|
|
118
133
|
this.evictionPolicy = data.evictionPolicy;
|
|
119
134
|
this.maxExpiry = data.maxExpiry;
|
|
120
135
|
this.compressionMode = data.compressionMode;
|
|
@@ -162,6 +177,7 @@ class BucketSettings {
|
|
|
162
177
|
replicaNumber: data.numReplicas,
|
|
163
178
|
replicaIndexes: data.replicaIndexes,
|
|
164
179
|
bucketType: data.bucketType,
|
|
180
|
+
storageBackend: data.storageBackend,
|
|
165
181
|
evictionPolicy: data.evictionPolicy,
|
|
166
182
|
maxTTL: data.maxTTL || data.maxExpiry,
|
|
167
183
|
compressionMode: data.compressionMode,
|
|
@@ -180,6 +196,7 @@ class BucketSettings {
|
|
|
180
196
|
numReplicas: data.replicaNumber,
|
|
181
197
|
replicaIndexes: data.replicaIndexes,
|
|
182
198
|
bucketType: data.bucketType,
|
|
199
|
+
storageBackend: data.storageBackend,
|
|
183
200
|
evictionPolicy: data.evictionPolicy,
|
|
184
201
|
maxExpiry: data.maxTTL,
|
|
185
202
|
compressionMode: data.compressionMode,
|
|
@@ -209,7 +226,10 @@ class CreateBucketSettings extends BucketSettings {
|
|
|
209
226
|
* @internal
|
|
210
227
|
*/
|
|
211
228
|
static _toNsData(data) {
|
|
212
|
-
return
|
|
229
|
+
return {
|
|
230
|
+
...BucketSettings._toNsData(data),
|
|
231
|
+
conflictResolutionType: data.conflictResolutionType,
|
|
232
|
+
};
|
|
213
233
|
}
|
|
214
234
|
}
|
|
215
235
|
/**
|
|
@@ -235,38 +255,36 @@ class BucketManager {
|
|
|
235
255
|
* @param options Optional parameters for this operation.
|
|
236
256
|
* @param callback A node-style callback to be invoked after execution.
|
|
237
257
|
*/
|
|
238
|
-
createBucket(settings, options, callback) {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
throw new errors_1.BucketExistsError(undefined, errCtx);
|
|
265
|
-
}
|
|
266
|
-
throw new errors_1.CouchbaseError('failed to create bucket', undefined, errCtx);
|
|
258
|
+
async createBucket(settings, options, callback) {
|
|
259
|
+
if (options instanceof Function) {
|
|
260
|
+
callback = arguments[1];
|
|
261
|
+
options = undefined;
|
|
262
|
+
}
|
|
263
|
+
if (!options) {
|
|
264
|
+
options = {};
|
|
265
|
+
}
|
|
266
|
+
const parentSpan = options.parentSpan;
|
|
267
|
+
const timeout = options.timeout;
|
|
268
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
269
|
+
const bucketData = CreateBucketSettings._toNsData(settings);
|
|
270
|
+
const res = await this._http.request({
|
|
271
|
+
type: httpexecutor_1.HttpServiceType.Management,
|
|
272
|
+
method: httpexecutor_1.HttpMethod.Post,
|
|
273
|
+
path: `/pools/default/buckets`,
|
|
274
|
+
contentType: 'application/x-www-form-urlencoded',
|
|
275
|
+
body: utilities_1.cbQsStringify(bucketData),
|
|
276
|
+
parentSpan: parentSpan,
|
|
277
|
+
timeout: timeout,
|
|
278
|
+
});
|
|
279
|
+
if (res.statusCode !== 202) {
|
|
280
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
|
281
|
+
const errText = res.body.toString().toLowerCase();
|
|
282
|
+
if (errText.includes('already exists')) {
|
|
283
|
+
throw new errors_1.BucketExistsError(undefined, errCtx);
|
|
267
284
|
}
|
|
268
|
-
|
|
269
|
-
|
|
285
|
+
throw new errors_1.CouchbaseError('failed to create bucket', undefined, errCtx);
|
|
286
|
+
}
|
|
287
|
+
}, callback);
|
|
270
288
|
}
|
|
271
289
|
/**
|
|
272
290
|
* Updates the settings for an existing bucket.
|
|
@@ -275,38 +293,36 @@ class BucketManager {
|
|
|
275
293
|
* @param options Optional parameters for this operation.
|
|
276
294
|
* @param callback A node-style callback to be invoked after execution.
|
|
277
295
|
*/
|
|
278
|
-
updateBucket(settings, options, callback) {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
throw new errors_1.BucketNotFoundError(undefined, errCtx);
|
|
305
|
-
}
|
|
306
|
-
throw new errors_1.CouchbaseError('failed to update bucket', undefined, errCtx);
|
|
296
|
+
async updateBucket(settings, options, callback) {
|
|
297
|
+
if (options instanceof Function) {
|
|
298
|
+
callback = arguments[1];
|
|
299
|
+
options = undefined;
|
|
300
|
+
}
|
|
301
|
+
if (!options) {
|
|
302
|
+
options = {};
|
|
303
|
+
}
|
|
304
|
+
const parentSpan = options.parentSpan;
|
|
305
|
+
const timeout = options.timeout;
|
|
306
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
307
|
+
const bucketData = BucketSettings._toNsData(settings);
|
|
308
|
+
const res = await this._http.request({
|
|
309
|
+
type: httpexecutor_1.HttpServiceType.Management,
|
|
310
|
+
method: httpexecutor_1.HttpMethod.Post,
|
|
311
|
+
path: `/pools/default/buckets/${settings.name}`,
|
|
312
|
+
contentType: 'application/x-www-form-urlencoded',
|
|
313
|
+
body: utilities_1.cbQsStringify(bucketData),
|
|
314
|
+
parentSpan: parentSpan,
|
|
315
|
+
timeout: timeout,
|
|
316
|
+
});
|
|
317
|
+
if (res.statusCode !== 200) {
|
|
318
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
|
319
|
+
const errText = res.body.toString().toLowerCase();
|
|
320
|
+
if (errText.includes('not found')) {
|
|
321
|
+
throw new errors_1.BucketNotFoundError(undefined, errCtx);
|
|
307
322
|
}
|
|
308
|
-
|
|
309
|
-
|
|
323
|
+
throw new errors_1.CouchbaseError('failed to update bucket', undefined, errCtx);
|
|
324
|
+
}
|
|
325
|
+
}, callback);
|
|
310
326
|
}
|
|
311
327
|
/**
|
|
312
328
|
* Drops an existing bucket.
|
|
@@ -315,35 +331,33 @@ class BucketManager {
|
|
|
315
331
|
* @param options Optional parameters for this operation.
|
|
316
332
|
* @param callback A node-style callback to be invoked after execution.
|
|
317
333
|
*/
|
|
318
|
-
dropBucket(bucketName, options, callback) {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
throw new errors_1.BucketNotFoundError(undefined, errCtx);
|
|
342
|
-
}
|
|
343
|
-
throw new errors_1.CouchbaseError('failed to drop bucket', undefined, errCtx);
|
|
334
|
+
async dropBucket(bucketName, options, callback) {
|
|
335
|
+
if (options instanceof Function) {
|
|
336
|
+
callback = arguments[1];
|
|
337
|
+
options = undefined;
|
|
338
|
+
}
|
|
339
|
+
if (!options) {
|
|
340
|
+
options = {};
|
|
341
|
+
}
|
|
342
|
+
const parentSpan = options.parentSpan;
|
|
343
|
+
const timeout = options.timeout;
|
|
344
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
345
|
+
const res = await this._http.request({
|
|
346
|
+
type: httpexecutor_1.HttpServiceType.Management,
|
|
347
|
+
method: httpexecutor_1.HttpMethod.Delete,
|
|
348
|
+
path: `/pools/default/buckets/${bucketName}`,
|
|
349
|
+
parentSpan: parentSpan,
|
|
350
|
+
timeout: timeout,
|
|
351
|
+
});
|
|
352
|
+
if (res.statusCode !== 200) {
|
|
353
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
|
354
|
+
const errText = res.body.toString().toLowerCase();
|
|
355
|
+
if (errText.includes('not found')) {
|
|
356
|
+
throw new errors_1.BucketNotFoundError(undefined, errCtx);
|
|
344
357
|
}
|
|
345
|
-
|
|
346
|
-
|
|
358
|
+
throw new errors_1.CouchbaseError('failed to drop bucket', undefined, errCtx);
|
|
359
|
+
}
|
|
360
|
+
}, callback);
|
|
347
361
|
}
|
|
348
362
|
/**
|
|
349
363
|
* Fetches the settings in use for a specified bucket.
|
|
@@ -352,37 +366,35 @@ class BucketManager {
|
|
|
352
366
|
* @param options Optional parameters for this operation.
|
|
353
367
|
* @param callback A node-style callback to be invoked after execution.
|
|
354
368
|
*/
|
|
355
|
-
getBucket(bucketName, options, callback) {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
throw new errors_1.BucketNotFoundError(undefined, errCtx);
|
|
379
|
-
}
|
|
380
|
-
throw new errors_1.CouchbaseError('failed to get bucket', undefined, errCtx);
|
|
369
|
+
async getBucket(bucketName, options, callback) {
|
|
370
|
+
if (options instanceof Function) {
|
|
371
|
+
callback = arguments[1];
|
|
372
|
+
options = undefined;
|
|
373
|
+
}
|
|
374
|
+
if (!options) {
|
|
375
|
+
options = {};
|
|
376
|
+
}
|
|
377
|
+
const parentSpan = options.parentSpan;
|
|
378
|
+
const timeout = options.timeout;
|
|
379
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
380
|
+
const res = await this._http.request({
|
|
381
|
+
type: httpexecutor_1.HttpServiceType.Management,
|
|
382
|
+
method: httpexecutor_1.HttpMethod.Get,
|
|
383
|
+
path: `/pools/default/buckets/${bucketName}`,
|
|
384
|
+
parentSpan: parentSpan,
|
|
385
|
+
timeout: timeout,
|
|
386
|
+
});
|
|
387
|
+
if (res.statusCode !== 200) {
|
|
388
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
|
389
|
+
const errText = res.body.toString().toLowerCase();
|
|
390
|
+
if (errText.includes('not found')) {
|
|
391
|
+
throw new errors_1.BucketNotFoundError(undefined, errCtx);
|
|
381
392
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
393
|
+
throw new errors_1.CouchbaseError('failed to get bucket', undefined, errCtx);
|
|
394
|
+
}
|
|
395
|
+
const bucketData = JSON.parse(res.body.toString());
|
|
396
|
+
return BucketSettings._fromNsData(bucketData);
|
|
397
|
+
}, callback);
|
|
386
398
|
}
|
|
387
399
|
/**
|
|
388
400
|
* Returns a list of existing buckets in the cluster.
|
|
@@ -390,34 +402,32 @@ class BucketManager {
|
|
|
390
402
|
* @param options Optional parameters for this operation.
|
|
391
403
|
* @param callback A node-style callback to be invoked after execution.
|
|
392
404
|
*/
|
|
393
|
-
getAllBuckets(options, callback) {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
405
|
+
async getAllBuckets(options, callback) {
|
|
406
|
+
if (options instanceof Function) {
|
|
407
|
+
callback = arguments[0];
|
|
408
|
+
options = undefined;
|
|
409
|
+
}
|
|
410
|
+
if (!options) {
|
|
411
|
+
options = {};
|
|
412
|
+
}
|
|
413
|
+
const parentSpan = options.parentSpan;
|
|
414
|
+
const timeout = options.timeout;
|
|
415
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
416
|
+
const res = await this._http.request({
|
|
417
|
+
type: httpexecutor_1.HttpServiceType.Management,
|
|
418
|
+
method: httpexecutor_1.HttpMethod.Get,
|
|
419
|
+
path: `/pools/default/buckets`,
|
|
420
|
+
parentSpan: parentSpan,
|
|
421
|
+
timeout: timeout,
|
|
422
|
+
});
|
|
423
|
+
if (res.statusCode !== 200) {
|
|
424
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
|
425
|
+
throw new errors_1.CouchbaseError('failed to get buckets', undefined, errCtx);
|
|
401
426
|
}
|
|
402
|
-
const
|
|
403
|
-
const
|
|
404
|
-
return
|
|
405
|
-
|
|
406
|
-
type: httpexecutor_1.HttpServiceType.Management,
|
|
407
|
-
method: httpexecutor_1.HttpMethod.Get,
|
|
408
|
-
path: `/pools/default/buckets`,
|
|
409
|
-
parentSpan: parentSpan,
|
|
410
|
-
timeout: timeout,
|
|
411
|
-
});
|
|
412
|
-
if (res.statusCode !== 200) {
|
|
413
|
-
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
|
414
|
-
throw new errors_1.CouchbaseError('failed to get buckets', undefined, errCtx);
|
|
415
|
-
}
|
|
416
|
-
const bucketsData = JSON.parse(res.body.toString());
|
|
417
|
-
const buckets = bucketsData.map((bucketData) => BucketSettings._fromNsData(bucketData));
|
|
418
|
-
return buckets;
|
|
419
|
-
}), callback);
|
|
420
|
-
});
|
|
427
|
+
const bucketsData = JSON.parse(res.body.toString());
|
|
428
|
+
const buckets = bucketsData.map((bucketData) => BucketSettings._fromNsData(bucketData));
|
|
429
|
+
return buckets;
|
|
430
|
+
}, callback);
|
|
421
431
|
}
|
|
422
432
|
/**
|
|
423
433
|
* Flushes the bucket, deleting all the existing data that is stored in it.
|
|
@@ -426,35 +436,33 @@ class BucketManager {
|
|
|
426
436
|
* @param options Optional parameters for this operation.
|
|
427
437
|
* @param callback A node-style callback to be invoked after execution.
|
|
428
438
|
*/
|
|
429
|
-
flushBucket(bucketName, options, callback) {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
throw new errors_1.BucketNotFoundError(undefined, errCtx);
|
|
453
|
-
}
|
|
454
|
-
throw new errors_1.CouchbaseError('failed to get bucket', undefined, errCtx);
|
|
439
|
+
async flushBucket(bucketName, options, callback) {
|
|
440
|
+
if (options instanceof Function) {
|
|
441
|
+
callback = arguments[1];
|
|
442
|
+
options = undefined;
|
|
443
|
+
}
|
|
444
|
+
if (!options) {
|
|
445
|
+
options = {};
|
|
446
|
+
}
|
|
447
|
+
const parentSpan = options.parentSpan;
|
|
448
|
+
const timeout = options.timeout;
|
|
449
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
450
|
+
const res = await this._http.request({
|
|
451
|
+
type: httpexecutor_1.HttpServiceType.Management,
|
|
452
|
+
method: httpexecutor_1.HttpMethod.Post,
|
|
453
|
+
path: `/pools/default/buckets/${bucketName}/controller/doFlush`,
|
|
454
|
+
parentSpan: parentSpan,
|
|
455
|
+
timeout: timeout,
|
|
456
|
+
});
|
|
457
|
+
if (res.statusCode !== 200) {
|
|
458
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
|
459
|
+
const errText = res.body.toString().toLowerCase();
|
|
460
|
+
if (errText.includes('not found')) {
|
|
461
|
+
throw new errors_1.BucketNotFoundError(undefined, errCtx);
|
|
455
462
|
}
|
|
456
|
-
|
|
457
|
-
|
|
463
|
+
throw new errors_1.CouchbaseError('failed to get bucket', undefined, errCtx);
|
|
464
|
+
}
|
|
465
|
+
}, callback);
|
|
458
466
|
}
|
|
459
467
|
}
|
|
460
468
|
exports.BucketManager = BucketManager;
|
package/dist/cluster.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { Bucket } from './bucket';
|
|
|
5
5
|
import { BucketManager } from './bucketmanager';
|
|
6
6
|
import { Connection } from './connection';
|
|
7
7
|
import { DiagnosticsOptions, DiagnosticsResult, PingOptions, PingResult } from './diagnosticstypes';
|
|
8
|
+
import { EventingFunctionManager } from './eventingfunctionmanager';
|
|
8
9
|
import { LogFunc } from './logging';
|
|
9
10
|
import { Meter } from './metrics';
|
|
10
11
|
import { QueryIndexManager } from './queryindexmanager';
|
|
@@ -158,6 +159,12 @@ export declare class Cluster {
|
|
|
158
159
|
* indexes of this cluster.
|
|
159
160
|
*/
|
|
160
161
|
searchIndexes(): SearchIndexManager;
|
|
162
|
+
/**
|
|
163
|
+
* Returns a EventingFunctionManager which can be used to manage the eventing
|
|
164
|
+
* functions of this cluster.
|
|
165
|
+
* Volatile: This API is subject to change at any time.
|
|
166
|
+
*/
|
|
167
|
+
eventingFunctions(): EventingFunctionManager;
|
|
161
168
|
/**
|
|
162
169
|
* Executes a N1QL query against the cluster.
|
|
163
170
|
*
|