couchbase 3.2.0 → 3.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/README.md +24 -18
  2. package/binding.gyp +88 -85
  3. package/deps/lcb/CMakeLists.txt +1 -1
  4. package/deps/lcb/CONTRIBUTING.md +1 -1
  5. package/deps/lcb/README.markdown +2 -2
  6. package/deps/lcb/RELEASE_NOTES.markdown +99 -14
  7. package/deps/lcb/cmake/Modules/GetVersionInfo.cmake +1 -1
  8. package/deps/lcb/contrib/cbsasl/src/scram-sha/scram_utils.cc +22 -26
  9. package/deps/lcb/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp +20 -7
  10. package/deps/lcb/doc/Doxyfile +1 -1
  11. package/deps/lcb/example/CMakeLists.txt +4 -4
  12. package/deps/lcb/example/libuvdirect/main.c +39 -12
  13. package/deps/lcb/example/minimal/durability.cc +149 -0
  14. package/deps/lcb/example/minimal/query.c +11 -9
  15. package/deps/lcb/gyp_config/common/libcouchbase/configuration.h +3 -3
  16. package/deps/lcb/gyp_config/linux/arm64/config.h +243 -0
  17. package/deps/lcb/include/libcouchbase/couchbase.h +80 -5
  18. package/deps/lcb/include/libcouchbase/error.h +2 -0
  19. package/deps/lcb/include/libcouchbase/ixmgmt.h +15 -10
  20. package/deps/lcb/include/libcouchbase/tracing.h +2 -2
  21. package/deps/lcb/include/memcached/protocol_binary.h +21 -0
  22. package/deps/lcb/libcouchbase.gyp +347 -349
  23. package/deps/lcb/packaging/deb/control +1 -1
  24. package/deps/lcb/src/analytics/analytics_handle.cc +13 -5
  25. package/deps/lcb/src/analytics/analytics_handle.hh +29 -0
  26. package/deps/lcb/src/bootstrap.cc +6 -3
  27. package/deps/lcb/src/capi/cmd_analytics.cc +12 -1
  28. package/deps/lcb/src/capi/cmd_analytics.hh +30 -0
  29. package/deps/lcb/src/capi/cmd_counter.hh +23 -0
  30. package/deps/lcb/src/capi/cmd_exists.hh +24 -1
  31. package/deps/lcb/src/capi/cmd_get.hh +22 -0
  32. package/deps/lcb/src/capi/cmd_get_replica.hh +23 -0
  33. package/deps/lcb/src/capi/cmd_http.hh +7 -0
  34. package/deps/lcb/src/capi/cmd_query.cc +11 -1
  35. package/deps/lcb/src/capi/cmd_query.hh +31 -0
  36. package/deps/lcb/src/capi/cmd_remove.hh +23 -0
  37. package/deps/lcb/src/capi/cmd_search.cc +6 -0
  38. package/deps/lcb/src/capi/cmd_search.hh +23 -0
  39. package/deps/lcb/src/capi/cmd_store.hh +33 -21
  40. package/deps/lcb/src/capi/cmd_subdoc.hh +35 -0
  41. package/deps/lcb/src/capi/cmd_touch.hh +23 -0
  42. package/deps/lcb/src/capi/cmd_unlock.hh +23 -0
  43. package/deps/lcb/src/capi/cmd_view.hh +6 -0
  44. package/deps/lcb/src/capi/collection_qualifier.hh +2 -2
  45. package/deps/lcb/src/cntl.cc +45 -11
  46. package/deps/lcb/src/crypto.cc +2 -2
  47. package/deps/lcb/src/dns-srv.cc +5 -3
  48. package/deps/lcb/src/errmap.cc +5 -9
  49. package/deps/lcb/src/errmap.h +7 -3
  50. package/deps/lcb/src/handler.cc +24 -18
  51. package/deps/lcb/src/hostlist.h +2 -2
  52. package/deps/lcb/src/http/http-priv.h +2 -2
  53. package/deps/lcb/src/http/http.cc +5 -2
  54. package/deps/lcb/src/instance.cc +20 -11
  55. package/deps/lcb/src/internal.h +9 -0
  56. package/deps/lcb/src/lcbio/connect.cc +14 -2
  57. package/deps/lcb/src/lcbio/connect.h +2 -2
  58. package/deps/lcb/src/lcbio/ctx.cc +4 -2
  59. package/deps/lcb/src/lcbio/ioutils.cc +9 -10
  60. package/deps/lcb/src/lcbio/manager.cc +1 -1
  61. package/deps/lcb/src/mcserver/mcserver.cc +9 -6
  62. package/deps/lcb/src/mcserver/negotiate.cc +39 -17
  63. package/deps/lcb/src/n1ql/ixmgmt.cc +1 -2
  64. package/deps/lcb/src/n1ql/query_handle.cc +41 -19
  65. package/deps/lcb/src/n1ql/query_handle.hh +28 -1
  66. package/deps/lcb/src/operations/counter.cc +18 -5
  67. package/deps/lcb/src/operations/exists.cc +25 -4
  68. package/deps/lcb/src/operations/get.cc +39 -19
  69. package/deps/lcb/src/operations/get_replica.cc +28 -8
  70. package/deps/lcb/src/operations/observe.cc +1 -1
  71. package/deps/lcb/src/operations/ping.cc +8 -8
  72. package/deps/lcb/src/operations/pktfwd.cc +2 -1
  73. package/deps/lcb/src/operations/remove.cc +39 -22
  74. package/deps/lcb/src/operations/store.cc +18 -5
  75. package/deps/lcb/src/operations/subdoc.cc +18 -6
  76. package/deps/lcb/src/operations/touch.cc +34 -16
  77. package/deps/lcb/src/operations/unlock.cc +24 -5
  78. package/deps/lcb/src/packetutils.h +3 -2
  79. package/deps/lcb/src/retryq.cc +24 -5
  80. package/deps/lcb/src/search/search.cc +1 -0
  81. package/deps/lcb/src/search/search_handle.cc +30 -8
  82. package/deps/lcb/src/search/search_handle.hh +29 -0
  83. package/deps/lcb/src/settings.cc +1 -1
  84. package/deps/lcb/src/ssl/ssl_common.c +6 -7
  85. package/deps/lcb/src/tracing/span.cc +47 -14
  86. package/deps/lcb/src/tracing/tracer.cc +11 -2
  87. package/deps/lcb/src/tracing/tracing-internal.h +105 -93
  88. package/deps/lcb/src/utilities.cc +43 -0
  89. package/deps/lcb/src/utilities.h +53 -0
  90. package/deps/lcb/src/vbucket/vbucket.c +34 -33
  91. package/deps/lcb/src/views/view_handle.cc +13 -5
  92. package/deps/lcb/src/views/view_handle.hh +29 -0
  93. package/deps/lcb/tests/CMakeLists.txt +21 -0
  94. package/deps/lcb/tests/basic/t_ctlcodes.cc +24 -3
  95. package/deps/lcb/tests/basic/t_jsparse.cc +8 -0
  96. package/deps/lcb/tests/basic/t_n1qlstrings.cc +73 -0
  97. package/deps/lcb/tests/iotests/mock-environment.cc +30 -1
  98. package/deps/lcb/tests/iotests/mock-environment.h +49 -0
  99. package/deps/lcb/tests/iotests/mock-unit-test.cc +104 -6
  100. package/deps/lcb/tests/iotests/mock-unit-test.h +34 -0
  101. package/deps/lcb/tests/iotests/t_collections.cc +1 -1
  102. package/deps/lcb/tests/iotests/t_confmon.cc +4 -2
  103. package/deps/lcb/tests/iotests/t_get.cc +109 -7
  104. package/deps/lcb/tests/iotests/t_http.cc +9 -4
  105. package/deps/lcb/tests/iotests/t_lock.cc +18 -0
  106. package/deps/lcb/tests/iotests/t_mutate.cc +157 -63
  107. package/deps/lcb/tests/iotests/t_n1ql.cc +330 -33
  108. package/deps/lcb/tests/iotests/t_views.cc +1 -0
  109. package/deps/lcb/tests/iotests/testutil.cc +168 -0
  110. package/deps/lcb/tests/iotests/testutil.h +116 -0
  111. package/deps/lcb/tests/mocksupport/procutil.c +32 -28
  112. package/deps/lcb/tests/mocksupport/server.c +0 -1
  113. package/deps/lcb/tests/mocksupport/timeout.c +2 -2
  114. package/deps/lcb/tools/cbc.cc +7 -0
  115. package/dist/analyticsindexmanager.js +512 -524
  116. package/dist/binding.d.ts +3 -0
  117. package/dist/bindingutilities.js +4 -0
  118. package/dist/bucket.js +1 -1
  119. package/dist/bucketmanager.d.ts +31 -1
  120. package/dist/bucketmanager.js +194 -186
  121. package/dist/cluster.d.ts +7 -0
  122. package/dist/cluster.js +48 -38
  123. package/dist/collection.js +11 -17
  124. package/dist/collectionmanager.js +181 -197
  125. package/dist/connection.d.ts +3 -1
  126. package/dist/connection.js +27 -16
  127. package/dist/couchbase.d.ts +1 -0
  128. package/dist/couchbase.js +3 -13
  129. package/dist/datastructures.js +239 -310
  130. package/dist/diagnosticsexecutor.js +70 -85
  131. package/dist/errors.d.ts +70 -0
  132. package/dist/errors.js +96 -2
  133. package/dist/eventingfunctionmanager.d.ts +804 -0
  134. package/dist/eventingfunctionmanager.js +993 -0
  135. package/dist/httpexecutor.d.ts +2 -1
  136. package/dist/httpexecutor.js +30 -37
  137. package/dist/queryindexmanager.js +240 -266
  138. package/dist/scope.js +10 -4
  139. package/dist/sdspecs.d.ts +1 -1
  140. package/dist/searchexecutor.js +3 -0
  141. package/dist/searchindexmanager.js +240 -271
  142. package/dist/searchquery.d.ts +17 -0
  143. package/dist/searchquery.js +22 -1
  144. package/dist/searchtypes.d.ts +7 -2
  145. package/dist/searchtypes.js +2 -2
  146. package/dist/usermanager.js +251 -264
  147. package/dist/utilities.d.ts +2 -0
  148. package/dist/utilities.js +7 -2
  149. package/dist/viewexecutor.js +1 -1
  150. package/dist/viewindexmanager.js +131 -150
  151. package/package.json +1 -1
  152. package/src/addondata.cpp +58 -0
  153. package/src/addondata.h +40 -0
  154. package/src/binding.cpp +3 -1
  155. package/src/cas.h +2 -2
  156. package/src/connection.cpp +25 -178
  157. package/src/connection.h +8 -65
  158. package/src/connection_ops.cpp +57 -34
  159. package/src/constants.cpp +3 -0
  160. package/src/instance.cpp +235 -0
  161. package/src/instance.h +102 -0
  162. package/src/{connection_callbacks.cpp → instance_callbacks.cpp} +34 -34
  163. package/src/logger.cpp +11 -1
  164. package/src/logger.h +3 -0
  165. package/src/metrics.cpp +10 -0
  166. package/src/metrics.h +3 -0
  167. package/src/mutationtoken.h +2 -2
  168. package/src/opbuilder.h +13 -15
  169. package/src/respreader.cpp +1 -0
  170. package/src/respreader.h +6 -4
  171. package/src/tracespan.h +11 -11
  172. package/src/tracing.cpp +11 -0
  173. package/src/tracing.h +3 -0
  174. package/src/valueparser.h +5 -0
  175. package/deps/lcb/example/observe/durability.c +0 -110
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.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 + '`';
168
- }
169
- try {
170
- yield this._cluster.query(qs, {
171
- parentSpan: options.parentSpan,
172
- timeout: timeout,
173
- });
164
+ throw err;
174
165
  }
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,39 +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
- let qs = '';
252
- qs += 'SELECT idx.* FROM system:indexes AS idx';
253
- qs += ' WHERE keyspace_id="' + bucketName + '"';
254
- qs += ' AND `using`="gsi" ORDER BY is_primary DESC, name ASC';
255
- const parentSpan = options.parentSpan;
256
- const timeout = options.timeout;
257
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
258
- const res = yield this._cluster.query(qs, {
259
- parentSpan: parentSpan,
260
- timeout: timeout,
261
- });
262
- const indexes = res.rows.map((row) => new QueryIndex({
263
- name: row.name,
264
- isPrimary: row.is_primary,
265
- type: row.using,
266
- state: row.state,
267
- keyspace: row.keyspace_id,
268
- indexKey: row.index_key,
269
- condition: row.condition,
270
- partition: row.partition,
271
- }));
272
- return indexes;
273
- }), callback);
274
- });
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
230
+ WHERE (
231
+ (\`bucket_id\` IS MISSING AND \`keyspace_id\`="${bucketName}")
232
+ OR \`bucket_id\`="${bucketName}"
233
+ ) AND \`using\`="gsi" ORDER BY is_primary DESC, name ASC`;
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);
275
253
  }
