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/usermanager.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
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.UserManager = exports.Group = exports.UserAndMetadata = exports.User = exports.RoleAndOrigin = exports.RoleAndDescription = exports.Role = exports.Origin = void 0;
|
|
13
4
|
const errors_1 = require("./errors");
|
|
@@ -57,7 +48,7 @@ class Role {
|
|
|
57
48
|
*/
|
|
58
49
|
static _fromNsData(data) {
|
|
59
50
|
return new Role({
|
|
60
|
-
name: data.
|
|
51
|
+
name: data.role,
|
|
61
52
|
bucket: data.bucket_name,
|
|
62
53
|
scope: data.scope_name,
|
|
63
54
|
collection: data.collection_name,
|
|
@@ -103,7 +94,11 @@ class RoleAndDescription extends Role {
|
|
|
103
94
|
* @internal
|
|
104
95
|
*/
|
|
105
96
|
static _fromNsData(data) {
|
|
106
|
-
return new RoleAndDescription(
|
|
97
|
+
return new RoleAndDescription({
|
|
98
|
+
...Role._fromNsData(data),
|
|
99
|
+
displayName: data.name,
|
|
100
|
+
description: data.description,
|
|
101
|
+
});
|
|
107
102
|
}
|
|
108
103
|
}
|
|
109
104
|
exports.RoleAndDescription = RoleAndDescription;
|
|
@@ -131,7 +126,10 @@ class RoleAndOrigin extends Role {
|
|
|
131
126
|
else {
|
|
132
127
|
origins = [];
|
|
133
128
|
}
|
|
134
|
-
return new RoleAndOrigin(
|
|
129
|
+
return new RoleAndOrigin({
|
|
130
|
+
...Role._fromNsData(data),
|
|
131
|
+
origins,
|
|
132
|
+
});
|
|
135
133
|
}
|
|
136
134
|
}
|
|
137
135
|
exports.RoleAndOrigin = RoleAndOrigin;
|
|
@@ -236,7 +234,14 @@ class UserAndMetadata extends User {
|
|
|
236
234
|
else {
|
|
237
235
|
effectiveRoles = [];
|
|
238
236
|
}
|
|
239
|
-
return new UserAndMetadata(
|
|
237
|
+
return new UserAndMetadata({
|
|
238
|
+
...User._fromNsData(data),
|
|
239
|
+
domain: data.domain,
|
|
240
|
+
effectiveRoles: effectiveRoles,
|
|
241
|
+
effectiveRolesAndOrigins: effectiveRoles,
|
|
242
|
+
passwordChanged: new Date(data.password_change_date),
|
|
243
|
+
externalGroups: data.external_groups,
|
|
244
|
+
});
|
|
240
245
|
}
|
|
241
246
|
}
|
|
242
247
|
exports.UserAndMetadata = UserAndMetadata;
|
|
@@ -312,37 +317,35 @@ class UserManager {
|
|
|
312
317
|
* @param options Optional parameters for this operation.
|
|
313
318
|
* @param callback A node-style callback to be invoked after execution.
|
|
314
319
|
*/
|
|
315
|
-
getUser(username, options, callback) {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
throw new errors_1.UserNotFoundError(undefined, errCtx);
|
|
339
|
-
}
|
|
340
|
-
throw new errors_1.CouchbaseError('failed to get the user', undefined, errCtx);
|
|
320
|
+
async getUser(username, options, callback) {
|
|
321
|
+
if (options instanceof Function) {
|
|
322
|
+
callback = arguments[1];
|
|
323
|
+
options = undefined;
|
|
324
|
+
}
|
|
325
|
+
if (!options) {
|
|
326
|
+
options = {};
|
|
327
|
+
}
|
|
328
|
+
const domainName = options.domainName || 'local';
|
|
329
|
+
const parentSpan = options.parentSpan;
|
|
330
|
+
const timeout = options.timeout;
|
|
331
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
332
|
+
const res = await this._http.request({
|
|
333
|
+
type: httpexecutor_1.HttpServiceType.Management,
|
|
334
|
+
method: httpexecutor_1.HttpMethod.Get,
|
|
335
|
+
path: `/settings/rbac/users/${domainName}/${username}`,
|
|
336
|
+
parentSpan: parentSpan,
|
|
337
|
+
timeout: timeout,
|
|
338
|
+
});
|
|
339
|
+
if (res.statusCode !== 200) {
|
|
340
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
|
341
|
+
if (res.statusCode === 404) {
|
|
342
|
+
throw new errors_1.UserNotFoundError(undefined, errCtx);
|
|
341
343
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
344
|
+
throw new errors_1.CouchbaseError('failed to get the user', undefined, errCtx);
|
|
345
|
+
}
|
|
346
|
+
const userData = JSON.parse(res.body.toString());
|
|
347
|
+
return UserAndMetadata._fromNsData(userData);
|
|
348
|
+
}, callback);
|
|
346
349
|
}
|
|
347
350
|
/**
|
|
348
351
|
* Returns a list of all existing users.
|
|
@@ -350,35 +353,33 @@ class UserManager {
|
|
|
350
353
|
* @param options Optional parameters for this operation.
|
|
351
354
|
* @param callback A node-style callback to be invoked after execution.
|
|
352
355
|
*/
|
|
353
|
-
getAllUsers(options, callback) {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
356
|
+
async getAllUsers(options, callback) {
|
|
357
|
+
if (options instanceof Function) {
|
|
358
|
+
callback = arguments[0];
|
|
359
|
+
options = undefined;
|
|
360
|
+
}
|
|
361
|
+
if (!options) {
|
|
362
|
+
options = {};
|
|
363
|
+
}
|
|
364
|
+
const domainName = options.domainName || 'local';
|
|
365
|
+
const parentSpan = options.parentSpan;
|
|
366
|
+
const timeout = options.timeout;
|
|
367
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
368
|
+
const res = await this._http.request({
|
|
369
|
+
type: httpexecutor_1.HttpServiceType.Management,
|
|
370
|
+
method: httpexecutor_1.HttpMethod.Get,
|
|
371
|
+
path: `/settings/rbac/users/${domainName}`,
|
|
372
|
+
parentSpan: parentSpan,
|
|
373
|
+
timeout: timeout,
|
|
374
|
+
});
|
|
375
|
+
if (res.statusCode !== 200) {
|
|
376
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
|
377
|
+
throw new errors_1.CouchbaseError('failed to get users', undefined, errCtx);
|
|
361
378
|
}
|
|
362
|
-
const
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
const res = yield this._http.request({
|
|
367
|
-
type: httpexecutor_1.HttpServiceType.Management,
|
|
368
|
-
method: httpexecutor_1.HttpMethod.Get,
|
|
369
|
-
path: `/settings/rbac/users/${domainName}`,
|
|
370
|
-
parentSpan: parentSpan,
|
|
371
|
-
timeout: timeout,
|
|
372
|
-
});
|
|
373
|
-
if (res.statusCode !== 200) {
|
|
374
|
-
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
|
375
|
-
throw new errors_1.CouchbaseError('failed to get users', undefined, errCtx);
|
|
376
|
-
}
|
|
377
|
-
const usersData = JSON.parse(res.body.toString());
|
|
378
|
-
const users = usersData.map((userData) => UserAndMetadata._fromNsData(userData));
|
|
379
|
-
return users;
|
|
380
|
-
}), callback);
|
|
381
|
-
});
|
|
379
|
+
const usersData = JSON.parse(res.body.toString());
|
|
380
|
+
const users = usersData.map((userData) => UserAndMetadata._fromNsData(userData));
|
|
381
|
+
return users;
|
|
382
|
+
}, callback);
|
|
382
383
|
}
|
|
383
384
|
/**
|
|
384
385
|
* Creates or updates an existing user.
|
|
@@ -387,35 +388,33 @@ class UserManager {
|
|
|
387
388
|
* @param options Optional parameters for this operation.
|
|
388
389
|
* @param callback A node-style callback to be invoked after execution.
|
|
389
390
|
*/
|
|
390
|
-
upsertUser(user, options, callback) {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
391
|
+
async upsertUser(user, options, callback) {
|
|
392
|
+
if (options instanceof Function) {
|
|
393
|
+
callback = arguments[1];
|
|
394
|
+
options = undefined;
|
|
395
|
+
}
|
|
396
|
+
if (!options) {
|
|
397
|
+
options = {};
|
|
398
|
+
}
|
|
399
|
+
const domainName = options.domainName || 'local';
|
|
400
|
+
const parentSpan = options.parentSpan;
|
|
401
|
+
const timeout = options.timeout;
|
|
402
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
403
|
+
const userData = User._toNsData(user);
|
|
404
|
+
const res = await this._http.request({
|
|
405
|
+
type: httpexecutor_1.HttpServiceType.Management,
|
|
406
|
+
method: httpexecutor_1.HttpMethod.Put,
|
|
407
|
+
path: `/settings/rbac/users/${domainName}/${user.username}`,
|
|
408
|
+
contentType: 'application/x-www-form-urlencoded',
|
|
409
|
+
body: utilities_1.cbQsStringify(userData),
|
|
410
|
+
parentSpan: parentSpan,
|
|
411
|
+
timeout: timeout,
|
|
412
|
+
});
|
|
413
|
+
if (res.statusCode !== 200) {
|
|
414
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
|
415
|
+
throw new errors_1.CouchbaseError('failed to upsert user', undefined, errCtx);
|
|
398
416
|
}
|
|
399
|
-
|
|
400
|
-
const parentSpan = options.parentSpan;
|
|
401
|
-
const timeout = options.timeout;
|
|
402
|
-
return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
|
|
403
|
-
const userData = User._toNsData(user);
|
|
404
|
-
const res = yield this._http.request({
|
|
405
|
-
type: httpexecutor_1.HttpServiceType.Management,
|
|
406
|
-
method: httpexecutor_1.HttpMethod.Put,
|
|
407
|
-
path: `/settings/rbac/users/${domainName}/${user.username}`,
|
|
408
|
-
contentType: 'application/x-www-form-urlencoded',
|
|
409
|
-
body: utilities_1.cbQsStringify(userData),
|
|
410
|
-
parentSpan: parentSpan,
|
|
411
|
-
timeout: timeout,
|
|
412
|
-
});
|
|
413
|
-
if (res.statusCode !== 200) {
|
|
414
|
-
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
|
415
|
-
throw new errors_1.CouchbaseError('failed to upsert user', undefined, errCtx);
|
|
416
|
-
}
|
|
417
|
-
}), callback);
|
|
418
|
-
});
|
|
417
|
+
}, callback);
|
|
419
418
|
}
|
|
420
419
|
/**
|
|
421
420
|
* Drops an existing user.
|
|
@@ -424,35 +423,33 @@ class UserManager {
|
|
|
424
423
|
* @param options Optional parameters for this operation.
|
|
425
424
|
* @param callback A node-style callback to be invoked after execution.
|
|
426
425
|
*/
|
|
427
|
-
dropUser(username, options, callback) {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
throw new errors_1.UserNotFoundError(undefined, errCtx);
|
|
451
|
-
}
|
|
452
|
-
throw new errors_1.CouchbaseError('failed to drop the user', undefined, errCtx);
|
|
426
|
+
async dropUser(username, options, callback) {
|
|
427
|
+
if (options instanceof Function) {
|
|
428
|
+
callback = arguments[1];
|
|
429
|
+
options = undefined;
|
|
430
|
+
}
|
|
431
|
+
if (!options) {
|
|
432
|
+
options = {};
|
|
433
|
+
}
|
|
434
|
+
const domainName = options.domainName || 'local';
|
|
435
|
+
const parentSpan = options.parentSpan;
|
|
436
|
+
const timeout = options.timeout;
|
|
437
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
438
|
+
const res = await this._http.request({
|
|
439
|
+
type: httpexecutor_1.HttpServiceType.Management,
|
|
440
|
+
method: httpexecutor_1.HttpMethod.Delete,
|
|
441
|
+
path: `/settings/rbac/users/${domainName}/${username}`,
|
|
442
|
+
parentSpan: parentSpan,
|
|
443
|
+
timeout: timeout,
|
|
444
|
+
});
|
|
445
|
+
if (res.statusCode !== 200) {
|
|
446
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
|
447
|
+
if (res.statusCode === 404) {
|
|
448
|
+
throw new errors_1.UserNotFoundError(undefined, errCtx);
|
|
453
449
|
}
|
|
454
|
-
|
|
455
|
-
|
|
450
|
+
throw new errors_1.CouchbaseError('failed to drop the user', undefined, errCtx);
|
|
451
|
+
}
|
|
452
|
+
}, callback);
|
|
456
453
|
}
|
|
457
454
|
/**
|
|
458
455
|
* Returns a list of roles available on the server.
|
|
@@ -460,34 +457,32 @@ class UserManager {
|
|
|
460
457
|
* @param options Optional parameters for this operation.
|
|
461
458
|
* @param callback A node-style callback to be invoked after execution.
|
|
462
459
|
*/
|
|
463
|
-
getRoles(options, callback) {
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
460
|
+
async getRoles(options, callback) {
|
|
461
|
+
if (options instanceof Function) {
|
|
462
|
+
callback = arguments[0];
|
|
463
|
+
options = undefined;
|
|
464
|
+
}
|
|
465
|
+
if (!options) {
|
|
466
|
+
options = {};
|
|
467
|
+
}
|
|
468
|
+
const parentSpan = options.parentSpan;
|
|
469
|
+
const timeout = options.timeout;
|
|
470
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
471
|
+
const res = await this._http.request({
|
|
472
|
+
type: httpexecutor_1.HttpServiceType.Management,
|
|
473
|
+
method: httpexecutor_1.HttpMethod.Get,
|
|
474
|
+
path: `/settings/rbac/roles`,
|
|
475
|
+
parentSpan: parentSpan,
|
|
476
|
+
timeout: timeout,
|
|
477
|
+
});
|
|
478
|
+
if (res.statusCode !== 200) {
|
|
479
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
|
480
|
+
throw new errors_1.CouchbaseError('failed to get roles', undefined, errCtx);
|
|
471
481
|
}
|
|
472
|
-
const
|
|
473
|
-
const
|
|
474
|
-
return
|
|
475
|
-
|
|
476
|
-
type: httpexecutor_1.HttpServiceType.Management,
|
|
477
|
-
method: httpexecutor_1.HttpMethod.Get,
|
|
478
|
-
path: `/settings/rbac/roles`,
|
|
479
|
-
parentSpan: parentSpan,
|
|
480
|
-
timeout: timeout,
|
|
481
|
-
});
|
|
482
|
-
if (res.statusCode !== 200) {
|
|
483
|
-
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
|
484
|
-
throw new errors_1.CouchbaseError('failed to get roles', undefined, errCtx);
|
|
485
|
-
}
|
|
486
|
-
const rolesData = JSON.parse(res.body.toString());
|
|
487
|
-
const roles = rolesData.map((roleData) => RoleAndDescription._fromNsData(roleData));
|
|
488
|
-
return roles;
|
|
489
|
-
}), callback);
|
|
490
|
-
});
|
|
482
|
+
const rolesData = JSON.parse(res.body.toString());
|
|
483
|
+
const roles = rolesData.map((roleData) => RoleAndDescription._fromNsData(roleData));
|
|
484
|
+
return roles;
|
|
485
|
+
}, callback);
|
|
491
486
|
}
|
|
492
487
|
/**
|
|
493
488
|
* Returns a group by it's name.
|
|
@@ -496,36 +491,34 @@ class UserManager {
|
|
|
496
491
|
* @param options Optional parameters for this operation.
|
|
497
492
|
* @param callback A node-style callback to be invoked after execution.
|
|
498
493
|
*/
|
|
499
|
-
getGroup(groupName, options, callback) {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
throw new errors_1.GroupNotFoundError(undefined, errCtx);
|
|
522
|
-
}
|
|
523
|
-
throw new errors_1.CouchbaseError('failed to get the group', undefined, errCtx);
|
|
494
|
+
async getGroup(groupName, options, callback) {
|
|
495
|
+
if (options instanceof Function) {
|
|
496
|
+
callback = arguments[1];
|
|
497
|
+
options = undefined;
|
|
498
|
+
}
|
|
499
|
+
if (!options) {
|
|
500
|
+
options = {};
|
|
501
|
+
}
|
|
502
|
+
const parentSpan = options.parentSpan;
|
|
503
|
+
const timeout = options.timeout;
|
|
504
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
505
|
+
const res = await this._http.request({
|
|
506
|
+
type: httpexecutor_1.HttpServiceType.Management,
|
|
507
|
+
method: httpexecutor_1.HttpMethod.Get,
|
|
508
|
+
path: `/settings/rbac/groups/${groupName}`,
|
|
509
|
+
parentSpan: parentSpan,
|
|
510
|
+
timeout: timeout,
|
|
511
|
+
});
|
|
512
|
+
if (res.statusCode !== 200) {
|
|
513
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
|
514
|
+
if (res.statusCode === 404) {
|
|
515
|
+
throw new errors_1.GroupNotFoundError(undefined, errCtx);
|
|
524
516
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
517
|
+
throw new errors_1.CouchbaseError('failed to get the group', undefined, errCtx);
|
|
518
|
+
}
|
|
519
|
+
const groupData = JSON.parse(res.body.toString());
|
|
520
|
+
return Group._fromNsData(groupData);
|
|
521
|
+
}, callback);
|
|
529
522
|
}
|
|
530
523
|
/**
|
|
531
524
|
* Returns a list of all existing groups.
|
|
@@ -533,34 +526,32 @@ class UserManager {
|
|
|
533
526
|
* @param options Optional parameters for this operation.
|
|
534
527
|
* @param callback A node-style callback to be invoked after execution.
|
|
535
528
|
*/
|
|
536
|
-
getAllGroups(options, callback) {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
529
|
+
async getAllGroups(options, callback) {
|
|
530
|
+
if (options instanceof Function) {
|
|
531
|
+
callback = arguments[0];
|
|
532
|
+
options = undefined;
|
|
533
|
+
}
|
|
534
|
+
if (!options) {
|
|
535
|
+
options = {};
|
|
536
|
+
}
|
|
537
|
+
const parentSpan = options.parentSpan;
|
|
538
|
+
const timeout = options.timeout;
|
|
539
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
540
|
+
const res = await this._http.request({
|
|
541
|
+
type: httpexecutor_1.HttpServiceType.Management,
|
|
542
|
+
method: httpexecutor_1.HttpMethod.Get,
|
|
543
|
+
path: `/settings/rbac/groups`,
|
|
544
|
+
parentSpan: parentSpan,
|
|
545
|
+
timeout: timeout,
|
|
546
|
+
});
|
|
547
|
+
if (res.statusCode !== 200) {
|
|
548
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
|
549
|
+
throw new errors_1.CouchbaseError('failed to get groups', undefined, errCtx);
|
|
544
550
|
}
|
|
545
|
-
const
|
|
546
|
-
const
|
|
547
|
-
return
|
|
548
|
-
|
|
549
|
-
type: httpexecutor_1.HttpServiceType.Management,
|
|
550
|
-
method: httpexecutor_1.HttpMethod.Get,
|
|
551
|
-
path: `/settings/rbac/groups`,
|
|
552
|
-
parentSpan: parentSpan,
|
|
553
|
-
timeout: timeout,
|
|
554
|
-
});
|
|
555
|
-
if (res.statusCode !== 200) {
|
|
556
|
-
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
|
557
|
-
throw new errors_1.CouchbaseError('failed to get groups', undefined, errCtx);
|
|
558
|
-
}
|
|
559
|
-
const groupsData = JSON.parse(res.body.toString());
|
|
560
|
-
const groups = groupsData.map((groupData) => Group._fromNsData(groupData));
|
|
561
|
-
return groups;
|
|
562
|
-
}), callback);
|
|
563
|
-
});
|
|
551
|
+
const groupsData = JSON.parse(res.body.toString());
|
|
552
|
+
const groups = groupsData.map((groupData) => Group._fromNsData(groupData));
|
|
553
|
+
return groups;
|
|
554
|
+
}, callback);
|
|
564
555
|
}
|
|
565
556
|
/**
|
|
566
557
|
* Creates or updates an existing group.
|
|
@@ -569,34 +560,32 @@ class UserManager {
|
|
|
569
560
|
* @param options Optional parameters for this operation.
|
|
570
561
|
* @param callback A node-style callback to be invoked after execution.
|
|
571
562
|
*/
|
|
572
|
-
upsertGroup(group, options, callback) {
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
563
|
+
async upsertGroup(group, options, callback) {
|
|
564
|
+
if (options instanceof Function) {
|
|
565
|
+
callback = arguments[1];
|
|
566
|
+
options = undefined;
|
|
567
|
+
}
|
|
568
|
+
if (!options) {
|
|
569
|
+
options = {};
|
|
570
|
+
}
|
|
571
|
+
const parentSpan = options.parentSpan;
|
|
572
|
+
const timeout = options.timeout;
|
|
573
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
574
|
+
const groupData = Group._toNsData(group);
|
|
575
|
+
const res = await this._http.request({
|
|
576
|
+
type: httpexecutor_1.HttpServiceType.Management,
|
|
577
|
+
method: httpexecutor_1.HttpMethod.Put,
|
|
578
|
+
path: `/settings/rbac/groups/${group.name}`,
|
|
579
|
+
contentType: 'application/x-www-form-urlencoded',
|
|
580
|
+
body: utilities_1.cbQsStringify(groupData),
|
|
581
|
+
parentSpan: parentSpan,
|
|
582
|
+
timeout: timeout,
|
|
583
|
+
});
|
|
584
|
+
if (res.statusCode !== 200) {
|
|
585
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
|
586
|
+
throw new errors_1.CouchbaseError('failed to upsert group', undefined, errCtx);
|
|
580
587
|
}
|
|
581
|
-
|
|
582
|
-
const timeout = options.timeout;
|
|
583
|
-
return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
|
|
584
|
-
const groupData = Group._toNsData(group);
|
|
585
|
-
const res = yield this._http.request({
|
|
586
|
-
type: httpexecutor_1.HttpServiceType.Management,
|
|
587
|
-
method: httpexecutor_1.HttpMethod.Put,
|
|
588
|
-
path: `/settings/rbac/groups/${group.name}`,
|
|
589
|
-
contentType: 'application/x-www-form-urlencoded',
|
|
590
|
-
body: utilities_1.cbQsStringify(groupData),
|
|
591
|
-
parentSpan: parentSpan,
|
|
592
|
-
timeout: timeout,
|
|
593
|
-
});
|
|
594
|
-
if (res.statusCode !== 200) {
|
|
595
|
-
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
|
596
|
-
throw new errors_1.CouchbaseError('failed to upsert group', undefined, errCtx);
|
|
597
|
-
}
|
|
598
|
-
}), callback);
|
|
599
|
-
});
|
|
588
|
+
}, callback);
|
|
600
589
|
}
|
|
601
590
|
/**
|
|
602
591
|
* Drops an existing group.
|
|
@@ -605,34 +594,32 @@ class UserManager {
|
|
|
605
594
|
* @param options Optional parameters for this operation.
|
|
606
595
|
* @param callback A node-style callback to be invoked after execution.
|
|
607
596
|
*/
|
|
608
|
-
dropGroup(groupName, options, callback) {
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
throw new errors_1.GroupNotFoundError(undefined, errCtx);
|
|
631
|
-
}
|
|
632
|
-
throw new errors_1.CouchbaseError('failed to drop the group', undefined, errCtx);
|
|
597
|
+
async dropGroup(groupName, options, callback) {
|
|
598
|
+
if (options instanceof Function) {
|
|
599
|
+
callback = arguments[1];
|
|
600
|
+
options = undefined;
|
|
601
|
+
}
|
|
602
|
+
if (!options) {
|
|
603
|
+
options = {};
|
|
604
|
+
}
|
|
605
|
+
const parentSpan = options.parentSpan;
|
|
606
|
+
const timeout = options.timeout;
|
|
607
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
608
|
+
const res = await this._http.request({
|
|
609
|
+
type: httpexecutor_1.HttpServiceType.Management,
|
|
610
|
+
method: httpexecutor_1.HttpMethod.Delete,
|
|
611
|
+
path: `/settings/rbac/groups/${groupName}`,
|
|
612
|
+
parentSpan: parentSpan,
|
|
613
|
+
timeout: timeout,
|
|
614
|
+
});
|
|
615
|
+
if (res.statusCode !== 200) {
|
|
616
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
|
617
|
+
if (res.statusCode === 404) {
|
|
618
|
+
throw new errors_1.GroupNotFoundError(undefined, errCtx);
|
|
633
619
|
}
|
|
634
|
-
|
|
635
|
-
|
|
620
|
+
throw new errors_1.CouchbaseError('failed to drop the group', undefined, errCtx);
|
|
621
|
+
}
|
|
622
|
+
}, callback);
|
|
636
623
|
}
|
|
637
624
|
}
|
|
638
625
|
exports.UserManager = UserManager;
|
package/dist/utilities.d.ts
CHANGED
package/dist/utilities.js
CHANGED
|
@@ -181,14 +181,19 @@ exports.nsServerStrToDuraLevel = nsServerStrToDuraLevel;
|
|
|
181
181
|
/**
|
|
182
182
|
* @internal
|
|
183
183
|
*/
|
|
184
|
-
function cbQsStringify(values) {
|
|
184
|
+
function cbQsStringify(values, options) {
|
|
185
185
|
const cbValues = {};
|
|
186
186
|
for (const i in values) {
|
|
187
187
|
if (values[i] === undefined) {
|
|
188
188
|
// skipped
|
|
189
189
|
}
|
|
190
190
|
else if (typeof values[i] === 'boolean') {
|
|
191
|
-
|
|
191
|
+
if (options && options.boolAsString) {
|
|
192
|
+
cbValues[i] = values[i] ? 'true' : 'false';
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
cbValues[i] = values[i] ? 1 : 0;
|
|
196
|
+
}
|
|
192
197
|
}
|
|
193
198
|
else {
|
|
194
199
|
cbValues[i] = values[i];
|