couchbase 4.2.1 → 4.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. package/CMakeLists.txt +1 -0
  2. package/deps/couchbase-cxx-client/.gitmodules +3 -0
  3. package/deps/couchbase-cxx-client/.idea/misc.xml +1 -0
  4. package/deps/couchbase-cxx-client/.idea/vcs.xml +1 -0
  5. package/deps/couchbase-cxx-client/CMakeLists.txt +11 -1
  6. package/deps/couchbase-cxx-client/README.md +3 -3
  7. package/deps/couchbase-cxx-client/cmake/CompilerWarnings.cmake +4 -1
  8. package/deps/couchbase-cxx-client/cmake/VersionInfo.cmake +13 -1
  9. package/deps/couchbase-cxx-client/cmake/build_version.hxx.in +1 -0
  10. package/deps/couchbase-cxx-client/core/cluster.hxx +15 -5
  11. package/deps/couchbase-cxx-client/core/impl/build_deferred_query_indexes.cxx +17 -6
  12. package/deps/couchbase-cxx-client/core/impl/cluster.cxx +1 -1
  13. package/deps/couchbase-cxx-client/core/impl/collection_query_index_manager.cxx +93 -0
  14. package/deps/couchbase-cxx-client/core/impl/configuration_profiles_registry.cxx +11 -0
  15. package/deps/couchbase-cxx-client/core/impl/create_query_index.cxx +119 -0
  16. package/deps/couchbase-cxx-client/core/impl/drop_query_index.cxx +108 -0
  17. package/deps/couchbase-cxx-client/core/impl/get.cxx +1 -1
  18. package/deps/couchbase-cxx-client/core/impl/get_all_query_indexes.cxx +76 -0
  19. package/deps/couchbase-cxx-client/core/impl/query.cxx +5 -7
  20. package/deps/couchbase-cxx-client/core/impl/watch_query_indexes.cxx +168 -0
  21. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +15 -1
  22. package/deps/couchbase-cxx-client/core/logger/configuration.hxx +3 -0
  23. package/deps/couchbase-cxx-client/core/logger/level.hxx +21 -0
  24. package/deps/couchbase-cxx-client/core/logger/logger.hxx +4 -6
  25. package/deps/couchbase-cxx-client/core/meta/CMakeLists.txt +4 -2
  26. package/deps/couchbase-cxx-client/core/meta/features.hxx +31 -0
  27. package/deps/couchbase-cxx-client/core/meta/version.cxx +67 -5
  28. package/deps/couchbase-cxx-client/core/meta/version.hxx +12 -1
  29. package/deps/couchbase-cxx-client/core/metrics/CMakeLists.txt +4 -1
  30. package/deps/couchbase-cxx-client/core/metrics/logging_meter.cxx +46 -5
  31. package/deps/couchbase-cxx-client/core/metrics/logging_meter.hxx +10 -26
  32. package/deps/couchbase-cxx-client/core/operations/document_get_projected.cxx +3 -2
  33. package/deps/couchbase-cxx-client/core/operations/document_query.cxx +10 -12
  34. package/deps/couchbase-cxx-client/core/operations/document_query.hxx +1 -3
  35. package/deps/couchbase-cxx-client/core/operations/management/query_index_build.cxx +8 -14
  36. package/deps/couchbase-cxx-client/core/operations/management/query_index_build.hxx +2 -1
  37. package/deps/couchbase-cxx-client/core/operations/management/query_index_build_deferred.hxx +15 -8
  38. package/deps/couchbase-cxx-client/core/operations/management/query_index_create.cxx +7 -14
  39. package/deps/couchbase-cxx-client/core/operations/management/query_index_create.hxx +2 -0
  40. package/deps/couchbase-cxx-client/core/operations/management/query_index_drop.cxx +11 -16
  41. package/deps/couchbase-cxx-client/core/operations/management/query_index_drop.hxx +2 -0
  42. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all.cxx +8 -12
  43. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all.hxx +4 -3
  44. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all_deferred.cxx +21 -12
  45. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all_deferred.hxx +3 -2
  46. package/deps/couchbase-cxx-client/core/origin.hxx +1 -1
  47. package/deps/couchbase-cxx-client/core/platform/uuid.cc +1 -2
  48. package/deps/couchbase-cxx-client/core/protocol/cmd_hello.hxx +5 -1
  49. package/deps/couchbase-cxx-client/core/query_context.hxx +79 -0
  50. package/deps/couchbase-cxx-client/core/tracing/CMakeLists.txt +3 -1
  51. package/deps/couchbase-cxx-client/core/tracing/threshold_logging_tracer.cxx +19 -4
  52. package/deps/couchbase-cxx-client/core/tracing/threshold_logging_tracer.hxx +2 -2
  53. package/deps/couchbase-cxx-client/core/transactions/async_attempt_context.hxx +10 -4
  54. package/deps/couchbase-cxx-client/core/transactions/atr_cleanup_entry.cxx +52 -63
  55. package/deps/couchbase-cxx-client/core/transactions/attempt_context.hxx +8 -3
  56. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.cxx +163 -126
  57. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.hxx +24 -37
  58. package/deps/couchbase-cxx-client/core/transactions/forward_compat.hxx +4 -4
  59. package/deps/couchbase-cxx-client/core/transactions/internal/atr_cleanup_entry.hxx +51 -13
  60. package/deps/couchbase-cxx-client/core/transactions/internal/client_record.hxx +26 -1
  61. package/deps/couchbase-cxx-client/core/transactions/internal/doc_record.hxx +21 -0
  62. package/deps/couchbase-cxx-client/core/transactions/internal/logging.hxx +40 -18
  63. package/deps/couchbase-cxx-client/core/transactions/internal/transaction_context.hxx +5 -0
  64. package/deps/couchbase-cxx-client/core/transactions/result.hxx +26 -0
  65. package/deps/couchbase-cxx-client/core/transactions/staged_mutation.cxx +48 -47
  66. package/deps/couchbase-cxx-client/core/transactions/staged_mutation.hxx +6 -6
  67. package/deps/couchbase-cxx-client/core/transactions/transaction_context.cxx +33 -19
  68. package/deps/couchbase-cxx-client/core/transactions/transaction_get_result.hxx +18 -2
  69. package/deps/couchbase-cxx-client/core/transactions/transaction_links.hxx +25 -2
  70. package/deps/couchbase-cxx-client/core/transactions/transactions.cxx +4 -4
  71. package/deps/couchbase-cxx-client/core/transactions/transactions_cleanup.cxx +49 -56
  72. package/deps/couchbase-cxx-client/core/transactions/waitable_op_list.hxx +7 -7
  73. package/deps/couchbase-cxx-client/core/transactions.hxx +0 -12
  74. package/deps/couchbase-cxx-client/core/utils/binary.hxx +1 -1
  75. package/deps/couchbase-cxx-client/core/utils/keyspace.hxx +55 -0
  76. package/deps/couchbase-cxx-client/couchbase/build_query_index_options.hxx +12 -45
  77. package/deps/couchbase-cxx-client/couchbase/cluster.hxx +1 -1
  78. package/deps/couchbase-cxx-client/couchbase/cluster_options.hxx +6 -7
  79. package/deps/couchbase-cxx-client/couchbase/collection.hxx +8 -0
  80. package/deps/couchbase-cxx-client/couchbase/collection_query_index_manager.hxx +218 -0
  81. package/deps/couchbase-cxx-client/couchbase/configuration_profiles_registry.hxx +3 -0
  82. package/deps/couchbase-cxx-client/couchbase/create_primary_query_index_options.hxx +166 -0
  83. package/deps/couchbase-cxx-client/couchbase/create_query_index_options.hxx +172 -0
  84. package/deps/couchbase-cxx-client/couchbase/drop_primary_query_index_options.hxx +129 -0
  85. package/deps/couchbase-cxx-client/couchbase/drop_query_index_options.hxx +116 -0
  86. package/deps/couchbase-cxx-client/couchbase/fmt/cas.hxx +1 -1
  87. package/deps/couchbase-cxx-client/couchbase/fmt/query_scan_consistency.hxx +46 -0
  88. package/deps/couchbase-cxx-client/couchbase/fmt/query_status.hxx +70 -0
  89. package/deps/couchbase-cxx-client/couchbase/fmt/tls_verify_mode.hxx +46 -0
  90. package/deps/couchbase-cxx-client/couchbase/get_all_query_indexes_options.hxx +100 -0
  91. package/deps/couchbase-cxx-client/{core → couchbase}/management/query_index.hxx +2 -2
  92. package/deps/couchbase-cxx-client/couchbase/metrics/meter.hxx +16 -0
  93. package/deps/couchbase-cxx-client/couchbase/query_index_manager.hxx +178 -6
  94. package/deps/couchbase-cxx-client/couchbase/query_options.hxx +1 -18
  95. package/deps/couchbase-cxx-client/couchbase/scope.hxx +5 -2
  96. package/deps/couchbase-cxx-client/couchbase/tracing/request_tracer.hxx +16 -0
  97. package/deps/couchbase-cxx-client/couchbase/transactions/async_attempt_context.hxx +11 -4
  98. package/deps/couchbase-cxx-client/couchbase/transactions/attempt_context.hxx +5 -3
  99. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_keyspace.hxx +16 -0
  100. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_query_options.hxx +0 -6
  101. package/deps/couchbase-cxx-client/couchbase/watch_query_indexes_options.hxx +115 -0
  102. package/deps/couchbase-cxx-client/examples/minimal.cxx +3 -1
  103. package/deps/couchbase-cxx-client/test/test_integration_crud.cxx +72 -0
  104. package/deps/couchbase-cxx-client/test/test_integration_management.cxx +727 -310
  105. package/deps/couchbase-cxx-client/test/test_integration_query.cxx +4 -8
  106. package/deps/couchbase-cxx-client/test/test_integration_transcoders.cxx +14 -0
  107. package/deps/couchbase-cxx-client/test/test_transaction_transaction_public_blocking_api.cxx +34 -19
  108. package/deps/couchbase-cxx-client/test/test_unit_transaction_logging.cxx +66 -22
  109. package/deps/couchbase-cxx-client/test/test_unit_utils.cxx +51 -0
  110. package/deps/couchbase-cxx-client/test/tools/tool_kv_loader.cxx +2 -2
  111. package/deps/couchbase-cxx-client/test/utils/integration_test_guard.cxx +2 -0
  112. package/deps/couchbase-cxx-client/test/utils/wait_until.cxx +4 -4
  113. package/deps/couchbase-cxx-client/third_party/docopt/.travis.yml +103 -0
  114. package/deps/couchbase-cxx-client/third_party/docopt/CMakeLists.txt +129 -0
  115. package/deps/couchbase-cxx-client/third_party/docopt/LICENSE-Boost-1.0 +23 -0
  116. package/deps/couchbase-cxx-client/third_party/docopt/LICENSE-MIT +23 -0
  117. package/deps/couchbase-cxx-client/third_party/docopt/README.rst +479 -0
  118. package/deps/couchbase-cxx-client/third_party/docopt/docopt-config.cmake +1 -0
  119. package/deps/couchbase-cxx-client/third_party/docopt/docopt.cpp +687 -0
  120. package/deps/couchbase-cxx-client/third_party/docopt/docopt.h +98 -0
  121. package/deps/couchbase-cxx-client/third_party/docopt/docopt.pc.in +9 -0
  122. package/deps/couchbase-cxx-client/third_party/docopt/docopt_private.h +676 -0
  123. package/deps/couchbase-cxx-client/third_party/docopt/docopt_util.h +122 -0
  124. package/deps/couchbase-cxx-client/third_party/docopt/docopt_value.h +341 -0
  125. package/deps/couchbase-cxx-client/third_party/docopt/examples/naval_fate.cpp +36 -0
  126. package/deps/couchbase-cxx-client/third_party/docopt/main.cpp +16 -0
  127. package/deps/couchbase-cxx-client/third_party/docopt/run_testcase.cpp +40 -0
  128. package/deps/couchbase-cxx-client/third_party/docopt/run_tests.py +72 -0
  129. package/deps/couchbase-cxx-client/third_party/docopt/testcases.docopt +957 -0
  130. package/deps/couchbase-cxx-client/tools/CMakeLists.txt +14 -0
  131. package/deps/couchbase-cxx-client/tools/cbc.cxx +65 -0
  132. package/deps/couchbase-cxx-client/tools/command.hxx +31 -0
  133. package/deps/couchbase-cxx-client/tools/command_registry.cxx +43 -0
  134. package/deps/couchbase-cxx-client/tools/command_registry.hxx +39 -0
  135. package/deps/couchbase-cxx-client/tools/get.cxx +267 -0
  136. package/deps/couchbase-cxx-client/tools/get.hxx +26 -0
  137. package/deps/couchbase-cxx-client/tools/query.cxx +441 -0
  138. package/deps/couchbase-cxx-client/tools/query.hxx +26 -0
  139. package/deps/couchbase-cxx-client/tools/utils.cxx +418 -0
  140. package/deps/couchbase-cxx-client/tools/utils.hxx +150 -0
  141. package/deps/couchbase-cxx-client/tools/version.cxx +82 -0
  142. package/deps/couchbase-cxx-client/tools/version.hxx +26 -0
  143. package/dist/authenticators.d.ts +2 -2
  144. package/dist/authenticators.js +1 -2
  145. package/dist/binding.d.ts +32 -16
  146. package/dist/cluster.js +14 -7
  147. package/dist/collection.d.ts +6 -0
  148. package/dist/collection.js +8 -0
  149. package/dist/queryexecutor.js +1 -1
  150. package/dist/queryindexmanager.d.ts +100 -4
  151. package/dist/queryindexmanager.js +344 -118
  152. package/dist/transactions.js +0 -2
  153. package/package.json +1 -1
  154. package/src/connection.cpp +2 -0
  155. package/src/connection.hpp +1 -0
  156. package/src/connection_autogen.cpp +16 -0
  157. package/src/jstocbpp_autogen.hpp +93 -23
  158. package/src/jstocbpp_basic.hpp +24 -0
  159. package/src/jstocbpp_transactions.hpp +0 -8
  160. package/tools/gen-bindings-js.js +1 -0
  161. package/tools/gen-bindings-json.py +4 -2
  162. package/deps/couchbase-cxx-client/core/transactions/logging.cxx +0 -107
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QueryIndexManager = exports.QueryIndex = void 0;
3
+ exports.QueryIndexManager = exports.CollectionQueryIndexManager = exports.QueryIndex = void 0;
4
4
  const bindingutilities_1 = require("./bindingutilities");