276
254
  /**
277
255
  * Starts building any indexes which were previously created with deferred=true.
@@ -280,49 +258,47 @@ class QueryIndexManager {
280
258
  * @param options Optional parameters for this operation.
281
259
  * @param callback A node-style callback to be invoked after execution.
282
260
  */
283
- buildDeferredIndexes(bucketName, options, callback) {
284
- return __awaiter(this, arguments, void 0, function* () {
285
- if (options instanceof Function) {
286
- callback = arguments[1];
287
- options = undefined;
288
- }
289
- if (!options) {
290
- 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 [];
291
284
  }
292
- const parentSpan = options.parentSpan;
293
- const timeout = options.timeout;
294
- const timer = new utilities_1.CompoundTimeout(timeout);
295
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
296
- const indexes = yield this.getAllIndexes(bucketName, {
297
- parentSpan: parentSpan,
298
- timeout: timer.left(),
299
- });
300
- // Filter out the index names that need to be built
301
- const deferredList = indexes
302
- .filter((index) => index.state === 'deferred' || index.state === 'pending')
303
- .map((index) => index.name);
304
- // If there are no deferred indexes, we have nothing to do.
305
- if (deferredList.length === 0) {
306
- return [];
307
- }
308
- let qs = '';
309
- qs += 'BUILD INDEX ON `' + bucketName + '` ';
310
- qs += '(';
311
- for (let j = 0; j < deferredList.length; ++j) {
312
- if (j > 0) {
313
- qs += ', ';
314
- }
315
- 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 += ', ';
316
291
  }
317
- qs += ')';
318
- // Run our deferred build query
319
- yield this._cluster.query(qs, {
320
- timeout: timer.left(),
321
- });
322
- // Return the list of indices that we built
323
- return deferredList;
324
- }), callback);
325
- });
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);
326
302
  }
