couchbase 3.2.2 → 3.2.5
Sign up to get free protection for your applications and to get access to all the features.
- 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/searchtypes.d.ts
CHANGED
@@ -44,7 +44,7 @@ export declare class SearchResult {
|
|
44
44
|
*
|
45
45
|
* @category Full Text Search
|
46
46
|
*/
|
47
|
-
declare enum HighlightStyle {
|
47
|
+
export declare enum HighlightStyle {
|
48
48
|
/**
|
49
49
|
* Indicates that matches should be highlighted using HTML tags in the result text.
|
50
50
|
*/
|
@@ -123,6 +123,12 @@ export interface SearchQueryOptions {
|
|
123
123
|
* impossible to sort based on how well a particular result scored.
|
124
124
|
*/
|
125
125
|
disableScoring?: boolean;
|
126
|
+
/**
|
127
|
+
* If set to true, will include the locations in the search result.
|
128
|
+
*
|
129
|
+
* @experimental This API is subject to change without notice.
|
130
|
+
*/
|
131
|
+
includeLocations?: boolean;
|
126
132
|
/**
|
127
133
|
* Specifies the consistency requirements when executing the query.
|
128
134
|
*
|
@@ -151,4 +157,3 @@ export interface SearchQueryOptions {
|
|
151
157
|
*/
|
152
158
|
timeout?: number;
|
153
159
|
}
|
154
|
-
export {};
|
package/dist/searchtypes.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.SearchScanConsistency = exports.SearchResult = exports.SearchRow = exports.SearchMetaData = void 0;
|
3
|
+
exports.SearchScanConsistency = exports.HighlightStyle = exports.SearchResult = exports.SearchRow = exports.SearchMetaData = void 0;
|
4
4
|
/**
|
5
5
|
* SearchMetaData represents the meta-data available from a search query.
|
6
6
|
* This class is currently incomplete and must be casted to `any` in
|
@@ -51,7 +51,7 @@ var HighlightStyle;
|
|
51
51
|
* Indicates that matches should be highlighted using ASCII coding in the result test.
|
52
52
|
*/
|
53
53
|
HighlightStyle["ANSI"] = "ansi";
|
54
|
-
})(HighlightStyle || (HighlightStyle = {}));
|
54
|
+
})(HighlightStyle = exports.HighlightStyle || (exports.HighlightStyle = {}));
|
55
55
|
/**
|
56
56
|
* Represents the various scan consistency options that are available when
|
57
57
|
* querying against the query service.
|
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");
|
@@ -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: (0, 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: (0, 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;
|