5
5
  const errors_1 = require("./errors");
6
- const httpexecutor_1 = require("./httpexecutor");
7
6
  const utilities_1 = require("./utilities");
8
7
  /**
9
8
  * Contains a specific index configuration for the query service.
@@ -29,22 +28,23 @@ class QueryIndex {
29
28
  }
30
29
  exports.QueryIndex = QueryIndex;
31
30
  /**
32
- * QueryIndexManager provides an interface for managing the
33
- * query indexes on the cluster.
34
- *
35
- * @category Management
31
+ * @internal
36
32
  */
37
- class QueryIndexManager {
33
+ class InternalQueryIndexManager {
38
34
  /**
39
35
  * @internal
40
36
  */
41
37
  constructor(cluster) {
42
38
  this._cluster = cluster;
39
+ this._queryContext = {
40
+ bucket_name: '',
41
+ scope_name: '',
42
+ };
43
43
  }
44
- get _http() {
45
- return new httpexecutor_1.HttpExecutor(this._cluster.conn);
46
- }
47
- async _createIndex(bucketName, isPrimary, options, callback) {
44
+ /**
45
+ * @internal
46
+ */
47
+ async createIndex(bucketName, isPrimary, options, callback) {
48
48
  const timeout = options.timeout || this._cluster.managementTimeout;
49
49
  return utilities_1.PromiseHelper.wrap((wrapCallback) => {
50
50
  this._cluster.conn.managementQueryIndexCreate({
@@ -53,6 +53,7 @@ class QueryIndexManager {
53
53
  collection_name: options.collectionName || '',
54
54
  index_name: options.name || '',
55
55
  fields: options.fields || [],
56
+ query_ctx: options.queryContext || this._queryContext,
56
57
  is_primary: isPrimary,
57
58
  ignore_if_exists: options.ignoreIfExists || false,
58
59
  deferred: options.deferred,
@@ -68,6 +69,322 @@ class QueryIndexManager {
68
69
  });
69
70
  }, callback);
70
71
  }
72
+ /**
73
+ * @internal
74
+ */
75
+ async dropIndex(bucketName, isPrimary, options, callback) {
76
+ const timeout = options.timeout || this._cluster.managementTimeout;
77
+ // BUG(JSCBC-1066): We need to use a normal drop index for named primary indexes.
78
+ if (options.name) {
79
+ isPrimary = false;
80
+ }
81
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
82
+ this._cluster.conn.managementQueryIndexDrop({
83
+ bucket_name: bucketName,
84
+ scope_name: options.scopeName || '',
85
+ collection_name: options.collectionName || '',
86
+ index_name: options.name || '',
87
+ query_ctx: options.queryContext || this._queryContext,
88
+ is_primary: isPrimary,
89
+ ignore_if_does_not_exist: options.ignoreIfNotExists || false,
90
+ timeout: timeout,
91
+ }, (cppErr) => {
92
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
93
+ if (err) {
94
+ return wrapCallback(err, null);
95
+ }
96
+ wrapCallback(err);
97
+ });
98
+ }, callback);
99
+ }
100
+ /**
101
+ * @internal
102
+ */
103
+ async getAllIndexes(bucketName, options, callback) {
104
+ const timeout = options.timeout || this._cluster.managementTimeout;
105
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
106
+ this._cluster.conn.managementQueryIndexGetAll({
107
+ bucket_name: bucketName,
108
+ scope_name: options.scopeName || '',
109
+ collection_name: options.collectionName || '',
110
+ query_ctx: options.queryContext || this._queryContext,
111
+ timeout: timeout,
112
+ }, (cppErr, resp) => {
113
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
114
+ if (err) {
115
+ return wrapCallback(err, null);
116
+ }
117
+ const indexes = resp.indexes.map((row) => new QueryIndex({
118
+ isPrimary: row.is_primary,
119
+ name: row.name,
120
+ state: row.state,
121
+ type: row.type,
122
+ indexKey: row.index_key,
123
+ partition: row.partition,
124
+ condition: row.condition,
125
+ bucketName: row.bucket_name,
126
+ scopeName: row.scope_name,
127
+ collectionName: row.collection_name,
128
+ }));
129
+ wrapCallback(null, indexes);
130
+ });
131
+ }, callback);
132
+ }
133
+ /**
134
+ * @internal
135
+ */
136
+ async buildDeferredIndexes(bucketName, options, callback) {
137
+ const timeout = options.timeout || this._cluster.managementTimeout;
138
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
139
+ this._cluster.conn.managementQueryIndexBuildDeferred({
140
+ bucket_name: bucketName,
141
+ scope_name: options.scopeName || '',
142
+ collection_name: options.collectionName || '',
143
+ query_ctx: options.queryContext || this._queryContext,
144
+ timeout: timeout,
145
+ }, (cppErr) => {
146
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
147
+ if (err) {
148
+ return wrapCallback(err, null);
149
+ }
150
+ wrapCallback(null, null);
151
+ });
152
+ }, callback);
153
+ }
154
+ /**
155
+ * @internal
156
+ */
157
+ async watchIndexes(bucketName, indexNames, timeout, options, callback) {
158
+ if (options.watchPrimary) {
159
+ indexNames = [...indexNames, '#primary'];
160
+ }
161
+ const timer = new utilities_1.CompoundTimeout(timeout);
162
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
163
+ let curInterval = 50;
164
+ for (;;) {
165
+ // Get all the indexes that are currently registered
166
+ const foundIdxs = await this.getAllIndexes(bucketName, {
167
+ timeout: timer.left(),
168
+ });
169
+ const foundIndexNames = foundIdxs.map((idx) => idx.name);
170
+ const onlineIdxs = foundIdxs.filter((idx) => idx.state === 'online');
171
+ const onlineIdxNames = onlineIdxs.map((idx) => idx.name);
172
+ // Check if all the indexes we want are online
173
+ let allOnline = true;
174
+ indexNames.forEach((indexName) => {
175
+ if (!foundIndexNames.includes(indexName)) {
176
+ throw new errors_1.IndexNotFoundError(new Error(`Cannot find index with name ${indexName}`));
177
+ }
178
+ allOnline = allOnline && onlineIdxNames.indexOf(indexName) !== -1;
179
+ });
180
+ // If all the indexes are online, we've succeeded
181
+ if (allOnline) {
182
+ break;
183
+ }
184
+ // Add 500 to our interval to a max of 1000
185
+ curInterval = Math.min(1000, curInterval + 500);
186
+ // Make sure we don't go past our user-specified duration
187
+ const userTimeLeft = timer.left();
188
+ if (userTimeLeft !== undefined) {
189
+ curInterval = Math.min(curInterval, userTimeLeft);
190
+ }
191
+ if (curInterval <= 0) {
192
+ throw new errors_1.CouchbaseError('Failed to find all indexes online within the alloted time.');
193
+ }
194
+ // Wait until curInterval expires
195
+ await new Promise((resolve) => setTimeout(() => resolve(true), curInterval));
196
+ }
197
+ }, callback);
198
+ }
199
+ }
200
+ /**
201
+ * CollectionQueryIndexManager provides an interface for managing the
202
+ * query indexes on the collection.
203
+ *
204
+ * @category Management
205
+ */
206
+ class CollectionQueryIndexManager {
207
+ /**
208
+ * @internal
209
+ */
210
+ constructor(collection) {
211
+ this._bucketName = collection.scope.bucket.name;
212
+ this._collectionName = collection.name;
213
+ this._scopeName = collection.scope.name;
214
+ this._manager = new InternalQueryIndexManager(collection.cluster);
215
+ }
216
+ /**
217
+ * Creates a new query index.
218
+ *
219
+ * @param indexName The name of the new index.
220
+ * @param fields The fields which this index should cover.
221
+ * @param options Optional parameters for this operation.
222
+ * @param callback A node-style callback to be invoked after execution.
223
+ */
224
+ async createIndex(indexName, fields, options, callback) {
225
+ if (options instanceof Function) {
226
+ callback = arguments[2];
227
+ options = undefined;
228
+ }
229
+ if (!options) {
230
+ options = {};
231
+ }
232
+ return this._manager.createIndex(this._bucketName, false, {
233
+ collectionName: this._collectionName,
234
+ scopeName: this._scopeName,
235
+ name: indexName,
236
+ fields: fields,
237
+ ignoreIfExists: options.ignoreIfExists,
238
+ numReplicas: options.numReplicas,
239
+ deferred: options.deferred,
240
+ timeout: options.timeout,
241
+ }, callback);
242
+ }
243
+ /**
244
+ * Creates a new primary query index.
245
+ *
246
+ * @param options Optional parameters for this operation.
247
+ * @param callback A node-style callback to be invoked after execution.
248
+ */
249
+ async createPrimaryIndex(options, callback) {
250
+ if (options instanceof Function) {
251
+ callback = arguments[0];
252
+ options = undefined;
253
+ }
254
+ if (!options) {
255
+ options = {};
256
+ }
257
+ return this._manager.createIndex(this._bucketName, true, {
258
+ collectionName: this._collectionName,
259
+ scopeName: this._scopeName,
260
+ name: options.name,
261
+ ignoreIfExists: options.ignoreIfExists,
262
+ deferred: options.deferred,
263
+ timeout: options.timeout,
264
+ }, callback);
265
+ }
266
+ /**
267
+ * Drops an existing query index.
268
+ *
269
+ * @param indexName The name of the index to drop.
270
+ * @param options Optional parameters for this operation.
271
+ * @param callback A node-style callback to be invoked after execution.
272
+ */
273
+ async dropIndex(indexName, options, callback) {
274
+ if (options instanceof Function) {
275
+ callback = arguments[1];
276
+ options = undefined;
277
+ }
278
+ if (!options) {
279
+ options = {};
280
+ }
281
+ return this._manager.dropIndex(this._bucketName, false, {
282
+ collectionName: this._collectionName,
283
+ scopeName: this._scopeName,
284
+ name: indexName,
285
+ ignoreIfNotExists: options.ignoreIfNotExists,
286
+ timeout: options.timeout,
287
+ }, callback);
288
+ }
289
+ /**
290
+ * Drops an existing primary index.
291
+ *
292
+ * @param options Optional parameters for this operation.
293
+ * @param callback A node-style callback to be invoked after execution.
294
+ */
295
+ async dropPrimaryIndex(options, callback) {
296
+ if (options instanceof Function) {
297
+ callback = arguments[0];
298
+ options = undefined;
299
+ }
300
+ if (!options) {
301
+ options = {};
302
+ }
303
+ return this._manager.dropIndex(this._bucketName, true, {
304
+ collectionName: this._collectionName,
305
+ scopeName: this._scopeName,
306
+ name: options.name,
307
+ ignoreIfNotExists: options.ignoreIfNotExists,
308
+ timeout: options.timeout,
309
+ }, callback);
310
+ }
311
+ /**
312
+ * Returns a list of indexes for a specific bucket.
313
+ *
314
+ * @param options Optional parameters for this operation.
315
+ * @param callback A node-style callback to be invoked after execution.
316
+ */
317
+ async getAllIndexes(options, callback) {
318
+ if (options instanceof Function) {
319
+ callback = arguments[0];
320
+ options = undefined;
321
+ }
322
+ if (!options) {
323
+ options = {};
324
+ }
325
+ return this._manager.getAllIndexes(this._bucketName, {
326
+ collectionName: this._collectionName,
327
+ scopeName: this._scopeName,
328
+ timeout: options.timeout,
329
+ }, callback);
330
+ }
331
+ /**
332
+ * Starts building any indexes which were previously created with deferred=true.
333
+ *
334
+ * @param options Optional parameters for this operation.
335
+ * @param callback A node-style callback to be invoked after execution.
336
+ */
337
+ async buildDeferredIndexes(options, callback) {
338
+ if (options instanceof Function) {
339
+ callback = arguments[0];
340
+ options = undefined;
341
+ }
342
+ if (!options) {
343
+ options = {};
344
+ }
345
+ return this._manager.buildDeferredIndexes(this._bucketName, {
346
+ collectionName: this._collectionName,
347
+ scopeName: this._scopeName,
348
+ timeout: options.timeout,
349
+ }, callback);
350
+ }
351
+ /**
352
+ * Waits for a number of indexes to finish creation and be ready to use.
353
+ *
354
+ * @param indexNames The names of the indexes to watch.
355
+ * @param timeout The maximum time to wait for the index, expressed in milliseconds.
356
+ * @param options Optional parameters for this operation.
357
+ * @param callback A node-style callback to be invoked after execution.
358
+ */
359
+ async watchIndexes(indexNames, timeout, options, callback) {
360
+ if (options instanceof Function) {
361
+ callback = arguments[2];
362
+ options = undefined;
363
+ }
364
+ if (!options) {
365
+ options = {};
366
+ }
367
+ return this._manager.watchIndexes(this._bucketName, indexNames, timeout, {
368
+ collectionName: this._collectionName,
369
+ scopeName: this._scopeName,
370
+ watchPrimary: options.watchPrimary,
371
+ }, callback);
372
+ }
373
+ }
374
+ exports.CollectionQueryIndexManager = CollectionQueryIndexManager;
375
+ /**
376
+ * QueryIndexManager provides an interface for managing the
377
+ * query indexes on the cluster.
378
+ *
379
+ * @category Management
380
+ */
381
+ class QueryIndexManager {
382
+ /**
383
+ * @internal
384
+ */
385
+ constructor(cluster) {
386
+ this._manager = new InternalQueryIndexManager(cluster);
387
+ }
71
388
  /**
72
389
  * Creates a new query index.
73
390
  *
@@ -85,7 +402,7 @@ class QueryIndexManager {
85
402
  if (!options) {
86
403
  options = {};
87
404
  }
88
- return this._createIndex(bucketName, false, {
405
+ return this._manager.createIndex(bucketName, false, {
89
406
  collectionName: options.collectionName,
90
407
  scopeName: options.scopeName,
91
408
  name: indexName,
@@ -111,7 +428,7 @@ class QueryIndexManager {
111
428
  if (!options) {
112
429
  options = {};
113
430
  }
114
- return this._createIndex(bucketName, true, {
431
+ return this._manager.createIndex(bucketName, true, {
115
432
  collectionName: options.collectionName,
116
433
  scopeName: options.scopeName,
117
434
  name: options.name,
@@ -120,30 +437,6 @@ class QueryIndexManager {
120
437
  timeout: options.timeout,
121
438
  }, callback);
122
439
  }
123
- async _dropIndex(bucketName, isPrimary, options, callback) {
124
- const timeout = options.timeout || this._cluster.managementTimeout;
125
- // BUG(JSCBC-1066): We need to use a normal drop index for named primary indexes.
126
- if (options.name) {
127
- isPrimary = false;
128
- }
129
- return utilities_1.PromiseHelper.wrap((wrapCallback) => {
130
- this._cluster.conn.managementQueryIndexDrop({
131
- bucket_name: bucketName,
132
- scope_name: options.scopeName || '',
133
- collection_name: options.collectionName || '',
134
- index_name: options.name || '',
135
- is_primary: isPrimary,
136
- ignore_if_does_not_exist: options.ignoreIfNotExists || false,
137
- timeout: timeout,
138
- }, (cppErr) => {
139
- const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
140
- if (err) {
141
- return wrapCallback(err, null);
142
- }
143
- wrapCallback(err);
144
- });
145
- }, callback);
146
- }
147
440
  /**
148
441
  * Drops an existing query index.
149
442
  *
@@ -160,7 +453,7 @@ class QueryIndexManager {
160
453
  if (!options) {
161
454
  options = {};
162
455
  }
163
- return this._dropIndex(bucketName, false, {
456
+ return this._manager.dropIndex(bucketName, false, {
164
457
  collectionName: options.collectionName,
165
458
  scopeName: options.scopeName,
166
459
  name: indexName,
@@ -183,7 +476,7 @@ class QueryIndexManager {
183
476
  if (!options) {
184
477
  options = {};
185
478
  }
186
- return this._dropIndex(bucketName, true, {
479
+ return this._manager.dropIndex(bucketName, true, {
187
480
  collectionName: options.collectionName,
188
481
  scopeName: options.scopeName,
189
482
  name: options.name,
@@ -206,34 +499,10 @@ class QueryIndexManager {
206
499
  if (!options) {
207
500
  options = {};
208
501
  }
209
- const collectionName = options.collectionName || '';
210
- const scopeName = options.scopeName || '';
211
- const timeout = options.timeout || this._cluster.managementTimeout;
212
- return utilities_1.PromiseHelper.wrap((wrapCallback) => {
213
- this._cluster.conn.managementQueryIndexGetAll({
214
- bucket_name: bucketName,
215
- scope_name: scopeName,
216
- collection_name: collectionName,
217
- timeout,
218
- }, (cppErr, resp) => {
219
- const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
220
- if (err) {
221
- return wrapCallback(err, null);
222
- }
223
- const indexes = resp.indexes.map((row) => new QueryIndex({
224
- isPrimary: row.is_primary,
225
- name: row.name,
226
- state: row.state,
227
- type: row.type,
228
- indexKey: row.index_key,
229
- partition: row.partition,
230
- condition: row.condition,
231
- bucketName: row.bucket_name,
232
- scopeName: row.scope_name,
233
- collectionName: row.collection_name,
234
- }));
235
- wrapCallback(null, indexes);
236
- });
502
+ return this._manager.getAllIndexes(bucketName, {
503
+ collectionName: options.collectionName,
504
+ scopeName: options.scopeName,
505
+ timeout: options.timeout,
237
506
  }, callback);
238
507
  }
239
508
  /**
@@ -251,22 +520,10 @@ class QueryIndexManager {
251
520
  if (!options) {
252
521
  options = {};
253
522
  }
254
- const collectionName = options.collectionName || undefined;
255
- const scopeName = options.scopeName || undefined;
256
- const timeout = options.timeout || this._cluster.managementTimeout;
257
- return utilities_1.PromiseHelper.wrap((wrapCallback) => {
258
- this._cluster.conn.managementQueryIndexBuildDeferred({
259
- bucket_name: bucketName,
260
- scope_name: scopeName,
261
- collection_name: collectionName,
262
- timeout: timeout,
263
- }, (cppErr) => {
264
- const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
265
- if (err) {
266
- return wrapCallback(err, null);
267
- }
268
- wrapCallback(null, null);
269
- });
523
+ return this._manager.buildDeferredIndexes(bucketName, {
524
+ collectionName: options.collectionName,
525
+ scopeName: options.scopeName,
526
+ timeout: options.timeout,
270
527
  }, callback);
271
528
  }
272
529
  /**
@@ -286,41 +543,10 @@ class QueryIndexManager {
286
543
  if (!options) {
287
544
  options = {};
288
545
  }
289
- if (options.watchPrimary) {
290
- indexNames = [...indexNames, '#primary'];
291
- }
292
- const timer = new utilities_1.CompoundTimeout(timeout);
293
- return utilities_1.PromiseHelper.wrapAsync(async () => {
294
- let curInterval = 50;
295
- for (;;) {
296
- // Get all the indexes that are currently registered
297
- const foundIdxs = await this.getAllIndexes(bucketName, {
298
- timeout: timer.left(),
299
- });
300
- const onlineIdxs = foundIdxs.filter((idx) => idx.state === 'online');
301
- const onlineIdxNames = onlineIdxs.map((idx) => idx.name);
302
- // Check if all the indexes we want are online
303
- let allOnline = true;
304
- indexNames.forEach((indexName) => {
305
- allOnline = allOnline && onlineIdxNames.indexOf(indexName) !== -1;
306
- });
307
- // If all the indexes are online, we've succeeded
308
- if (allOnline) {
309
- break;
310
- }
311
- // Add 500 to our interval to a max of 1000
312
- curInterval = Math.min(1000, curInterval + 500);
313
- // Make sure we don't go past our user-specified duration
314
- const userTimeLeft = timer.left();
315
- if (userTimeLeft !== undefined) {
316
- curInterval = Math.min(curInterval, userTimeLeft);
317
- }
318
- if (curInterval <= 0) {
319
- throw new errors_1.CouchbaseError('Failed to find all indexes online within the alloted time.');
320
- }
321
- // Wait until curInterval expires
322
- await new Promise((resolve) => setTimeout(() => resolve(true), curInterval));
323
- }
546
+ return this._manager.watchIndexes(bucketName, indexNames, timeout, {
547
+ collectionName: options.collectionName,
548
+ scopeName: options.scopeName,
549
+ watchPrimary: options.watchPrimary,
324
550
  }, callback);
325
551
  }
326
552
  }
@@ -237,8 +237,6 @@ class TransactionAttemptContext {
237
237
  readonly: options.readOnly || false,
238
238
  profile: (0, bindingutilities_1.queryProfileToCpp)(options.profile),
239
239
  metrics: options.metrics || false,
240
- bucket_name: options.scope ? options.scope.bucket.name : undefined,
241
- scope_name: options.scope ? options.scope.name : undefined,
242
240
  raw: options.raw
243
241
  ? Object.fromEntries(Object.entries(options.raw)
244
242
  .filter(([, v]) => v !== undefined)
package/package.json CHANGED
@@ -1 +1 @@
1
- {"bugs":{"url":"http://www.couchbase.com/issues/browse/JSCBC"},"description":"The official Couchbase Node.js Client Library.","engines":{"node":">=12.0.0"},"homepage":"http://www.couchbase.com/communities/nodejs","keywords":["couchbase","libcouchbase","memcached","nosql","json","document"],"main":"dist/couchbase.js","types":"dist/couchbase.d.ts","license":"Apache-2.0","name":"couchbase","dependencies":{"bindings":"^1.5.0","cmake-js":"^6.3.2","node-addon-api":"^5.0.0","prebuild-install":"^7.1.1"},"devDependencies":{"@trivago/prettier-plugin-sort-imports":"^3.3.0","@tsconfig/node12":"^1.0.11","@types/bindings":"^1.5.1","@types/debug":"^4.1.7","@types/node":"^18.6.3","@typescript-eslint/eslint-plugin":"^5.32.0","@typescript-eslint/parser":"^5.32.0","chai":"^4.3.6","eslint":"^8.21.0","eslint-config-prettier":"^8.5.0","eslint-plugin-jsdoc":"^39.3.4","eslint-plugin-mocha":"^10.1.0","eslint-plugin-node":"^11.1.0","expose-gc":"^1.0.0","mocha":"^10.0.0","npm-check-updates":"^16.0.5","nyc":"^15.1.0","prebuild":"^11.0.4","prettier":"^2.7.1","segfault-handler":"^1.3.0","semver":"^7.3.7","ts-mocha":"^10.0.0","ts-node":"^10.9.1","typedoc":"^0.23.10","typescript":"^4.7.4","uuid":"^8.3.2"},"repository":{"type":"git","url":"http://github.com/couchbase/couchnode.git"},"version":"4.2.1","config":{"native":false},"scripts":{"install":"prebuild-install -r napi || cmake-js compile","build":"cmake-js build && tsc","rebuild":"cmake-js rebuild && tsc","prebuild":"prebuild --backend cmake-js --verbose --strip","prepare":"tsc","build-docs":"typedoc","test":"ts-mocha test/*.test.*","test-fast":"ts-mocha test/*.test.* -ig '(slow)'","cover":"nyc ts-mocha test/*.test.*","cover-fast":"nyc ts-mocha test/*.test.* -ig '(slow)'","lint":"eslint ./lib/ ./test/","check-deps":"ncu"},"binary":{"napi_versions":[6]}}
1
+ {"bugs":{"url":"http://www.couchbase.com/issues/browse/JSCBC"},"description":"The official Couchbase Node.js Client Library.","engines":{"node":">=12.0.0"},"homepage":"http://www.couchbase.com/communities/nodejs","keywords":["couchbase","libcouchbase","memcached","nosql","json","document"],"main":"dist/couchbase.js","types":"dist/couchbase.d.ts","license":"Apache-2.0","name":"couchbase","dependencies":{"bindings":"^1.5.0","cmake-js":"^6.3.2","node-addon-api":"^5.0.0","prebuild-install":"^7.1.1"},"devDependencies":{"@trivago/prettier-plugin-sort-imports":"^3.3.0","@tsconfig/node12":"^1.0.11","@types/bindings":"^1.5.1","@types/debug":"^4.1.7","@types/node":"^18.6.3","@typescript-eslint/eslint-plugin":"^5.32.0","@typescript-eslint/parser":"^5.32.0","chai":"^4.3.6","eslint":"^8.21.0","eslint-config-prettier":"^8.5.0","eslint-plugin-jsdoc":"^39.3.4","eslint-plugin-mocha":"^10.1.0","eslint-plugin-node":"^11.1.0","expose-gc":"^1.0.0","mocha":"^10.0.0","npm-check-updates":"^16.0.5","nyc":"^15.1.0","prebuild":"^11.0.4","prettier":"^2.7.1","segfault-handler":"^1.3.0","semver":"^7.3.7","ts-mocha":"^10.0.0","ts-node":"^10.9.1","typedoc":"^0.23.10","typescript":"^4.7.4","uuid":"^8.3.2"},"repository":{"type":"git","url":"http://github.com/couchbase/couchnode.git"},"version":"4.2.2","config":{"native":false},"scripts":{"install":"prebuild-install -r napi || cmake-js compile","build":"cmake-js build && tsc","rebuild":"cmake-js rebuild && tsc","prebuild":"prebuild --backend cmake-js --verbose --strip","prepare":"tsc","build-docs":"typedoc","test":"ts-mocha test/*.test.*","test-fast":"ts-mocha test/*.test.* -ig '(slow)'","cover":"nyc ts-mocha test/*.test.*","cover-fast":"nyc ts-mocha test/*.test.* -ig '(slow)'","lint":"eslint ./lib/ ./test/","check-deps":"ncu"},"binary":{"napi_versions":[6]}}
@@ -127,6 +127,8 @@ void Connection::Init(Napi::Env env, Napi::Object exports)
127
127
  "managementAnalyticsLinkConnect"),
128
128
  InstanceMethod<&Connection::jsManagementCollectionsManifestGet>(
129
129
  "managementCollectionsManifestGet"),
130
+ InstanceMethod<&Connection::jsManagementChangePassword>(
131
+ "managementChangePassword"),
130
132
  InstanceMethod<
131
133
  &Connection::jsManagementClusterDeveloperPreviewEnable>(
132
134
  "managementClusterDeveloperPreviewEnable"),
@@ -139,6 +139,7 @@ public:
139
139
  jsManagementAnalyticsLinkConnect(const Napi::CallbackInfo &info);
140
140
  Napi::Value
141
141
  jsManagementCollectionsManifestGet(const Napi::CallbackInfo &info);
142
+ Napi::Value jsManagementChangePassword(const Napi::CallbackInfo &info);
142
143
  Napi::Value
143
144
  jsManagementClusterDeveloperPreviewEnable(const Napi::CallbackInfo &info);
144
145
  Napi::Value jsManagementAnalyticsLinkDrop(const Napi::CallbackInfo &info);
@@ -769,6 +769,22 @@ Connection::jsManagementCollectionsManifestGet(const Napi::CallbackInfo &info)
769
769
  return info.Env().Null();
770
770
  }
771
771
 
772
+ Napi::Value
773
+ Connection::jsManagementChangePassword(const Napi::CallbackInfo &info)
774
+ {
775
+ auto optsJsObj = info[0].As<Napi::Object>();
776
+ auto callbackJsFn = info[1].As<Napi::Function>();
777
+
778
+ executeOp(
779
+ "managementChangePassword",
780
+ jsToCbpp<
781
+ couchbase::core::operations::management::change_password_request>(
782
+ optsJsObj),
783
+ callbackJsFn);
784
+
785
+ return info.Env().Null();
786
+ }
787
+
772
788
  Napi::Value Connection::jsManagementClusterDeveloperPreviewEnable(
773
789
  const Napi::CallbackInfo &info)
774
790
  {