couchbase 4.4.3 → 4.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. package/BUILDING.md +182 -0
  2. package/CMakeLists.txt +11 -0
  3. package/CONTRIBUTING.md +1 -1
  4. package/README.md +4 -2
  5. package/deps/couchbase-cxx-cache/boringssl/e31ea00c1ea52052d2d78d44006cc88c80fa24a9/boringssl/src/BUILDING.md +206 -0
  6. package/deps/couchbase-cxx-client/CMakeLists.txt +3 -1
  7. package/deps/couchbase-cxx-client/README.md +2 -2
  8. package/deps/couchbase-cxx-client/cmake/APKBUILD.in +54 -0
  9. package/deps/couchbase-cxx-client/cmake/CompilerWarnings.cmake +0 -5
  10. package/deps/couchbase-cxx-client/cmake/Packaging.cmake +174 -11
  11. package/deps/couchbase-cxx-client/cmake/RPath.cmake +10 -0
  12. package/deps/couchbase-cxx-client/cmake/VersionInfo.cmake +4 -0
  13. package/deps/couchbase-cxx-client/cmake/build_version.hxx.in +1 -0
  14. package/deps/couchbase-cxx-client/cmake/couchbase-cxx-client.spec.in +2 -2
  15. package/deps/couchbase-cxx-client/cmake/couchbase_cxx_client.pc.in +2 -2
  16. package/deps/couchbase-cxx-client/cmake/debian/changelog.in +5 -0
  17. package/deps/couchbase-cxx-client/cmake/debian/compat +1 -0
  18. package/deps/couchbase-cxx-client/cmake/debian/control +40 -0
  19. package/deps/couchbase-cxx-client/cmake/debian/rules +41 -0
  20. package/deps/couchbase-cxx-client/cmake/debian/source/format +1 -0
  21. package/deps/couchbase-cxx-client/core/impl/analytics.cxx +1 -0
  22. package/deps/couchbase-cxx-client/core/impl/collection.cxx +27 -3
  23. package/deps/couchbase-cxx-client/core/impl/error.cxx +24 -3
  24. package/deps/couchbase-cxx-client/core/impl/get_replica.hxx +2 -0
  25. package/deps/couchbase-cxx-client/core/impl/lookup_in_replica.hxx +2 -0
  26. package/deps/couchbase-cxx-client/core/impl/observe_seqno.hxx +2 -0
  27. package/deps/couchbase-cxx-client/core/impl/query.cxx +1 -0
  28. package/deps/couchbase-cxx-client/core/impl/search.cxx +2 -0
  29. package/deps/couchbase-cxx-client/core/io/http_command.hxx +2 -2
  30. package/deps/couchbase-cxx-client/core/io/mcbp_command.hxx +1 -1
  31. package/deps/couchbase-cxx-client/core/meta/features.hxx +11 -0
  32. package/deps/couchbase-cxx-client/core/meta/version.cxx +47 -6
  33. package/deps/couchbase-cxx-client/core/operations/document_analytics.cxx +23 -17
  34. package/deps/couchbase-cxx-client/core/operations/document_analytics.hxx +1 -0
  35. package/deps/couchbase-cxx-client/core/operations/document_append.hxx +2 -0
  36. package/deps/couchbase-cxx-client/core/operations/document_decrement.hxx +2 -0
  37. package/deps/couchbase-cxx-client/core/operations/document_exists.hxx +2 -0
  38. package/deps/couchbase-cxx-client/core/operations/document_get.hxx +2 -0
  39. package/deps/couchbase-cxx-client/core/operations/document_get_all_replicas.hxx +2 -0
  40. package/deps/couchbase-cxx-client/core/operations/document_get_and_lock.hxx +2 -0
  41. package/deps/couchbase-cxx-client/core/operations/document_get_and_touch.hxx +2 -0
  42. package/deps/couchbase-cxx-client/core/operations/document_get_any_replica.hxx +2 -0
  43. package/deps/couchbase-cxx-client/core/operations/document_get_projected.hxx +2 -0
  44. package/deps/couchbase-cxx-client/core/operations/document_increment.hxx +2 -0
  45. package/deps/couchbase-cxx-client/core/operations/document_insert.hxx +2 -0
  46. package/deps/couchbase-cxx-client/core/operations/document_lookup_in.hxx +2 -0
  47. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_all_replicas.hxx +2 -0
  48. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_any_replica.hxx +2 -0
  49. package/deps/couchbase-cxx-client/core/operations/document_mutate_in.hxx +2 -0
  50. package/deps/couchbase-cxx-client/core/operations/document_prepend.hxx +2 -0
  51. package/deps/couchbase-cxx-client/core/operations/document_query.hxx +1 -0
  52. package/deps/couchbase-cxx-client/core/operations/document_remove.hxx +2 -0
  53. package/deps/couchbase-cxx-client/core/operations/document_replace.hxx +2 -0
  54. package/deps/couchbase-cxx-client/core/operations/document_search.hxx +1 -0
  55. package/deps/couchbase-cxx-client/core/operations/document_touch.hxx +2 -0
  56. package/deps/couchbase-cxx-client/core/operations/document_unlock.hxx +2 -0
  57. package/deps/couchbase-cxx-client/core/operations/document_upsert.hxx +2 -0
  58. package/deps/couchbase-cxx-client/core/operations/document_view.hxx +1 -0
  59. package/deps/couchbase-cxx-client/core/operations/http_noop.hxx +2 -0
  60. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_create.hxx +1 -0
  61. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_drop.hxx +1 -0
  62. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_get_all.hxx +1 -0
  63. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataverse_create.hxx +1 -0
  64. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataverse_drop.hxx +1 -0
  65. package/deps/couchbase-cxx-client/core/operations/management/analytics_get_pending_mutations.hxx +2 -0
  66. package/deps/couchbase-cxx-client/core/operations/management/analytics_index_create.hxx +1 -0
  67. package/deps/couchbase-cxx-client/core/operations/management/analytics_index_drop.hxx +1 -0
  68. package/deps/couchbase-cxx-client/core/operations/management/analytics_index_get_all.hxx +1 -0
  69. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_connect.hxx +1 -0
  70. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_create.hxx +1 -0
  71. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_disconnect.hxx +1 -0
  72. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_drop.hxx +1 -0
  73. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_get_all.cxx +23 -15
  74. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_get_all.hxx +4 -3
  75. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_replace.hxx +1 -0
  76. package/deps/couchbase-cxx-client/core/operations/management/bucket_create.hxx +1 -0
  77. package/deps/couchbase-cxx-client/core/operations/management/bucket_describe.hxx +1 -0
  78. package/deps/couchbase-cxx-client/core/operations/management/bucket_drop.hxx +1 -0
  79. package/deps/couchbase-cxx-client/core/operations/management/bucket_flush.hxx +1 -0
  80. package/deps/couchbase-cxx-client/core/operations/management/bucket_get.hxx +1 -0
  81. package/deps/couchbase-cxx-client/core/operations/management/bucket_get_all.hxx +1 -0
  82. package/deps/couchbase-cxx-client/core/operations/management/bucket_update.hxx +1 -0
  83. package/deps/couchbase-cxx-client/core/operations/management/change_password.hxx +1 -0
  84. package/deps/couchbase-cxx-client/core/operations/management/cluster_describe.hxx +1 -0
  85. package/deps/couchbase-cxx-client/core/operations/management/cluster_developer_preview_enable.hxx +1 -0
  86. package/deps/couchbase-cxx-client/core/operations/management/collection_create.hxx +2 -0
  87. package/deps/couchbase-cxx-client/core/operations/management/collection_drop.hxx +1 -0
  88. package/deps/couchbase-cxx-client/core/operations/management/collection_update.hxx +2 -0
  89. package/deps/couchbase-cxx-client/core/operations/management/collections_manifest_get.hxx +2 -0
  90. package/deps/couchbase-cxx-client/core/operations/management/eventing_deploy_function.hxx +3 -2
  91. package/deps/couchbase-cxx-client/core/operations/management/eventing_drop_function.hxx +3 -2
  92. package/deps/couchbase-cxx-client/core/operations/management/eventing_get_all_functions.hxx +3 -2
  93. package/deps/couchbase-cxx-client/core/operations/management/eventing_get_function.hxx +3 -2
  94. package/deps/couchbase-cxx-client/core/operations/management/eventing_get_status.hxx +3 -2
  95. package/deps/couchbase-cxx-client/core/operations/management/eventing_pause_function.hxx +3 -2
  96. package/deps/couchbase-cxx-client/core/operations/management/eventing_resume_function.hxx +3 -2
  97. package/deps/couchbase-cxx-client/core/operations/management/eventing_undeploy_function.hxx +3 -2
  98. package/deps/couchbase-cxx-client/core/operations/management/eventing_upsert_function.hxx +3 -2
  99. package/deps/couchbase-cxx-client/core/operations/management/freeform.hxx +2 -0
  100. package/deps/couchbase-cxx-client/core/operations/management/group_drop.hxx +1 -0
  101. package/deps/couchbase-cxx-client/core/operations/management/group_get.hxx +1 -0
  102. package/deps/couchbase-cxx-client/core/operations/management/group_get_all.hxx +1 -0
  103. package/deps/couchbase-cxx-client/core/operations/management/group_upsert.hxx +1 -0
  104. package/deps/couchbase-cxx-client/core/operations/management/query_index_build.hxx +2 -0
  105. package/deps/couchbase-cxx-client/core/operations/management/query_index_build_deferred.hxx +3 -0
  106. package/deps/couchbase-cxx-client/core/operations/management/query_index_create.hxx +1 -0
  107. package/deps/couchbase-cxx-client/core/operations/management/query_index_drop.hxx +1 -0
  108. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all.hxx +2 -0
  109. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all_deferred.hxx +3 -0
  110. package/deps/couchbase-cxx-client/core/operations/management/role_get_all.hxx +1 -0
  111. package/deps/couchbase-cxx-client/core/operations/management/scope_create.hxx +1 -0
  112. package/deps/couchbase-cxx-client/core/operations/management/scope_drop.hxx +1 -0
  113. package/deps/couchbase-cxx-client/core/operations/management/scope_get_all.hxx +1 -0
  114. package/deps/couchbase-cxx-client/core/operations/management/search_get_stats.hxx +1 -0
  115. package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.hxx +1 -0
  116. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.hxx +1 -0
  117. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.hxx +1 -0
  118. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.hxx +1 -0
  119. package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.hxx +1 -0
  120. package/deps/couchbase-cxx-client/core/operations/management/search_index_get.hxx +1 -0
  121. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.hxx +1 -0
  122. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.hxx +2 -0
  123. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_stats.hxx +1 -0
  124. package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.hxx +1 -0
  125. package/deps/couchbase-cxx-client/core/operations/management/user_drop.hxx +1 -0
  126. package/deps/couchbase-cxx-client/core/operations/management/user_get.hxx +1 -0
  127. package/deps/couchbase-cxx-client/core/operations/management/user_get_all.hxx +1 -0
  128. package/deps/couchbase-cxx-client/core/operations/management/user_upsert.cxx +3 -3
  129. package/deps/couchbase-cxx-client/core/operations/management/user_upsert.hxx +1 -0
  130. package/deps/couchbase-cxx-client/core/operations/management/view_index_drop.hxx +1 -0
  131. package/deps/couchbase-cxx-client/core/operations/management/view_index_get.hxx +1 -0
  132. package/deps/couchbase-cxx-client/core/operations/management/view_index_get_all.hxx +2 -0
  133. package/deps/couchbase-cxx-client/core/operations/management/view_index_upsert.hxx +1 -0
  134. package/deps/couchbase-cxx-client/core/transactions/async_attempt_context.hxx +9 -21
  135. package/deps/couchbase-cxx-client/core/transactions/attempt_context.hxx +6 -33
  136. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.cxx +41 -41
  137. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.hxx +15 -16
  138. package/deps/couchbase-cxx-client/core/transactions/transaction_context.cxx +2 -2
  139. package/deps/couchbase-cxx-client/core/transactions/transaction_get_result.hxx +0 -20
  140. package/deps/couchbase-cxx-client/couchbase/common_options.hxx +16 -1
  141. package/deps/couchbase-cxx-client/couchbase/metrics/otel_meter.hxx +16 -20
  142. package/dist/analyticsindexmanager.d.ts +98 -14
  143. package/dist/analyticsindexmanager.js +452 -411
  144. package/dist/binding.d.ts +53 -4
  145. package/dist/bindingutilities.d.ts +26 -1
  146. package/dist/bindingutilities.js +108 -1
  147. package/dist/couchbase.d.ts +3 -1
  148. package/dist/couchbase.js +2 -0
  149. package/dist/rangeScan.d.ts +1 -1
  150. package/dist/rangeScan.js +1 -1
  151. package/dist/transactions.d.ts +34 -3
  152. package/dist/transactions.js +25 -18
  153. package/dist/transcoders.d.ts +68 -0
  154. package/dist/transcoders.js +194 -1
  155. package/dist/usermanager.d.ts +14 -14
  156. package/dist/usermanager.js +178 -228
  157. package/dist/utilities.js +4 -6
  158. package/dist/utilities_internal.js +1 -2
  159. package/package.json +9 -8
  160. package/src/connection.cpp +22 -0
  161. package/src/connection.hpp +12 -0
  162. package/src/connection_autogen.cpp +100 -0
  163. package/src/jstocbpp_autogen.hpp +315 -8
  164. package/src/jstocbpp_transactions.hpp +1 -2
  165. package/tools/gen-bindings-js.js +38 -3
  166. package/tools/gen-bindings-json.py +575 -328
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UserManager = exports.Group = exports.UserAndMetadata = exports.User = exports.RoleAndOrigin = exports.RoleAndDescription = exports.Role = exports.Origin = void 0;
4
- const errors_1 = require("./errors");
5
- const httpexecutor_1 = require("./httpexecutor");
4
+ const bindingutilities_1 = require("./bindingutilities");
6
5
  const utilities_1 = require("./utilities");
