couchbase 3.2.2 → 3.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. package/binding.gyp +5 -0
  2. package/deps/lcb/CMakeLists.txt +1 -1
  3. package/deps/lcb/CONTRIBUTING.md +1 -1
  4. package/deps/lcb/README.markdown +2 -2
  5. package/deps/lcb/RELEASE_NOTES.markdown +84 -17
  6. package/deps/lcb/cmake/Modules/GetVersionInfo.cmake +1 -1
  7. package/deps/lcb/contrib/cbsasl/src/scram-sha/scram_utils.cc +22 -26
  8. package/deps/lcb/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp +20 -6
  9. package/deps/lcb/doc/Doxyfile +1 -1
  10. package/deps/lcb/example/minimal/query.c +9 -7
  11. package/deps/lcb/gyp_config/common/libcouchbase/configuration.h +3 -3
  12. package/deps/lcb/gyp_config/linux/arm64/config.h +243 -0
  13. package/deps/lcb/include/libcouchbase/couchbase.h +55 -1
  14. package/deps/lcb/include/libcouchbase/error.h +6 -1
  15. package/deps/lcb/include/libcouchbase/ixmgmt.h +15 -10
  16. package/deps/lcb/include/libcouchbase/tracing.h +2 -2
  17. package/deps/lcb/include/memcached/protocol_binary.h +21 -0
  18. package/deps/lcb/libcouchbase.gyp +353 -349
  19. package/deps/lcb/packaging/deb/control +1 -1
  20. package/deps/lcb/src/analytics/analytics_handle.cc +7 -5
  21. package/deps/lcb/src/analytics/analytics_handle.hh +28 -0
  22. package/deps/lcb/src/capi/cmd_counter.hh +18 -0
  23. package/deps/lcb/src/capi/cmd_exists.hh +18 -0
  24. package/deps/lcb/src/capi/cmd_get.hh +17 -0
  25. package/deps/lcb/src/capi/cmd_get_replica.hh +20 -1
  26. package/deps/lcb/src/capi/cmd_query.cc +13 -0
  27. package/deps/lcb/src/capi/cmd_query.hh +22 -14
  28. package/deps/lcb/src/capi/cmd_remove.hh +18 -0
  29. package/deps/lcb/src/capi/cmd_search.hh +6 -0
  30. package/deps/lcb/src/capi/cmd_store.hh +28 -21
  31. package/deps/lcb/src/capi/cmd_subdoc.hh +30 -0
  32. package/deps/lcb/src/capi/cmd_touch.hh +18 -0
  33. package/deps/lcb/src/capi/cmd_unlock.hh +18 -0
  34. package/deps/lcb/src/capi/cmd_view.hh +6 -0
  35. package/deps/lcb/src/capi/collection_qualifier.hh +6 -8
  36. package/deps/lcb/src/cntl.cc +42 -8
  37. package/deps/lcb/src/dns-srv.cc +5 -3
  38. package/deps/lcb/src/errmap.cc +5 -9
  39. package/deps/lcb/src/errmap.h +7 -3
  40. package/deps/lcb/src/handler.cc +24 -18
  41. package/deps/lcb/src/internal.h +2 -1
  42. package/deps/lcb/src/lcbio/ctx.cc +4 -2
  43. package/deps/lcb/src/mcserver/mcserver.cc +8 -5
  44. package/deps/lcb/src/mcserver/negotiate.cc +42 -17
  45. package/deps/lcb/src/n1ql/ixmgmt.cc +1 -2
  46. package/deps/lcb/src/n1ql/n1ql.cc +5 -1
  47. package/deps/lcb/src/n1ql/query_handle.cc +80 -44
  48. package/deps/lcb/src/n1ql/query_handle.hh +41 -3
  49. package/deps/lcb/src/operations/counter.cc +13 -1
  50. package/deps/lcb/src/operations/exists.cc +14 -2
  51. package/deps/lcb/src/operations/get.cc +14 -2
  52. package/deps/lcb/src/operations/get_replica.cc +18 -6
  53. package/deps/lcb/src/operations/observe.cc +1 -1
  54. package/deps/lcb/src/operations/remove.cc +13 -1
  55. package/deps/lcb/src/operations/store.cc +13 -1
  56. package/deps/lcb/src/operations/subdoc.cc +13 -2
  57. package/deps/lcb/src/operations/touch.cc +14 -2
  58. package/deps/lcb/src/operations/unlock.cc +14 -2
  59. package/deps/lcb/src/search/search_handle.cc +26 -8
  60. package/deps/lcb/src/search/search_handle.hh +29 -0
  61. package/deps/lcb/src/ssl/ssl_common.c +7 -8
  62. package/deps/lcb/src/tracing/span.cc +43 -10
  63. package/deps/lcb/src/tracing/tracing-internal.h +105 -93
  64. package/deps/lcb/src/utilities.cc +21 -0
  65. package/deps/lcb/src/utilities.h +3 -0
  66. package/deps/lcb/src/views/view_handle.cc +13 -5
  67. package/deps/lcb/src/views/view_handle.hh +29 -0
  68. package/deps/lcb/tests/CMakeLists.txt +21 -0
  69. package/deps/lcb/tests/basic/t_ctlcodes.cc +24 -3
  70. package/deps/lcb/tests/basic/t_jsparse.cc +8 -0
  71. package/deps/lcb/tests/iotests/mock-environment.cc +25 -1
  72. package/deps/lcb/tests/iotests/mock-environment.h +49 -1
  73. package/deps/lcb/tests/iotests/mock-unit-test.cc +96 -5
  74. package/deps/lcb/tests/iotests/mock-unit-test.h +32 -0
  75. package/deps/lcb/tests/iotests/serverparams.h +7 -2
  76. package/deps/lcb/tests/iotests/t_collections.cc +1 -1
  77. package/deps/lcb/tests/iotests/t_confmon.cc +4 -2
  78. package/deps/lcb/tests/iotests/t_get.cc +14 -4
  79. package/deps/lcb/tests/iotests/t_n1ql.cc +17 -1
  80. package/deps/lcb/tests/iotests/t_ratelimit.cc +729 -0
  81. package/deps/lcb/tests/iotests/t_views.cc +1 -0
  82. package/deps/lcb/tests/iotests/testutil.cc +342 -0
  83. package/deps/lcb/tests/iotests/testutil.h +164 -0
  84. package/deps/lcb/tests/mocksupport/procutil.c +32 -28
  85. package/deps/lcb/tests/mocksupport/server.c +0 -1
  86. package/deps/lcb/tools/cbc.cc +7 -0
  87. package/dist/analyticsexecutor.js +2 -2
  88. package/dist/analyticsindexmanager.js +512 -524
  89. package/dist/binarycollection.d.ts +17 -0
  90. package/dist/binding.d.ts +2 -0
  91. package/dist/binding.js +1 -1
  92. package/dist/bindingutilities.js +9 -1
  93. package/dist/bucketmanager.d.ts +32 -23
  94. package/dist/bucketmanager.js +197 -189
  95. package/dist/cluster.js +37 -36
  96. package/dist/collection.js +17 -23
  97. package/dist/collectionmanager.js +181 -200
  98. package/dist/connection.js +6 -3
  99. package/dist/connspec.js +5 -1
  100. package/dist/couchbase.js +7 -14
  101. package/dist/datastructures.js +239 -310
  102. package/dist/diagnosticsexecutor.js +70 -85
  103. package/dist/errors.d.ts +18 -0
  104. package/dist/errors.js +26 -2
  105. package/dist/eventingfunctionmanager.js +267 -294
  106. package/dist/httpexecutor.js +31 -38
  107. package/dist/logging.js +1 -1
  108. package/dist/queryexecutor.js +3 -3
  109. package/dist/queryindexmanager.js +236 -263
  110. package/dist/scope.js +8 -2
  111. package/dist/searchexecutor.js +3 -0
  112. package/dist/searchindexmanager.js +240 -271
  113. package/dist/searchquery.d.ts +17 -0
  114. package/dist/searchquery.js +22 -1
  115. package/dist/searchtypes.d.ts +7 -2
  116. package/dist/searchtypes.js +2 -2
  117. package/dist/usermanager.js +250 -263
  118. package/dist/utilities.d.ts +3 -2
  119. package/dist/utilities.js +16 -4
  120. package/dist/viewexecutor.js +1 -1
  121. package/dist/viewindexmanager.js +131 -150
  122. package/package.json +1 -1
  123. package/src/connection.cpp +2 -0
  124. package/src/constants.cpp +2 -0
  125. package/src/instance.cpp +8 -1
  126. package/src/instance.h +1 -0
  127. package/src/uv-plugin-all.cpp +1 -0
  128. package/dist/cas.d.ts +0 -0
  129. package/dist/cas.js +0 -1
