couchbase 3.2.2 → 3.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. package/binding.gyp +5 -0
  2. package/deps/lcb/CMakeLists.txt +1 -1
  3. package/deps/lcb/CONTRIBUTING.md +1 -1
  4. package/deps/lcb/README.markdown +2 -2
  5. package/deps/lcb/RELEASE_NOTES.markdown +84 -17
  6. package/deps/lcb/cmake/Modules/GetVersionInfo.cmake +1 -1
  7. package/deps/lcb/contrib/cbsasl/src/scram-sha/scram_utils.cc +22 -26
  8. package/deps/lcb/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp +20 -6
  9. package/deps/lcb/doc/Doxyfile +1 -1
  10. package/deps/lcb/example/minimal/query.c +9 -7
  11. package/deps/lcb/gyp_config/common/libcouchbase/configuration.h +3 -3
  12. package/deps/lcb/gyp_config/linux/arm64/config.h +243 -0
  13. package/deps/lcb/include/libcouchbase/couchbase.h +55 -1
  14. package/deps/lcb/include/libcouchbase/error.h +6 -1
  15. package/deps/lcb/include/libcouchbase/ixmgmt.h +15 -10
  16. package/deps/lcb/include/libcouchbase/tracing.h +2 -2
  17. package/deps/lcb/include/memcached/protocol_binary.h +21 -0
  18. package/deps/lcb/libcouchbase.gyp +353 -349
  19. package/deps/lcb/packaging/deb/control +1 -1
  20. package/deps/lcb/src/analytics/analytics_handle.cc +7 -5
  21. package/deps/lcb/src/analytics/analytics_handle.hh +28 -0
  22. package/deps/lcb/src/capi/cmd_counter.hh +18 -0
  23. package/deps/lcb/src/capi/cmd_exists.hh +18 -0
  24. package/deps/lcb/src/capi/cmd_get.hh +17 -0
  25. package/deps/lcb/src/capi/cmd_get_replica.hh +20 -1
  26. package/deps/lcb/src/capi/cmd_query.cc +13 -0
  27. package/deps/lcb/src/capi/cmd_query.hh +22 -14
  28. package/deps/lcb/src/capi/cmd_remove.hh +18 -0
  29. package/deps/lcb/src/capi/cmd_search.hh +6 -0
  30. package/deps/lcb/src/capi/cmd_store.hh +28 -21
  31. package/deps/lcb/src/capi/cmd_subdoc.hh +30 -0
  32. package/deps/lcb/src/capi/cmd_touch.hh +18 -0
  33. package/deps/lcb/src/capi/cmd_unlock.hh +18 -0
  34. package/deps/lcb/src/capi/cmd_view.hh +6 -0
  35. package/deps/lcb/src/capi/collection_qualifier.hh +6 -8
  36. package/deps/lcb/src/cntl.cc +42 -8
  37. package/deps/lcb/src/dns-srv.cc +5 -3
  38. package/deps/lcb/src/errmap.cc +5 -9
  39. package/deps/lcb/src/errmap.h +7 -3
  40. package/deps/lcb/src/handler.cc +24 -18
  41. package/deps/lcb/src/internal.h +2 -1
  42. package/deps/lcb/src/lcbio/ctx.cc +4 -2
  43. package/deps/lcb/src/mcserver/mcserver.cc +8 -5
  44. package/deps/lcb/src/mcserver/negotiate.cc +42 -17
  45. package/deps/lcb/src/n1ql/ixmgmt.cc +1 -2
  46. package/deps/lcb/src/n1ql/n1ql.cc +5 -1
  47. package/deps/lcb/src/n1ql/query_handle.cc +80 -44
  48. package/deps/lcb/src/n1ql/query_handle.hh +41 -3
  49. package/deps/lcb/src/operations/counter.cc +13 -1
  50. package/deps/lcb/src/operations/exists.cc +14 -2
  51. package/deps/lcb/src/operations/get.cc +14 -2
  52. package/deps/lcb/src/operations/get_replica.cc +18 -6
  53. package/deps/lcb/src/operations/observe.cc +1 -1
  54. package/deps/lcb/src/operations/remove.cc +13 -1
  55. package/deps/lcb/src/operations/store.cc +13 -1
  56. package/deps/lcb/src/operations/subdoc.cc +13 -2
  57. package/deps/lcb/src/operations/touch.cc +14 -2
  58. package/deps/lcb/src/operations/unlock.cc +14 -2
  59. package/deps/lcb/src/search/search_handle.cc +26 -8
  60. package/deps/lcb/src/search/search_handle.hh +29 -0
  61. package/deps/lcb/src/ssl/ssl_common.c +7 -8
  62. package/deps/lcb/src/tracing/span.cc +43 -10
  63. package/deps/lcb/src/tracing/tracing-internal.h +105 -93
  64. package/deps/lcb/src/utilities.cc +21 -0
  65. package/deps/lcb/src/utilities.h +3 -0
  66. package/deps/lcb/src/views/view_handle.cc +13 -5
  67. package/deps/lcb/src/views/view_handle.hh +29 -0
  68. package/deps/lcb/tests/CMakeLists.txt +21 -0
  69. package/deps/lcb/tests/basic/t_ctlcodes.cc +24 -3
  70. package/deps/lcb/tests/basic/t_jsparse.cc +8 -0
  71. package/deps/lcb/tests/iotests/mock-environment.cc +25 -1
  72. package/deps/lcb/tests/iotests/mock-environment.h +49 -1
  73. package/deps/lcb/tests/iotests/mock-unit-test.cc +96 -5
  74. package/deps/lcb/tests/iotests/mock-unit-test.h +32 -0
  75. package/deps/lcb/tests/iotests/serverparams.h +7 -2
  76. package/deps/lcb/tests/iotests/t_collections.cc +1 -1
  77. package/deps/lcb/tests/iotests/t_confmon.cc +4 -2
  78. package/deps/lcb/tests/iotests/t_get.cc +14 -4
  79. package/deps/lcb/tests/iotests/t_n1ql.cc +17 -1
  80. package/deps/lcb/tests/iotests/t_ratelimit.cc +729 -0
  81. package/deps/lcb/tests/iotests/t_views.cc +1 -0
  82. package/deps/lcb/tests/iotests/testutil.cc +342 -0
  83. package/deps/lcb/tests/iotests/testutil.h +164 -0
  84. package/deps/lcb/tests/mocksupport/procutil.c +32 -28
  85. package/deps/lcb/tests/mocksupport/server.c +0 -1
  86. package/deps/lcb/tools/cbc.cc +7 -0
  87. package/dist/analyticsexecutor.js +2 -2
  88. package/dist/analyticsindexmanager.js +512 -524
  89. package/dist/binarycollection.d.ts +17 -0
  90. package/dist/binding.d.ts +2 -0
  91. package/dist/binding.js +1 -1
  92. package/dist/bindingutilities.js +9 -1
  93. package/dist/bucketmanager.d.ts +32 -23
  94. package/dist/bucketmanager.js +197 -189
  95. package/dist/cluster.js +37 -36
  96. package/dist/collection.js +17 -23
  97. package/dist/collectionmanager.js +181 -200
  98. package/dist/connection.js +6 -3
  99. package/dist/connspec.js +5 -1
  100. package/dist/couchbase.js +7 -14
  101. package/dist/datastructures.js +239 -310
  102. package/dist/diagnosticsexecutor.js +70 -85
  103. package/dist/errors.d.ts +18 -0
  104. package/dist/errors.js +26 -2
  105. package/dist/eventingfunctionmanager.js +267 -294
  106. package/dist/httpexecutor.js +31 -38
  107. package/dist/logging.js +1 -1
  108. package/dist/queryexecutor.js +3 -3
  109. package/dist/queryindexmanager.js +236 -263
  110. package/dist/scope.js +8 -2
  111. package/dist/searchexecutor.js +3 -0
  112. package/dist/searchindexmanager.js +240 -271
  113. package/dist/searchquery.d.ts +17 -0
  114. package/dist/searchquery.js +22 -1
  115. package/dist/searchtypes.d.ts +7 -2
  116. package/dist/searchtypes.js +2 -2
  117. package/dist/usermanager.js +250 -263
  118. package/dist/utilities.d.ts +3 -2
  119. package/dist/utilities.js +16 -4
  120. package/dist/viewexecutor.js +1 -1
  121. package/dist/viewindexmanager.js +131 -150
  122. package/package.json +1 -1
  123. package/src/connection.cpp +2 -0
  124. package/src/constants.cpp +2 -0
  125. package/src/instance.cpp +8 -1
  126. package/src/instance.h +1 -0
  127. package/src/uv-plugin-all.cpp +1 -0
  128. package/dist/cas.d.ts +0 -0
  129. package/dist/cas.js +0 -1