7
6
  /**
8
7
  * Contains information about an origin for a role.
@@ -20,7 +19,7 @@ class Origin {
20
19
  /**
21
20
  * @internal
22
21
  */
23
- static _fromNsData(data) {
22
+ static _fromCppData(data) {
24
23
  return new Origin({
25
24
  type: data.type,
26
25
  name: data.name,
@@ -46,33 +45,24 @@ class Role {
46
45
  /**
47
46
  * @internal
48
47
  */
49
- static _fromNsData(data) {
48
+ static _fromCppData(data) {
50
49
  return new Role({
51
- name: data.role,
52
- bucket: data.bucket_name,
53
- scope: data.scope_name,
54
- collection: data.collection_name,
50
+ name: data.name,
51
+ bucket: data.bucket,
52
+ scope: data.scope,
53
+ collection: data.collection,
55
54
  });
56
55
  }
57
56
  /**
58
57
  * @internal
59
58
  */
60
- static _toNsStr(role) {
61
- if (typeof role === 'string') {
62
- return role;
63
- }
64
- if (role.bucket && role.scope && role.collection) {
65
- return `${role.name}[${role.bucket}:${role.scope}:${role.collection}]`;
66
- }
67
- else if (role.bucket && role.scope) {
68
- return `${role.name}[${role.bucket}:${role.scope}]`;
69
- }
70
- else if (role.bucket) {
71
- return `${role.name}[${role.bucket}]`;
72
- }
73
- else {
74
- return role.name;
75
- }
59
+ static _toCppData(data) {
60
+ return {
61
+ name: data.name,
62
+ bucket: data.bucket,
63
+ scope: data.scope,
64
+ collection: data.collection,
65
+ };
76
66
  }
77
67
  }
78
68
  exports.Role = Role;
@@ -93,9 +83,10 @@ class RoleAndDescription extends Role {
93
83
  /**
94
84
  * @internal
95
85
  */
96
- static _fromNsData(data) {
86
+ static _fromCppData(data) {
87
+ const role = Role._fromCppData(data);
97
88
  return new RoleAndDescription({
98
- ...Role._fromNsData(data),
89
+ ...role,
99
90
  displayName: data.name,
100
91
  description: data.description,
101
92
  });
@@ -118,16 +109,15 @@ class RoleAndOrigin extends Role {
118
109
  /**
119
110
  * @internal
120
111
  */
121
- static _fromNsData(data) {
122
- let origins;
123
- if (data.origins) {
124
- origins = data.origins.map((originData) => Origin._fromNsData(originData));
125
- }
126
- else {
127
- origins = [];
128
- }
112
+ static _fromCppData(data) {
113
+ const origins = data.origins.map((origin) => Origin._fromCppData(origin));
129
114
  return new RoleAndOrigin({
130
- ...Role._fromNsData(data),
115
+ ...Role._fromCppData({
116
+ name: data.name,
117
+ bucket: data.bucket,
118
+ scope: data.scope,
119
+ collection: data.collection,
120
+ }),
131
121
  origins,
132
122
  });
133
123
  }
@@ -151,48 +141,38 @@ class User {
151
141
  /**
152
142
  * @internal
153
143
  */
154
- static _fromNsData(data) {
155
- let roles;
156
- if (data.roles) {
157
- roles = data.roles
158
- .filter((roleData) => {
159
- // Check whether or not this role has originated from the user directly
160
- // or whether it was through a group.
161
- if (!roleData.origins || roleData.origins.length === 0) {
162
- return false;
163
- }
164
- return !!roleData.origins.find((originData) => originData.type === 'user');
165
- })
166
- .map((roleData) => Role._fromNsData(roleData));
167
- }
168
- else {
169
- roles = [];
170
- }
144
+ static _fromCppData(data) {
171
145
  return new User({
172
- username: data.id,
173
- displayName: data.name,
146
+ username: data.username,
147
+ displayName: data.display_name,
174
148
  groups: data.groups,
175
- roles: roles,
149
+ roles: data.roles.map((role) => Role._fromCppData(role)),
176
150
  password: undefined,
177
151
  });
178
152
  }
179
153
  /**
180
154
  * @internal
181
155
  */
182
- static _toNsData(user) {
183
- let groups = undefined;
184
- if (user.groups && user.groups.length > 0) {
185
- groups = user.groups;
186
- }
187
- let roles = undefined;
188
- if (user.roles && user.roles.length > 0) {
189
- roles = user.roles.map((role) => Role._toNsStr(role)).join(',');
156
+ static _toCppData(data) {
157
+ const roles = [];
158
+ if (data.roles) {
159
+ data.roles.forEach((role) => {
160
+ if (typeof role === 'string') {
161
+ roles.push({
162
+ name: role,
163
+ });
164
+ }
165
+ else {
166
+ roles.push(Role._toCppData(role));
167
+ }
168
+ });
190
169
  }
191
170
  return {
192
- name: user.displayName,
193
- groups: groups,
194
- password: user.password,
171
+ username: data.username,
172
+ display_name: data.displayName,
173
+ groups: data.groups ? data.groups : [],
195
174
  roles: roles,
175
+ password: data.password,
196
176
  };
197
177
  }
198
178
  }
@@ -226,20 +206,23 @@ class UserAndMetadata extends User {
226
206
  /**
227
207
  * @internal
228
208
  */
229
- static _fromNsData(data) {
230
- let effectiveRoles;
231
- if (data.roles) {
232
- effectiveRoles = data.roles.map((roleData) => RoleAndOrigin._fromNsData(roleData));
233
- }
234
- else {
235
- effectiveRoles = [];
236
- }
209
+ static _fromCppData(data) {
210
+ const user = User._fromCppData({
211
+ username: data.username,
212
+ display_name: data.display_name,
213
+ groups: data.groups,
214
+ roles: data.roles,
215
+ password: data.password,
216
+ });
217
+ const effectiveRoles = data.effective_roles.map((erole) => RoleAndOrigin._fromCppData(erole));
237
218
  return new UserAndMetadata({
238
- ...User._fromNsData(data),
239
- domain: data.domain,
219
+ ...user,
220
+ domain: (0, bindingutilities_1.authDomainFromCpp)(data.domain),
240
221
  effectiveRoles: effectiveRoles,
241
222
  effectiveRolesAndOrigins: effectiveRoles,
242
- passwordChanged: new Date(data.password_change_date),
223
+ passwordChanged: data.password_changed
224
+ ? new Date(data.password_changed)
225
+ : undefined,
243
226
  externalGroups: data.external_groups,
244
227
  });
245
228
  }
@@ -263,33 +246,36 @@ class Group {
263
246
  /**
264
247
  * @internal
265
248
  */
266
- static _fromNsData(data) {
267
- let roles;
268
- if (data.roles) {
269
- roles = data.roles.map((roleData) => Role._fromNsData(roleData));
270
- }
271
- else {
272
- roles = [];
273
- }
249
+ static _fromCppData(data) {
274
250
  return new Group({
275
- name: data.id,
276
- description: data.description,
277
- roles: roles,
251
+ name: data.name,
252
+ description: data.description || '',
253
+ roles: data.roles.map((role) => Role._fromCppData(role)),
278
254
  ldapGroupReference: data.ldap_group_reference,
279
255
  });
280
256
  }
281
257
  /**
282
258
  * @internal
283
259
  */
284
- static _toNsData(group) {
285
- let roles = undefined;
286
- if (group.roles && group.roles.length > 0) {
287
- roles = group.roles.map((role) => Role._toNsStr(role)).join(',');
260
+ static _toCppData(data) {
261
+ const roles = [];
262
+ if (data.roles) {
263
+ data.roles.forEach((role) => {
264
+ if (typeof role === 'string') {
265
+ roles.push({
266
+ name: role,
267
+ });
268
+ }
269
+ else {
270
+ roles.push(Role._toCppData(role));
271
+ }
272
+ });
288
273
  }
289
274
  return {
290
- description: group.description,
275
+ name: data.name,
276
+ description: data.description,
291
277
  roles: roles,
292
- ldap_group_reference: group.ldapGroupReference,
278
+ ldap_group_reference: data.ldapGroupReference,
293
279
  };
294
280
  }
295
281
  }
@@ -307,9 +293,6 @@ class UserManager {
307
293
  constructor(cluster) {
308
294
  this._cluster = cluster;
309
295
  }
310
- get _http() {
311
- return new httpexecutor_1.HttpExecutor(this._cluster.conn);
312
- }
313
296
  /**
314
297
  * Returns a specific user by their username.
315
298
  *
@@ -325,24 +308,20 @@ class UserManager {
325
308
  if (!options) {
326
309
  options = {};
327
310
  }
328
- const domainName = options.domainName || 'local';
311
+ const cppDomain = (0, bindingutilities_1.authDomainToCpp)(options.domainName || 'local');
329
312
  const timeout = options.timeout || this._cluster.managementTimeout;
330
- return utilities_1.PromiseHelper.wrapAsync(async () => {
331
- const res = await this._http.request({
332
- type: httpexecutor_1.HttpServiceType.Management,
333
- method: httpexecutor_1.HttpMethod.Get,
334
- path: `/settings/rbac/users/${domainName}/${username}`,
313
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
314
+ this._cluster.conn.managementUserGet({
315
+ username: username,
316
+ domain: cppDomain,
335
317
  timeout: timeout,
336
- });
337
- if (res.statusCode !== 200) {
338
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
339
- if (res.statusCode === 404) {
340
- throw new errors_1.UserNotFoundError(undefined, errCtx);
318
+ }, (cppErr, resp) => {
319
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
320
+ if (err) {
321
+ return wrapCallback(err, null);
341
322
  }
342
- throw new errors_1.CouchbaseError('failed to get the user', undefined, errCtx);
343
- }
344
- const userData = JSON.parse(res.body.toString());
345
- return UserAndMetadata._fromNsData(userData);
323
+ wrapCallback(null, UserAndMetadata._fromCppData(resp.user));
324
+ });
346
325
  }, callback);
347
326
  }
348
327
  /**
@@ -359,22 +338,20 @@ class UserManager {
359
338
  if (!options) {
360
339
  options = {};
361
340
  }
362
- const domainName = options.domainName || 'local';
341
+ const cppDomain = (0, bindingutilities_1.authDomainToCpp)(options.domainName || 'local');
363
342
  const timeout = options.timeout || this._cluster.managementTimeout;
364
- return utilities_1.PromiseHelper.wrapAsync(async () => {
365
- const res = await this._http.request({
366
- type: httpexecutor_1.HttpServiceType.Management,
367
- method: httpexecutor_1.HttpMethod.Get,
368
- path: `/settings/rbac/users/${domainName}`,
343
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
344
+ this._cluster.conn.managementUserGetAll({
345
+ domain: cppDomain,
369
346
  timeout: timeout,
347
+ }, (cppErr, resp) => {
348
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
349
+ if (err) {
350
+ return wrapCallback(err, null);
351
+ }
352
+ const users = resp.users.map((user) => UserAndMetadata._fromCppData(user));
353
+ wrapCallback(null, users);
370
354
  });
371
- if (res.statusCode !== 200) {
372
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
373
- throw new errors_1.CouchbaseError('failed to get users', undefined, errCtx);
374
- }
375
- const usersData = JSON.parse(res.body.toString());
376
- const users = usersData.map((userData) => UserAndMetadata._fromNsData(userData));
377
- return users;
378
355
  }, callback);
379
356
  }
380
357
  /**
@@ -392,22 +369,20 @@ class UserManager {
392
369
  if (!options) {
393
370
  options = {};
394
371
  }
395
- const domainName = options.domainName || 'local';
372
+ const cppDomain = (0, bindingutilities_1.authDomainToCpp)(options.domainName || 'local');
396
373
  const timeout = options.timeout || this._cluster.managementTimeout;
397
- return utilities_1.PromiseHelper.wrapAsync(async () => {
398
- const userData = User._toNsData(user);
399
- const res = await this._http.request({
400
- type: httpexecutor_1.HttpServiceType.Management,
401
- method: httpexecutor_1.HttpMethod.Put,
402
- path: `/settings/rbac/users/${domainName}/${user.username}`,
403
- contentType: 'application/x-www-form-urlencoded',
404
- body: (0, utilities_1.cbQsStringify)(userData),
374
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
375
+ this._cluster.conn.managementUserUpsert({
376
+ user: User._toCppData(user),
377
+ domain: cppDomain,
405
378
  timeout: timeout,
379
+ }, (cppErr) => {
380
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
381
+ if (err) {
382
+ return wrapCallback(err, null);
383
+ }
384
+ wrapCallback(err);
406
385
  });
407
- if (res.statusCode !== 200) {
408
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
409
- throw new errors_1.CouchbaseError('failed to upsert user', undefined, errCtx);
410
- }
411
386
  }, callback);
412
387
  }
413
388
  /**
@@ -426,23 +401,17 @@ class UserManager {
426
401
  options = {};
427
402
  }
428
403
  const timeout = options.timeout || this._cluster.managementTimeout;
429
- return utilities_1.PromiseHelper.wrapAsync(async () => {
430
- const passwordData = { password: newPassword };
431
- const res = await this._http.request({
432
- type: httpexecutor_1.HttpServiceType.Management,
433
- method: httpexecutor_1.HttpMethod.Post,
434
- path: `/controller/changePassword`,
435
- contentType: 'application/x-www-form-urlencoded',
436
- body: (0, utilities_1.cbQsStringify)(passwordData),
404
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
405
+ this._cluster.conn.managementChangePassword({
406
+ newPassword: newPassword,
437
407
  timeout: timeout,
438
- });
439
- if (res.statusCode !== 200) {
440
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
441
- if (res.statusCode === 404) {
442
- throw new errors_1.UserNotFoundError(undefined, errCtx);
408
+ }, (cppErr) => {
409
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
410
+ if (err) {
411
+ return wrapCallback(err, null);
443
412
  }
444
- throw new errors_1.CouchbaseError('failed to change password for the current user', undefined, errCtx);
445
- }
413
+ wrapCallback(err);
414
+ });
446
415
  }, callback);
447
416
  }
448
417
  /**
@@ -460,22 +429,20 @@ class UserManager {
460
429
  if (!options) {
461
430
  options = {};
462
431
  }
463
- const domainName = options.domainName || 'local';
432
+ const cppDomain = (0, bindingutilities_1.authDomainToCpp)(options.domainName || 'local');
464
433
  const timeout = options.timeout || this._cluster.managementTimeout;
465
- return utilities_1.PromiseHelper.wrapAsync(async () => {
466
- const res = await this._http.request({
467
- type: httpexecutor_1.HttpServiceType.Management,
468
- method: httpexecutor_1.HttpMethod.Delete,
469
- path: `/settings/rbac/users/${domainName}/${username}`,
434
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
435
+ this._cluster.conn.managementUserDrop({
436
+ username: username,
437
+ domain: cppDomain,
470
438
  timeout: timeout,
471
- });
472
- if (res.statusCode !== 200) {
473
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
474
- if (res.statusCode === 404) {
475
- throw new errors_1.UserNotFoundError(undefined, errCtx);
439
+ }, (cppErr) => {
440
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
441
+ if (err) {
442
+ return wrapCallback(err, null);
476
443
  }
477
- throw new errors_1.CouchbaseError('failed to drop the user', undefined, errCtx);
478
- }
444
+ wrapCallback(err);
445
+ });
479
446
  }, callback);
480
447
  }
481
448
  /**
@@ -493,20 +460,17 @@ class UserManager {
493
460
  options = {};
494
461
  }
495
462
  const timeout = options.timeout || this._cluster.managementTimeout;
496
- return utilities_1.PromiseHelper.wrapAsync(async () => {
497
- const res = await this._http.request({
498
- type: httpexecutor_1.HttpServiceType.Management,
499
- method: httpexecutor_1.HttpMethod.Get,
500
- path: `/settings/rbac/roles`,
463
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
464
+ this._cluster.conn.managementRoleGetAll({
501
465
  timeout: timeout,
466
+ }, (cppErr, resp) => {
467
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
468
+ if (err) {
469
+ return wrapCallback(err, null);
470
+ }
471
+ const roles = resp.roles.map((role) => Role._fromCppData(role));
472
+ wrapCallback(null, roles);
502
473
  });
503
- if (res.statusCode !== 200) {
504
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
505
- throw new errors_1.CouchbaseError('failed to get roles', undefined, errCtx);
506
- }
507
- const rolesData = JSON.parse(res.body.toString());
508
- const roles = rolesData.map((roleData) => RoleAndDescription._fromNsData(roleData));
509
- return roles;
510
474
  }, callback);
511
475
  }
512
476
  /**
@@ -525,22 +489,17 @@ class UserManager {
525
489
  options = {};
526
490
  }
527
491
  const timeout = options.timeout || this._cluster.managementTimeout;
528
- return utilities_1.PromiseHelper.wrapAsync(async () => {
529
- const res = await this._http.request({
530
- type: httpexecutor_1.HttpServiceType.Management,
531
- method: httpexecutor_1.HttpMethod.Get,
532
- path: `/settings/rbac/groups/${groupName}`,
492
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
493
+ this._cluster.conn.managementGroupGet({
494
+ name: groupName,
533
495
  timeout: timeout,
534
- });
535
- if (res.statusCode !== 200) {
536
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
537
- if (res.statusCode === 404) {
538
- throw new errors_1.GroupNotFoundError(undefined, errCtx);
496
+ }, (cppErr, resp) => {
497
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
498
+ if (err) {
499
+ return wrapCallback(err, null);
539
500
  }
540
- throw new errors_1.CouchbaseError('failed to get the group', undefined, errCtx);
541
- }
542
- const groupData = JSON.parse(res.body.toString());
543
- return Group._fromNsData(groupData);
501
+ wrapCallback(null, Group._fromCppData(resp.group));
502
+ });
544
503
  }, callback);
545
504
  }
546
505
  /**
@@ -558,20 +517,17 @@ class UserManager {
558
517
  options = {};
559
518
  }
560
519
  const timeout = options.timeout || this._cluster.managementTimeout;
561
- return utilities_1.PromiseHelper.wrapAsync(async () => {
562
- const res = await this._http.request({
563
- type: httpexecutor_1.HttpServiceType.Management,
564
- method: httpexecutor_1.HttpMethod.Get,
565
- path: `/settings/rbac/groups`,
520
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
521
+ this._cluster.conn.managementGroupGetAll({
566
522
  timeout: timeout,
523
+ }, (cppErr, resp) => {
524
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
525
+ if (err) {
526
+ return wrapCallback(err, null);
527
+ }
528
+ const groups = resp.groups.map((group) => Group._fromCppData(group));
529
+ wrapCallback(null, groups);
567
530
  });
568
- if (res.statusCode !== 200) {
569
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
570
- throw new errors_1.CouchbaseError('failed to get groups', undefined, errCtx);
571
- }
572
- const groupsData = JSON.parse(res.body.toString());
573
- const groups = groupsData.map((groupData) => Group._fromNsData(groupData));
574
- return groups;
575
531
  }, callback);
576
532
  }
577
533
  /**
@@ -590,20 +546,17 @@ class UserManager {
590
546
  options = {};
591
547
  }
592
548
  const timeout = options.timeout || this._cluster.managementTimeout;
593
- return utilities_1.PromiseHelper.wrapAsync(async () => {
594
- const groupData = Group._toNsData(group);
595
- const res = await this._http.request({
596
- type: httpexecutor_1.HttpServiceType.Management,
597
- method: httpexecutor_1.HttpMethod.Put,
598
- path: `/settings/rbac/groups/${group.name}`,
599
- contentType: 'application/x-www-form-urlencoded',
600
- body: (0, utilities_1.cbQsStringify)(groupData),
549
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
550
+ this._cluster.conn.managementGroupUpsert({
551
+ group: Group._toCppData(group),
601
552
  timeout: timeout,
553
+ }, (cppErr) => {
554
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
555
+ if (err) {
556
+ return wrapCallback(err, null);
557
+ }
558
+ wrapCallback(err);
602
559
  });
603
- if (res.statusCode !== 200) {
604
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
605
- throw new errors_1.CouchbaseError('failed to upsert group', undefined, errCtx);
606
- }
607
560
  }, callback);
608
561
  }
609
562
  /**
@@ -622,20 +575,17 @@ class UserManager {
622
575
  options = {};
623
576
  }
624
577
  const timeout = options.timeout || this._cluster.managementTimeout;
625
- return utilities_1.PromiseHelper.wrapAsync(async () => {
626
- const res = await this._http.request({
627
- type: httpexecutor_1.HttpServiceType.Management,
628
- method: httpexecutor_1.HttpMethod.Delete,
629
- path: `/settings/rbac/groups/${groupName}`,
578
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
579
+ this._cluster.conn.managementGroupDrop({
580
+ name: groupName,
630
581
  timeout: timeout,
631
- });
632
- if (res.statusCode !== 200) {
633
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
634
- if (res.statusCode === 404) {
635
- throw new errors_1.GroupNotFoundError(undefined, errCtx);
582
+ }, (cppErr) => {
583
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
584
+ if (err) {
585
+ return wrapCallback(err, null);
636
586
  }
637
- throw new errors_1.CouchbaseError('failed to drop the group', undefined, errCtx);
638
- }
587
+ wrapCallback(err);
588
+ });
639
589
  }, callback);
640
590
  }
641
591
  }
package/dist/utilities.js CHANGED
@@ -40,9 +40,8 @@ class PromiseHelper {
40
40
  // callback specified. We directly return the promise.
41
41
  if (callback) {
42
42
  const prom = fn();
43
- prom
44
- .then((res) => callback(null, res))
45
- .catch((err) => callback(err, null));
43
+ prom.then((res) => callback(null, res));
44
+ prom.catch((err) => callback(err, null));
46
45
  return prom;
47
46
  }
48
47
  return fn();
@@ -62,9 +61,8 @@ class PromiseHelper {
62
61
  });
63
62
  });
64
63
  if (callback) {
65
- prom
66
- .then((res) => callback(null, res))
67
- .catch((err) => callback(err, null));
64
+ prom.then((res) => callback(null, res));
65
+ prom.catch((err) => callback(err, null));
68
66
  }
69
67
  return prom;
70
68
  }
@@ -9,10 +9,9 @@ function generateClientString() {
9
9
  // off as some Node.js versions insert strange characters into
10
10
  // the version identifiers (mainly newlines and such).
11
11
  /* eslint-disable-next-line @typescript-eslint/no-var-requires */
12
- const couchnodeVer = require('../package.json').version.trim();
13
12
  const nodeVer = process.versions.node.trim();
14
13
  const v8Ver = process.versions.v8.trim();
15
14
  const sslVer = process.versions.openssl.trim();
16
- return `couchnode/${couchnodeVer} (node/${nodeVer}; v8/${v8Ver}; ssl/${sslVer})`;
15
+ return `node/${nodeVer}; v8/${v8Ver}; ssl/${sslVer}`;
17
16
  }
18
17
  exports.generateClientString = generateClientString;
package/package.json CHANGED
@@ -54,7 +54,7 @@
54
54
  "type": "git",
55
55
  "url": "http://github.com/couchbase/couchnode.git"
56
56
  },
57
- "version": "4.4.3",
57
+ "version": "4.4.4",
58
58
  "config": {
59
59
  "native": false
60
60
  },
@@ -79,13 +79,13 @@
79
79
  ]
80
80
  },
81
81
  "optionalDependencies": {
82
- "@couchbase/couchbase-darwin-arm64-napi": "4.4.3",
83
- "@couchbase/couchbase-darwin-x64-napi": "4.4.3",
84
- "@couchbase/couchbase-linux-arm64-napi": "4.4.3",
85
- "@couchbase/couchbase-linuxmusl-arm64-napi": "4.4.3",
86
- "@couchbase/couchbase-linuxmusl-x64-napi": "4.4.3",
87
- "@couchbase/couchbase-linux-x64-napi": "4.4.3",
88
- "@couchbase/couchbase-win32-x64-napi": "4.4.3"
82
+ "@couchbase/couchbase-darwin-arm64-napi": "4.4.4",
83
+ "@couchbase/couchbase-darwin-x64-napi": "4.4.4",
84
+ "@couchbase/couchbase-linux-arm64-napi": "4.4.4",
85
+ "@couchbase/couchbase-linuxmusl-arm64-napi": "4.4.4",
86
+ "@couchbase/couchbase-linuxmusl-x64-napi": "4.4.4",
87
+ "@couchbase/couchbase-linux-x64-napi": "4.4.4",
88
+ "@couchbase/couchbase-win32-x64-napi": "4.4.4"
89
89
  },
90
90
  "files": [
91
91
  "LICENSE",
@@ -93,6 +93,7 @@
93
93
  "CONTRIBUTING.md",
94
94
  "package.json",
95
95
  "README.md",
96
+ "BUILDING.md",
96
97
  "couchbase-sdk-nodejs-black-duck-manifest.yaml",
97
98
  "scripts/*.js",
98
99
  "src/*.{c,h}pp",