327
303
  /**
328
304
  * Waits for a number of indexes to finish creation and be ready to use.
@@ -333,54 +309,52 @@ class QueryIndexManager {
333
309
  * @param options Optional parameters for this operation.
334
310
  * @param callback A node-style callback to be invoked after execution.
335
311
  */
336
- watchIndexes(bucketName, indexNames, timeout, options, callback) {
337
- return __awaiter(this, arguments, void 0, function* () {
338
- if (options instanceof Function) {
339
- callback = arguments[3];
340
- options = undefined;
341
- }
342
- if (!options) {
343
- options = {};
344
- }
345
- if (options.watchPrimary) {
346
- indexNames = [...indexNames, '#primary'];
347
- }
348
- const parentSpan = options.parentSpan;
349
- const timer = new utilities_1.CompoundTimeout(timeout);
350
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
351
- let curInterval = 50;
352
- for (;;) {
353
- // Get all the indexes that are currently registered
354
- const foundIdxs = yield this.getAllIndexes(bucketName, {
355
- parentSpan: parentSpan,
356
- timeout: timer.left(),
357
- });
358
- const onlineIdxs = foundIdxs.filter((idx) => idx.state === 'online');
359
- const onlineIdxNames = onlineIdxs.map((idx) => idx.name);
360
- // Check if all the indexes we want are online
361
- let allOnline = true;
362
- indexNames.forEach((indexName) => {
363
- allOnline = allOnline && onlineIdxNames.indexOf(indexName) !== -1;
364
- });
365
- // If all the indexes are online, we've succeeded
366
- if (allOnline) {
367
- break;
368
- }
369
- // Add 500 to our interval to a max of 1000
370
- curInterval = Math.min(curInterval, curInterval + 500);
371
- // Make sure we don't go past our user-specified duration
372
- const userTimeLeft = timer.left();
373
- if (userTimeLeft !== undefined) {
374
- curInterval = Math.min(curInterval, userTimeLeft);
375
- }
376
- if (curInterval <= 0) {
377
- throw new errors_1.CouchbaseError('Failed to find all indexes online within the alloted time.');
378
- }
379
- // Wait until curInterval expires
380
- 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;
381
343
  }
382
- }), callback);
383
- });
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);
384
358
  }
385
359
  }
386
360
  exports.QueryIndexManager = QueryIndexManager;
package/dist/scope.js CHANGED
@@ -67,7 +67,7 @@ class Scope {
67
67
  */
68
68
  query(statement, options, callback) {
69
69
  if (options instanceof Function) {
70
- callback = arguments[0];
70
+ callback = arguments[1];
71
71
  options = undefined;
72
72
  }
73
73
  if (!options) {
@@ -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.
@@ -87,7 +90,7 @@ class Scope {
87
90
  */
88
91
  analyticsQuery(statement, options, callback) {
89
92
  if (options instanceof Function) {
90
- callback = arguments[0];
93
+ callback = arguments[1];
91
94
  options = undefined;
92
95
  }
93
96
  if (!options) {
@@ -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;
package/dist/sdspecs.d.ts CHANGED
@@ -180,7 +180,7 @@ export declare class MutateInSpec {
180
180
  * Whether this operation should reference the document body or the extended
181
181
  * attributes data for the document.
182
182
  */
183
- static insert(path: string, value: any, options: {
183
+ static insert(path: string, value: any, options?: {
184
184
  createPath?: boolean;
185
185
  xattr?: boolean;
186
186
  }): MutateInSpec;
@@ -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,