@@ -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 {};
@@ -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.
@@ -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(Object.assign(Object.assign({}, Role._fromNsData(data)), { displayName: data.name, description: data.description }));
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(Object.assign(Object.assign({}, Role._fromNsData(data)), { origins }));
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(Object.assign(Object.assign({}, User._fromNsData(data)), { domain: data.domain, effectiveRoles: effectiveRoles, effectiveRolesAndOrigins: effectiveRoles, passwordChanged: new Date(data.password_change_date), externalGroups: data.external_groups }));
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
- return __awaiter(this, arguments, void 0, function* () {
317
- if (options instanceof Function) {
318
- callback = arguments[1];
319
- options = undefined;
320
- }
321
- if (!options) {
322
- options = {};
323
- }
324
- const domainName = options.domainName || 'local';
325
- const parentSpan = options.parentSpan;
326
- const timeout = options.timeout;
327
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
328
- const res = yield this._http.request({
329
- type: httpexecutor_1.HttpServiceType.Management,
330
- method: httpexecutor_1.HttpMethod.Get,
331
- path: `/settings/rbac/users/${domainName}/${username}`,
332
- parentSpan: parentSpan,
333
- timeout: timeout,
334
- });
335
- if (res.statusCode !== 200) {
336
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
337
- if (res.statusCode === 404) {
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
- const userData = JSON.parse(res.body.toString());
343
- return UserAndMetadata._fromNsData(userData);
344
- }), callback);
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
- return __awaiter(this, arguments, void 0, function* () {
355
- if (options instanceof Function) {
356
- callback = arguments[0];
357
- options = undefined;
358
- }
359
- if (!options) {
360
- options = {};
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 domainName = options.domainName || 'local';
363
- const parentSpan = options.parentSpan;
364
- const timeout = options.timeout;
365
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
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
- return __awaiter(this, arguments, void 0, function* () {
392
- if (options instanceof Function) {
393
- callback = arguments[1];
394
- options = undefined;
395
- }
396
- if (!options) {
397
- options = {};
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
- const domainName = options.domainName || 'local';
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
- return __awaiter(this, arguments, void 0, function* () {
429
- if (options instanceof Function) {
430
- callback = arguments[1];
431
- options = undefined;
432
- }
433
- if (!options) {
434
- options = {};
435
- }
436
- const domainName = options.domainName || 'local';
437
- const parentSpan = options.parentSpan;
438
- const timeout = options.timeout;
439
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
440
- const res = yield this._http.request({
441
- type: httpexecutor_1.HttpServiceType.Management,
442
- method: httpexecutor_1.HttpMethod.Delete,
443
- path: `/settings/rbac/users/${domainName}/${username}`,
444
- parentSpan: parentSpan,
445
- timeout: timeout,
446
- });
447
- if (res.statusCode !== 200) {
448
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
449
- if (res.statusCode === 404) {
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
- }), callback);
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
- return __awaiter(this, arguments, void 0, function* () {
465
- if (options instanceof Function) {
466
- callback = arguments[1];
467
- options = undefined;
468
- }
469
- if (!options) {
470
- options = {};
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 parentSpan = options.parentSpan;
473
- const timeout = options.timeout;
474
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
475
- const res = yield this._http.request({
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
- return __awaiter(this, arguments, void 0, function* () {
501
- if (options instanceof Function) {
502
- callback = arguments[1];
503
- options = undefined;
504
- }
505
- if (!options) {
506
- options = {};
507
- }
508
- const parentSpan = options.parentSpan;
509
- const timeout = options.timeout;
510
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
511
- const res = yield this._http.request({
512
- type: httpexecutor_1.HttpServiceType.Management,
513
- method: httpexecutor_1.HttpMethod.Get,
514
- path: `/settings/rbac/groups/${groupName}`,
515
- parentSpan: parentSpan,
516
- timeout: timeout,
517
- });
518
- if (res.statusCode !== 200) {
519
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
520
- if (res.statusCode === 404) {
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
- const groupData = JSON.parse(res.body.toString());
526
- return Group._fromNsData(groupData);
527
- }), callback);
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
- return __awaiter(this, arguments, void 0, function* () {
538
- if (options instanceof Function) {
539
- callback = arguments[0];
540
- options = undefined;
541
- }
542
- if (!options) {
543
- options = {};
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 parentSpan = options.parentSpan;
546
- const timeout = options.timeout;
547
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
548
- const res = yield this._http.request({
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
- return __awaiter(this, arguments, void 0, function* () {
574
- if (options instanceof Function) {
575
- callback = arguments[1];
576
- options = undefined;
577
- }
578
- if (!options) {
579
- options = {};
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
- const parentSpan = options.parentSpan;
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
- return __awaiter(this, arguments, void 0, function* () {
610
- if (options instanceof Function) {
611
- callback = arguments[1];
612
- options = undefined;
613
- }
614
- if (!options) {
615
- options = {};
616
- }
617
- const parentSpan = options.parentSpan;
618
- const timeout = options.timeout;
619
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
620
- const res = yield this._http.request({
621
- type: httpexecutor_1.HttpServiceType.Management,
622
- method: httpexecutor_1.HttpMethod.Delete,
623
- path: `/settings/rbac/groups/${groupName}`,
624
- parentSpan: parentSpan,
625
- timeout: timeout,
626
- });
627
- if (res.statusCode !== 200) {
628
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
629
- if (res.statusCode === 404) {
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
- }), callback);
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;