@@ -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.QueryIndexManager = exports.QueryIndex = void 0;
13
4
  const errors_1 = require("./errors");
@@ -50,56 +41,54 @@ class QueryIndexManager {
50
41
  get _http() {
51
42
  return new httpexecutor_1.HttpExecutor(this._cluster._getClusterConn());
52
43
  }
53
- _createIndex(bucketName, options, callback) {
54
- return __awaiter(this, void 0, void 0, function* () {
55
- let qs = '';
56
- if (!options.fields) {
57
- qs += 'CREATE PRIMARY INDEX';
58
- }
59
- else {
60
- qs += 'CREATE INDEX';
61
- }
62
- if (options.name) {
63
- qs += ' `' + options.name + '`';
64
- }
65
- qs += ' ON `' + bucketName + '`';
66
- if (options.fields && options.fields.length > 0) {
67
- qs += '(';
68
- for (let i = 0; i < options.fields.length; ++i) {
69
- if (i > 0) {
70
- qs += ', ';
71
- }
72
- qs += '`' + options.fields[i] + '`';
44
+ async _createIndex(bucketName, options, callback) {
45
+ let qs = '';
46
+ if (!options.fields) {
47
+ qs += 'CREATE PRIMARY INDEX';
48
+ }
49
+ else {
50
+ qs += 'CREATE INDEX';
51
+ }
52
+ if (options.name) {
53
+ qs += ' `' + options.name + '`';
54
+ }
55
+ qs += ' ON `' + bucketName + '`';
56
+ if (options.fields && options.fields.length > 0) {
57
+ qs += '(';
58
+ for (let i = 0; i < options.fields.length; ++i) {
59
+ if (i > 0) {
60
+ qs += ', ';
73
61
  }
74
- qs += ')';
75
- }
76
- const withOpts = {};
77
- if (options.deferred) {
78
- withOpts.defer_build = true;
79
- }
80
- if (options.numReplicas) {
81
- withOpts.num_replica = options.numReplicas;
62
+ qs += '`' + options.fields[i] + '`';
82
63
  }
83
- if (Object.keys(withOpts).length > 0) {
84
- qs += ' WITH ' + JSON.stringify(withOpts);
64
+ qs += ')';
65
+ }
66
+ const withOpts = {};
67
+ if (options.deferred) {
68
+ withOpts.defer_build = true;
69
+ }
70
+ if (options.numReplicas) {
71
+ withOpts.num_replica = options.numReplicas;
72
+ }
73
+ if (Object.keys(withOpts).length > 0) {
74
+ qs += ' WITH ' + JSON.stringify(withOpts);
75
+ }
76
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
77
+ try {
78
+ await this._cluster.query(qs, {
79
+ parentSpan: options.parentSpan,
80
+ timeout: options.timeout,
81
+ });
85
82
  }
86
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
87
- try {
88
- yield this._cluster.query(qs, {
89
- parentSpan: options.parentSpan,
90
- timeout: options.timeout,
91
- });
83
+ catch (err) {
84
+ if (options.ignoreIfExists && err instanceof errors_1.IndexExistsError) {
85
+ // swallow the error if the user wants us to
92
86
  }
93
- catch (err) {
94
- if (options.ignoreIfExists && err instanceof errors_1.IndexExistsError) {
95
- // swallow the error if the user wants us to
96
- }
97
- else {
98
- throw err;
99
- }
87
+ else {
88
+ throw err;
100
89
  }
101
- }), callback);
102
- });
90
+ }
91
+ }, callback);
103
92
  }
104
93
  /**
105
94
  * Creates a new query index.
@@ -110,25 +99,23 @@ class QueryIndexManager {
110
99
  * @param options Optional parameters for this operation.
111
100
  * @param callback A node-style callback to be invoked after execution.
112
101
  */
113
- createIndex(bucketName, indexName, fields, options, callback) {
114
- return __awaiter(this, arguments, void 0, function* () {
115
- if (options instanceof Function) {
116
- callback = arguments[2];
117
- options = undefined;
118
- }
119
- if (!options) {
120
- options = {};
121
- }
122
- return this._createIndex(bucketName, {
123
- name: indexName,
124
- fields: fields,
125
- ignoreIfExists: options.ignoreIfExists,
126
- numReplicas: options.numReplicas,
127
- deferred: options.deferred,
128
- parentSpan: options.parentSpan,
129
- timeout: options.timeout,
130
- }, callback);
131
- });
102
+ async createIndex(bucketName, indexName, fields, options, callback) {
103
+ if (options instanceof Function) {
104
+ callback = arguments[3];
105
+ options = undefined;
106
+ }
107
+ if (!options) {
108
+ options = {};
109
+ }
110
+ return this._createIndex(bucketName, {
111
+ name: indexName,
112
+ fields: fields,
113
+ ignoreIfExists: options.ignoreIfExists,
114
+ numReplicas: options.numReplicas,
115
+ deferred: options.deferred,
116
+ parentSpan: options.parentSpan,
117
+ timeout: options.timeout,
118
+ }, callback);
132
119
  }
133
120
  /**
134
121
  * Creates a new primary query index.
@@ -137,51 +124,47 @@ class QueryIndexManager {
137
124
  * @param options Optional parameters for this operation.
138
125
  * @param callback A node-style callback to be invoked after execution.
139
126
  */
140
- createPrimaryIndex(bucketName, options, callback) {
141
- return __awaiter(this, arguments, void 0, function* () {
142
- if (options instanceof Function) {
143
- callback = arguments[0];
144
- options = undefined;
127
+ async createPrimaryIndex(bucketName, options, callback) {
128
+ if (options instanceof Function) {
129
+ callback = arguments[1];
130
+ options = undefined;
131
+ }
132
+ if (!options) {
133
+ options = {};
134
+ }
135
+ return this._createIndex(bucketName, {
136
+ name: options.name,
137
+ ignoreIfExists: options.ignoreIfExists,
138
+ deferred: options.deferred,
139
+ parentSpan: options.parentSpan,
140
+ timeout: options.timeout,
141
+ }, callback);
142
+ }
143
+ async _dropIndex(bucketName, options, callback) {
144
+ const timeout = options.timeout;
145
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
146
+ let qs = '';
147
+ if (!options.name) {
148
+ qs += 'DROP PRIMARY INDEX `' + bucketName + '`';
145
149
  }
146
- if (!options) {
147
- options = {};
150
+ else {
151
+ qs += 'DROP INDEX `' + bucketName + '`.`' + options.name + '`';
148
152
  }
149
- return this._createIndex(bucketName, {
150
- name: options.name,
151
- ignoreIfExists: options.ignoreIfExists,
152
- deferred: options.deferred,
153
- parentSpan: options.parentSpan,
154
- timeout: options.timeout,
155
- }, callback);
156
- });
157
- }
158
- _dropIndex(bucketName, options, callback) {
159
- return __awaiter(this, void 0, void 0, function* () {
160
- const timeout = options.timeout;
161
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
162
- let qs = '';
163
- if (!options.name) {
164
- qs += 'DROP PRIMARY INDEX `' + bucketName + '`';
153
+ try {
154
+ await this._cluster.query(qs, {
155
+ parentSpan: options.parentSpan,
156
+ timeout: timeout,
157
+ });
158
+ }
159
+ catch (err) {
160
+ if (options.ignoreIfNotExists && err instanceof errors_1.IndexNotFoundError) {
161
+ // swallow the error if the user wants us to
165
162
  }
166
163
  else {
167
- qs += 'DROP INDEX `' + bucketName + '`.`' + options.name + '`';
164
+ throw err;
168
165
  }
169
- try {
170
- yield this._cluster.query(qs, {
171
- parentSpan: options.parentSpan,
172
- timeout: timeout,
173
- });
174
- }
175
- catch (err) {
176
- if (options.ignoreIfNotExists && err instanceof errors_1.IndexNotFoundError) {
177
- // swallow the error if the user wants us to
178
- }
179
- else {
180
- throw err;
181
- }
182
- }
183
- }), callback);
184
- });
166
+ }
167
+ }, callback);
185
168
  }
186
169
  /**
187
170
  * Drops an existing query index.
@@ -191,22 +174,20 @@ class QueryIndexManager {
191
174
  * @param options Optional parameters for this operation.
192
175
  * @param callback A node-style callback to be invoked after execution.
193
176
  */
194
- dropIndex(bucketName, indexName, options, callback) {
195
- return __awaiter(this, arguments, void 0, function* () {
196
- if (options instanceof Function) {
197
- callback = arguments[2];
198
- options = undefined;
199
- }
200
- if (!options) {
201
- options = {};
202
- }
203
- return this._dropIndex(bucketName, {
204
- name: indexName,
205
- ignoreIfNotExists: options.ignoreIfNotExists,
206
- parentSpan: options.parentSpan,
207
- timeout: options.timeout,
208
- }, callback);
209
- });
177
+ async dropIndex(bucketName, indexName, options, callback) {
178
+ if (options instanceof Function) {
179
+ callback = arguments[2];
180
+ options = undefined;
181
+ }
182
+ if (!options) {
183
+ options = {};
184
+ }
185
+ return this._dropIndex(bucketName, {
186
+ name: indexName,
187
+ ignoreIfNotExists: options.ignoreIfNotExists,
188
+ parentSpan: options.parentSpan,
189
+ timeout: options.timeout,
190
+ }, callback);
210
191
  }
211
192
  /**
212
193
  * Drops an existing primary index.
@@ -215,22 +196,20 @@ class QueryIndexManager {
215
196
  * @param options Optional parameters for this operation.
216
197
  * @param callback A node-style callback to be invoked after execution.
217
198
  */
218
- dropPrimaryIndex(bucketName, options, callback) {
219
- return __awaiter(this, arguments, void 0, function* () {
220
- if (options instanceof Function) {
221
- callback = arguments[0];
222
- options = undefined;
223
- }
224
- if (!options) {
225
- options = {};
226
- }
227
- return this._dropIndex(bucketName, {
228
- name: options.name,
229
- ignoreIfNotExists: options.ignoreIfNotExists,
230
- parentSpan: options.parentSpan,
231
- timeout: options.timeout,
232
- }, callback);
233
- });
199
+ async dropPrimaryIndex(bucketName, options, callback) {
200
+ if (options instanceof Function) {
201
+ callback = arguments[1];
202
+ options = undefined;
203
+ }
204
+ if (!options) {
205
+ options = {};
206
+ }
207
+ return this._dropIndex(bucketName, {
208
+ name: options.name,
209
+ ignoreIfNotExists: options.ignoreIfNotExists,
210
+ parentSpan: options.parentSpan,
211
+ timeout: options.timeout,
212
+ }, callback);
234
213
  }
235
214
  /**
236
215
  * Returns a list of indexes for a specific bucket.
@@ -239,40 +218,38 @@ class QueryIndexManager {
239
218
  * @param options Optional parameters for this operation.
240
219
  * @param callback A node-style callback to be invoked after execution.
241
220
  */
242
- getAllIndexes(bucketName, options, callback) {
243
- return __awaiter(this, arguments, void 0, function* () {
244
- if (options instanceof Function) {
245
- callback = arguments[1];
246
- options = undefined;
247
- }
248
- if (!options) {
249
- options = {};
250
- }
251
- const qs = `SELECT idx.* FROM system:indexes AS idx
221
+ async getAllIndexes(bucketName, options, callback) {
222
+ if (options instanceof Function) {
223
+ callback = arguments[1];
224
+ options = undefined;
225
+ }
226
+ if (!options) {
227
+ options = {};
228
+ }
229
+ const qs = `SELECT idx.* FROM system:indexes AS idx
252
230
  WHERE (
253
231
  (\`bucket_id\` IS MISSING AND \`keyspace_id\`="${bucketName}")
254
232
  OR \`bucket_id\`="${bucketName}"
255
233
  ) AND \`using\`="gsi" ORDER BY is_primary DESC, name ASC`;
256
- const parentSpan = options.parentSpan;
257
- const timeout = options.timeout;
258
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
259
- const res = yield this._cluster.query(qs, {
260
- parentSpan: parentSpan,
261
- timeout: timeout,
262
- });
263
- const indexes = res.rows.map((row) => new QueryIndex({
264
- name: row.name,
265
- isPrimary: row.is_primary,
266
- type: row.using,
267
- state: row.state,
268
- keyspace: row.keyspace_id,
269
- indexKey: row.index_key,
270
- condition: row.condition,
271
- partition: row.partition,
272
- }));
273
- return indexes;
274
- }), callback);
275
- });
234
+ const parentSpan = options.parentSpan;
235
+ const timeout = options.timeout;
236
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
237
+ const res = await this._cluster.query(qs, {
238
+ parentSpan: parentSpan,
239
+ timeout: timeout,
240
+ });
241
+ const indexes = res.rows.map((row) => new QueryIndex({
242
+ name: row.name,
243
+ isPrimary: row.is_primary,
244
+ type: row.using,
245
+ state: row.state,
246
+ keyspace: row.keyspace_id,
247
+ indexKey: row.index_key,
248
+ condition: row.condition,
249
+ partition: row.partition,
250
+ }));
251
+ return indexes;
252
+ }, callback);
276
253
  }
277
254
  /**
278
255
  * Starts building any indexes which were previously created with deferred=true.
@@ -281,49 +258,47 @@ class QueryIndexManager {
281
258
  * @param options Optional parameters for this operation.
282
259
  * @param callback A node-style callback to be invoked after execution.
283
260
  */
284
- buildDeferredIndexes(bucketName, options, callback) {
285
- return __awaiter(this, arguments, void 0, function* () {
286
- if (options instanceof Function) {
287
- callback = arguments[1];
288
- options = undefined;
289
- }
290
- if (!options) {
291
- options = {};
261
+ async buildDeferredIndexes(bucketName, options, callback) {
262
+ if (options instanceof Function) {
263
+ callback = arguments[1];
264
+ options = undefined;
265
+ }
266
+ if (!options) {
267
+ options = {};
268
+ }
269
+ const parentSpan = options.parentSpan;
270
+ const timeout = options.timeout;
271
+ const timer = new utilities_1.CompoundTimeout(timeout);
272
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
273
+ const indexes = await this.getAllIndexes(bucketName, {
274
+ parentSpan: parentSpan,
275
+ timeout: timer.left(),
276
+ });
277
+ // Filter out the index names that need to be built
278
+ const deferredList = indexes
279
+ .filter((index) => index.state === 'deferred' || index.state === 'pending')
280
+ .map((index) => index.name);
281
+ // If there are no deferred indexes, we have nothing to do.
282
+ if (deferredList.length === 0) {
283
+ return [];
292
284
  }
293
- const parentSpan = options.parentSpan;
294
- const timeout = options.timeout;
295
- const timer = new utilities_1.CompoundTimeout(timeout);
296
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
297
- const indexes = yield this.getAllIndexes(bucketName, {
298
- parentSpan: parentSpan,
299
- timeout: timer.left(),
300
- });
301
- // Filter out the index names that need to be built
302
- const deferredList = indexes
303
- .filter((index) => index.state === 'deferred' || index.state === 'pending')
304
- .map((index) => index.name);
305
- // If there are no deferred indexes, we have nothing to do.
306
- if (deferredList.length === 0) {
307
- return [];
308
- }
309
- let qs = '';
310
- qs += 'BUILD INDEX ON `' + bucketName + '` ';
311
- qs += '(';
312
- for (let j = 0; j < deferredList.length; ++j) {
313
- if (j > 0) {
314
- qs += ', ';
315
- }
316
- qs += '`' + deferredList[j] + '`';
285
+ let qs = '';
286
+ qs += 'BUILD INDEX ON `' + bucketName + '` ';
287
+ qs += '(';
288
+ for (let j = 0; j < deferredList.length; ++j) {
289
+ if (j > 0) {
290
+ qs += ', ';
317
291
  }
318
- qs += ')';
319
- // Run our deferred build query
320
- yield this._cluster.query(qs, {
321
- timeout: timer.left(),
322
- });
323
- // Return the list of indices that we built
324
- return deferredList;
325
- }), callback);
326
- });
292
+ qs += '`' + deferredList[j] + '`';
293
+ }
294
+ qs += ')';
295
+ // Run our deferred build query
296
+ await this._cluster.query(qs, {
297
+ timeout: timer.left(),
298
+ });
299
+ // Return the list of indices that we built
300
+ return deferredList;
301
+ }, callback);
327
302
  }
