couchbase 3.2.0 → 3.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. package/README.md +24 -18
  2. package/binding.gyp +88 -85
  3. package/deps/lcb/CMakeLists.txt +1 -1
  4. package/deps/lcb/CONTRIBUTING.md +1 -1
  5. package/deps/lcb/README.markdown +2 -2
  6. package/deps/lcb/RELEASE_NOTES.markdown +99 -14
  7. package/deps/lcb/cmake/Modules/GetVersionInfo.cmake +1 -1
  8. package/deps/lcb/contrib/cbsasl/src/scram-sha/scram_utils.cc +22 -26
  9. package/deps/lcb/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp +20 -7
  10. package/deps/lcb/doc/Doxyfile +1 -1
  11. package/deps/lcb/example/CMakeLists.txt +4 -4
  12. package/deps/lcb/example/libuvdirect/main.c +39 -12
  13. package/deps/lcb/example/minimal/durability.cc +149 -0
  14. package/deps/lcb/example/minimal/query.c +11 -9
  15. package/deps/lcb/gyp_config/common/libcouchbase/configuration.h +3 -3
  16. package/deps/lcb/gyp_config/linux/arm64/config.h +243 -0
  17. package/deps/lcb/include/libcouchbase/couchbase.h +80 -5
  18. package/deps/lcb/include/libcouchbase/error.h +2 -0
  19. package/deps/lcb/include/libcouchbase/ixmgmt.h +15 -10
  20. package/deps/lcb/include/libcouchbase/tracing.h +2 -2
  21. package/deps/lcb/include/memcached/protocol_binary.h +21 -0
  22. package/deps/lcb/libcouchbase.gyp +347 -349
  23. package/deps/lcb/packaging/deb/control +1 -1
  24. package/deps/lcb/src/analytics/analytics_handle.cc +13 -5
  25. package/deps/lcb/src/analytics/analytics_handle.hh +29 -0
  26. package/deps/lcb/src/bootstrap.cc +6 -3
  27. package/deps/lcb/src/capi/cmd_analytics.cc +12 -1
  28. package/deps/lcb/src/capi/cmd_analytics.hh +30 -0
  29. package/deps/lcb/src/capi/cmd_counter.hh +23 -0
  30. package/deps/lcb/src/capi/cmd_exists.hh +24 -1
  31. package/deps/lcb/src/capi/cmd_get.hh +22 -0
  32. package/deps/lcb/src/capi/cmd_get_replica.hh +23 -0
  33. package/deps/lcb/src/capi/cmd_http.hh +7 -0
  34. package/deps/lcb/src/capi/cmd_query.cc +11 -1
  35. package/deps/lcb/src/capi/cmd_query.hh +31 -0
  36. package/deps/lcb/src/capi/cmd_remove.hh +23 -0
  37. package/deps/lcb/src/capi/cmd_search.cc +6 -0
  38. package/deps/lcb/src/capi/cmd_search.hh +23 -0
  39. package/deps/lcb/src/capi/cmd_store.hh +33 -21
  40. package/deps/lcb/src/capi/cmd_subdoc.hh +35 -0
  41. package/deps/lcb/src/capi/cmd_touch.hh +23 -0
  42. package/deps/lcb/src/capi/cmd_unlock.hh +23 -0
  43. package/deps/lcb/src/capi/cmd_view.hh +6 -0
  44. package/deps/lcb/src/capi/collection_qualifier.hh +2 -2
  45. package/deps/lcb/src/cntl.cc +45 -11
  46. package/deps/lcb/src/crypto.cc +2 -2
  47. package/deps/lcb/src/dns-srv.cc +5 -3
  48. package/deps/lcb/src/errmap.cc +5 -9
  49. package/deps/lcb/src/errmap.h +7 -3
  50. package/deps/lcb/src/handler.cc +24 -18
  51. package/deps/lcb/src/hostlist.h +2 -2
  52. package/deps/lcb/src/http/http-priv.h +2 -2
  53. package/deps/lcb/src/http/http.cc +5 -2
  54. package/deps/lcb/src/instance.cc +20 -11
  55. package/deps/lcb/src/internal.h +9 -0
  56. package/deps/lcb/src/lcbio/connect.cc +14 -2
  57. package/deps/lcb/src/lcbio/connect.h +2 -2
  58. package/deps/lcb/src/lcbio/ctx.cc +4 -2
  59. package/deps/lcb/src/lcbio/ioutils.cc +9 -10
  60. package/deps/lcb/src/lcbio/manager.cc +1 -1
  61. package/deps/lcb/src/mcserver/mcserver.cc +9 -6
  62. package/deps/lcb/src/mcserver/negotiate.cc +39 -17
  63. package/deps/lcb/src/n1ql/ixmgmt.cc +1 -2
  64. package/deps/lcb/src/n1ql/query_handle.cc +41 -19
  65. package/deps/lcb/src/n1ql/query_handle.hh +28 -1
  66. package/deps/lcb/src/operations/counter.cc +18 -5
  67. package/deps/lcb/src/operations/exists.cc +25 -4
  68. package/deps/lcb/src/operations/get.cc +39 -19
  69. package/deps/lcb/src/operations/get_replica.cc +28 -8
  70. package/deps/lcb/src/operations/observe.cc +1 -1
  71. package/deps/lcb/src/operations/ping.cc +8 -8
  72. package/deps/lcb/src/operations/pktfwd.cc +2 -1
  73. package/deps/lcb/src/operations/remove.cc +39 -22
  74. package/deps/lcb/src/operations/store.cc +18 -5
  75. package/deps/lcb/src/operations/subdoc.cc +18 -6
  76. package/deps/lcb/src/operations/touch.cc +34 -16
  77. package/deps/lcb/src/operations/unlock.cc +24 -5
  78. package/deps/lcb/src/packetutils.h +3 -2
  79. package/deps/lcb/src/retryq.cc +24 -5
  80. package/deps/lcb/src/search/search.cc +1 -0
  81. package/deps/lcb/src/search/search_handle.cc +30 -8
  82. package/deps/lcb/src/search/search_handle.hh +29 -0
  83. package/deps/lcb/src/settings.cc +1 -1
  84. package/deps/lcb/src/ssl/ssl_common.c +6 -7
  85. package/deps/lcb/src/tracing/span.cc +47 -14
  86. package/deps/lcb/src/tracing/tracer.cc +11 -2
  87. package/deps/lcb/src/tracing/tracing-internal.h +105 -93
  88. package/deps/lcb/src/utilities.cc +43 -0
  89. package/deps/lcb/src/utilities.h +53 -0
  90. package/deps/lcb/src/vbucket/vbucket.c +34 -33
  91. package/deps/lcb/src/views/view_handle.cc +13 -5
  92. package/deps/lcb/src/views/view_handle.hh +29 -0
  93. package/deps/lcb/tests/CMakeLists.txt +21 -0
  94. package/deps/lcb/tests/basic/t_ctlcodes.cc +24 -3
  95. package/deps/lcb/tests/basic/t_jsparse.cc +8 -0
  96. package/deps/lcb/tests/basic/t_n1qlstrings.cc +73 -0
  97. package/deps/lcb/tests/iotests/mock-environment.cc +30 -1
  98. package/deps/lcb/tests/iotests/mock-environment.h +49 -0
  99. package/deps/lcb/tests/iotests/mock-unit-test.cc +104 -6
  100. package/deps/lcb/tests/iotests/mock-unit-test.h +34 -0
  101. package/deps/lcb/tests/iotests/t_collections.cc +1 -1
  102. package/deps/lcb/tests/iotests/t_confmon.cc +4 -2
  103. package/deps/lcb/tests/iotests/t_get.cc +109 -7
  104. package/deps/lcb/tests/iotests/t_http.cc +9 -4
  105. package/deps/lcb/tests/iotests/t_lock.cc +18 -0
  106. package/deps/lcb/tests/iotests/t_mutate.cc +157 -63
  107. package/deps/lcb/tests/iotests/t_n1ql.cc +330 -33
  108. package/deps/lcb/tests/iotests/t_views.cc +1 -0
  109. package/deps/lcb/tests/iotests/testutil.cc +168 -0
  110. package/deps/lcb/tests/iotests/testutil.h +116 -0
  111. package/deps/lcb/tests/mocksupport/procutil.c +32 -28
  112. package/deps/lcb/tests/mocksupport/server.c +0 -1
  113. package/deps/lcb/tests/mocksupport/timeout.c +2 -2
  114. package/deps/lcb/tools/cbc.cc +7 -0
  115. package/dist/analyticsindexmanager.js +512 -524
  116. package/dist/binding.d.ts +3 -0
  117. package/dist/bindingutilities.js +4 -0
  118. package/dist/bucket.js +1 -1
  119. package/dist/bucketmanager.d.ts +31 -1
  120. package/dist/bucketmanager.js +194 -186
  121. package/dist/cluster.d.ts +7 -0
  122. package/dist/cluster.js +48 -38
  123. package/dist/collection.js +11 -17
  124. package/dist/collectionmanager.js +181 -197
  125. package/dist/connection.d.ts +3 -1
  126. package/dist/connection.js +27 -16
  127. package/dist/couchbase.d.ts +1 -0
  128. package/dist/couchbase.js +3 -13
  129. package/dist/datastructures.js +239 -310
  130. package/dist/diagnosticsexecutor.js +70 -85
  131. package/dist/errors.d.ts +70 -0
  132. package/dist/errors.js +96 -2
  133. package/dist/eventingfunctionmanager.d.ts +804 -0
  134. package/dist/eventingfunctionmanager.js +993 -0
  135. package/dist/httpexecutor.d.ts +2 -1
  136. package/dist/httpexecutor.js +30 -37
  137. package/dist/queryindexmanager.js +240 -266
  138. package/dist/scope.js +10 -4
  139. package/dist/sdspecs.d.ts +1 -1
  140. package/dist/searchexecutor.js +3 -0
  141. package/dist/searchindexmanager.js +240 -271
  142. package/dist/searchquery.d.ts +17 -0
  143. package/dist/searchquery.js +22 -1
  144. package/dist/searchtypes.d.ts +7 -2
  145. package/dist/searchtypes.js +2 -2
  146. package/dist/usermanager.js +251 -264
  147. package/dist/utilities.d.ts +2 -0
  148. package/dist/utilities.js +7 -2
  149. package/dist/viewexecutor.js +1 -1
  150. package/dist/viewindexmanager.js +131 -150
  151. package/package.json +1 -1
  152. package/src/addondata.cpp +58 -0
  153. package/src/addondata.h +40 -0
  154. package/src/binding.cpp +3 -1
  155. package/src/cas.h +2 -2
  156. package/src/connection.cpp +25 -178
  157. package/src/connection.h +8 -65
  158. package/src/connection_ops.cpp +57 -34
  159. package/src/constants.cpp +3 -0
  160. package/src/instance.cpp +235 -0
  161. package/src/instance.h +102 -0
  162. package/src/{connection_callbacks.cpp → instance_callbacks.cpp} +34 -34
  163. package/src/logger.cpp +11 -1
  164. package/src/logger.h +3 -0
  165. package/src/metrics.cpp +10 -0
  166. package/src/metrics.h +3 -0
  167. package/src/mutationtoken.h +2 -2
  168. package/src/opbuilder.h +13 -15
  169. package/src/respreader.cpp +1 -0
  170. package/src/respreader.h +6 -4
  171. package/src/tracespan.h +11 -11
  172. package/src/tracing.cpp +11 -0
  173. package/src/tracing.h +3 -0
  174. package/src/valueparser.h +5 -0
  175. package/deps/lcb/example/observe/durability.c +0 -110
@@ -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.name,
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(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: 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: 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;
@@ -68,4 +68,6 @@ export declare function nsServerStrToDuraLevel(level: string): DurabilityLevel;
68
68
  */
69
69
  export declare function cbQsStringify(values: {
70
70
  [key: string]: any;
71
+ }, options?: {
72
+ boolAsString?: boolean;
71
73
  }): string;
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
- cbValues[i] = values[i] ? 1 : 0;
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];