328
303
  /**
329
304
  * Waits for a number of indexes to finish creation and be ready to use.
@@ -334,54 +309,52 @@ class QueryIndexManager {
334
309
  * @param options Optional parameters for this operation.
335
310
  * @param callback A node-style callback to be invoked after execution.
336
311
  */
337
- watchIndexes(bucketName, indexNames, timeout, options, callback) {
338
- return __awaiter(this, arguments, void 0, function* () {
339
- if (options instanceof Function) {
340
- callback = arguments[3];
341
- options = undefined;
342
- }
343
- if (!options) {
344
- options = {};
345
- }
346
- if (options.watchPrimary) {
347
- indexNames = [...indexNames, '#primary'];
348
- }
349
- const parentSpan = options.parentSpan;
350
- const timer = new utilities_1.CompoundTimeout(timeout);
351
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
352
- let curInterval = 50;
353
- for (;;) {
354
- // Get all the indexes that are currently registered
355
- const foundIdxs = yield this.getAllIndexes(bucketName, {
356
- parentSpan: parentSpan,
357
- timeout: timer.left(),
358
- });
359
- const onlineIdxs = foundIdxs.filter((idx) => idx.state === 'online');
360
- const onlineIdxNames = onlineIdxs.map((idx) => idx.name);
361
- // Check if all the indexes we want are online
362
- let allOnline = true;
363
- indexNames.forEach((indexName) => {
364
- allOnline = allOnline && onlineIdxNames.indexOf(indexName) !== -1;
365
- });
366
- // If all the indexes are online, we've succeeded
367
- if (allOnline) {
368
- break;
369
- }
370
- // Add 500 to our interval to a max of 1000
371
- curInterval = Math.min(1000, curInterval + 500);
372
- // Make sure we don't go past our user-specified duration
373
- const userTimeLeft = timer.left();
374
- if (userTimeLeft !== undefined) {
375
- curInterval = Math.min(curInterval, userTimeLeft);
376
- }
377
- if (curInterval <= 0) {
378
- throw new errors_1.CouchbaseError('Failed to find all indexes online within the alloted time.');
379
- }
380
- // Wait until curInterval expires
381
- yield new Promise((resolve) => setTimeout(() => resolve(true), curInterval));
312
+ async watchIndexes(bucketName, indexNames, timeout, options, callback) {
313
+ if (options instanceof Function) {
314
+ callback = arguments[3];
315
+ options = undefined;
316
+ }
317
+ if (!options) {
318
+ options = {};
319
+ }
320
+ if (options.watchPrimary) {
321
+ indexNames = [...indexNames, '#primary'];
322
+ }
323
+ const parentSpan = options.parentSpan;
324
+ const timer = new utilities_1.CompoundTimeout(timeout);
325
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
326
+ let curInterval = 50;
327
+ for (;;) {
328
+ // Get all the indexes that are currently registered
329
+ const foundIdxs = await this.getAllIndexes(bucketName, {
330
+ parentSpan: parentSpan,
331
+ timeout: timer.left(),
332
+ });
333
+ const onlineIdxs = foundIdxs.filter((idx) => idx.state === 'online');
334
+ const onlineIdxNames = onlineIdxs.map((idx) => idx.name);
335
+ // Check if all the indexes we want are online
336
+ let allOnline = true;
337
+ indexNames.forEach((indexName) => {
338
+ allOnline = allOnline && onlineIdxNames.indexOf(indexName) !== -1;
339
+ });
340
+ // If all the indexes are online, we've succeeded
341
+ if (allOnline) {
342
+ break;
382
343
  }
383
- }), callback);
384
- });
344
+ // Add 500 to our interval to a max of 1000
345
+ curInterval = Math.min(1000, curInterval + 500);
346
+ // Make sure we don't go past our user-specified duration
347
+ const userTimeLeft = timer.left();
348
+ if (userTimeLeft !== undefined) {
349
+ curInterval = Math.min(curInterval, userTimeLeft);
350
+ }
351
+ if (curInterval <= 0) {
352
+ throw new errors_1.CouchbaseError('Failed to find all indexes online within the alloted time.');
353
+ }
354
+ // Wait until curInterval expires
355
+ await new Promise((resolve) => setTimeout(() => resolve(true), curInterval));
356
+ }
357
+ }, callback);
385
358
  }
386
359
  }
387
360
  exports.QueryIndexManager = QueryIndexManager;
package/dist/scope.js CHANGED
@@ -76,7 +76,10 @@ class Scope {
76
76
  const bucket = this.bucket;
77
77
  const exec = new queryexecutor_1.QueryExecutor(bucket.conn);
78
78
  const options_ = options;
79
- return utilities_1.PromiseHelper.wrapAsync(() => exec.query(statement, Object.assign(Object.assign({}, options_), { queryContext: `${bucket.name}.${this.name}` })), callback);
79
+ return utilities_1.PromiseHelper.wrapAsync(() => exec.query(statement, {
80
+ ...options_,
81
+ queryContext: `${bucket.name}.${this.name}`,
82
+ }), callback);
80
83
  }
81
84
  /**
82
85
  * Executes an analytics query against the cluster scoped this scope.
@@ -96,7 +99,10 @@ class Scope {
96
99
  const bucket = this.bucket;
97
100
  const exec = new analyticsexecutor_1.AnalyticsExecutor(bucket.conn);
98
101
  const options_ = options;
99
- return utilities_1.PromiseHelper.wrapAsync(() => exec.query(statement, Object.assign(Object.assign({}, options_), { queryContext: `${bucket.name}.${this.name}` })), callback);
102
+ return utilities_1.PromiseHelper.wrapAsync(() => exec.query(statement, {
103
+ ...options_,
104
+ queryContext: `${bucket.name}.${this.name}`,
105
+ }), callback);
100
106
  }
101
107
  }
102
108
  exports.Scope = Scope;
@@ -50,6 +50,9 @@ class SearchExecutor {
50
50
  if (options.disableScoring) {
51
51
  queryObj.score = 'none';
52
52
  }
53
+ if (options.includeLocations !== undefined) {
54
+ queryObj.includeLocations = options.includeLocations;
55
+ }
53
56
  if (options.consistency) {
54
57
  queryObjCtl.consistency = {
55
58
  level: options.consistency,