couchbase 4.2.9 → 4.2.11-rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. package/deps/couchbase-cxx-client/CMakeLists.txt +4 -0
  2. package/deps/couchbase-cxx-client/cmake/CompilerWarnings.cmake +7 -3
  3. package/deps/couchbase-cxx-client/cmake/OpenSSL.cmake +1 -0
  4. package/deps/couchbase-cxx-client/core/bucket.cxx +67 -2
  5. package/deps/couchbase-cxx-client/core/bucket.hxx +2 -1
  6. package/deps/couchbase-cxx-client/core/cluster.cxx +65 -1
  7. package/deps/couchbase-cxx-client/core/impl/bucket.cxx +24 -0
  8. package/deps/couchbase-cxx-client/core/impl/cluster.cxx +73 -0
  9. package/deps/couchbase-cxx-client/core/impl/collection.cxx +2 -2
  10. package/deps/couchbase-cxx-client/core/impl/diagnostics.cxx +294 -0
  11. package/deps/couchbase-cxx-client/core/impl/diagnostics.hxx +39 -0
  12. package/deps/couchbase-cxx-client/core/impl/query_index_manager.cxx +6 -6
  13. package/deps/couchbase-cxx-client/core/impl/scope.cxx +19 -4
  14. package/deps/couchbase-cxx-client/core/impl/search.cxx +75 -2
  15. package/deps/couchbase-cxx-client/core/impl/search.hxx +8 -0
  16. package/deps/couchbase-cxx-client/core/impl/search_index_manager.cxx +261 -18
  17. package/deps/couchbase-cxx-client/core/impl/search_request.cxx +139 -0
  18. package/deps/couchbase-cxx-client/core/impl/vector_query.cxx +42 -0
  19. package/deps/couchbase-cxx-client/core/impl/vector_search.cxx +40 -0
  20. package/deps/couchbase-cxx-client/core/io/http_session.hxx +6 -3
  21. package/deps/couchbase-cxx-client/core/io/http_session_manager.hxx +7 -1
  22. package/deps/couchbase-cxx-client/core/io/mcbp_command.hxx +10 -0
  23. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +48 -33
  24. package/deps/couchbase-cxx-client/core/io/mcbp_session.hxx +2 -0
  25. package/deps/couchbase-cxx-client/core/logger/logger.cxx +1 -1
  26. package/deps/couchbase-cxx-client/core/management/design_document.hxx +1 -1
  27. package/deps/couchbase-cxx-client/core/meta/features.hxx +26 -1
  28. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_all_replicas.hxx +1 -1
  29. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_any_replica.hxx +1 -1
  30. package/deps/couchbase-cxx-client/core/operations/document_query.cxx +8 -3
  31. package/deps/couchbase-cxx-client/core/operations/document_search.cxx +37 -1
  32. package/deps/couchbase-cxx-client/core/operations/document_search.hxx +11 -0
  33. package/deps/couchbase-cxx-client/core/operations/document_view.cxx +3 -0
  34. package/deps/couchbase-cxx-client/core/operations/document_view.hxx +1 -0
  35. package/deps/couchbase-cxx-client/core/operations/management/collection_create.cxx +7 -6
  36. package/deps/couchbase-cxx-client/core/operations/management/collection_create.hxx +1 -1
  37. package/deps/couchbase-cxx-client/core/operations/management/collection_update.cxx +7 -8
  38. package/deps/couchbase-cxx-client/core/operations/management/collection_update.hxx +1 -1
  39. package/deps/couchbase-cxx-client/core/operations/management/error_utils.cxx +3 -0
  40. package/deps/couchbase-cxx-client/core/operations/management/query_index_create.cxx +24 -13
  41. package/deps/couchbase-cxx-client/core/operations/management/query_index_create.hxx +1 -1
  42. package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.cxx +17 -1
  43. package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.hxx +3 -0
  44. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.cxx +21 -1
  45. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.hxx +3 -0
  46. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.cxx +21 -1
  47. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.hxx +3 -0
  48. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.cxx +21 -1
  49. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.hxx +3 -0
  50. package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.cxx +17 -1
  51. package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.hxx +3 -0
  52. package/deps/couchbase-cxx-client/core/operations/management/search_index_get.cxx +17 -1
  53. package/deps/couchbase-cxx-client/core/operations/management/search_index_get.hxx +2 -0
  54. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.cxx +39 -22
  55. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.hxx +3 -0
  56. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.cxx +18 -1
  57. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.hxx +3 -0
  58. package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.cxx +17 -1
  59. package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.hxx +3 -0
  60. package/deps/couchbase-cxx-client/core/origin.cxx +14 -0
  61. package/deps/couchbase-cxx-client/core/origin.hxx +6 -0
  62. package/deps/couchbase-cxx-client/core/protocol/status.cxx +2 -0
  63. package/deps/couchbase-cxx-client/core/protocol/status.hxx +1 -0
  64. package/deps/couchbase-cxx-client/core/topology/capabilities.hxx +70 -1
  65. package/deps/couchbase-cxx-client/core/topology/capabilities_fmt.hxx +30 -2
  66. package/deps/couchbase-cxx-client/core/topology/collections_manifest.hxx +1 -1
  67. package/deps/couchbase-cxx-client/core/topology/collections_manifest_json.hxx +1 -1
  68. package/deps/couchbase-cxx-client/core/topology/configuration.hxx +1 -34
  69. package/deps/couchbase-cxx-client/core/topology/configuration_fmt.hxx +2 -2
  70. package/deps/couchbase-cxx-client/core/topology/configuration_json.hxx +43 -20
  71. package/deps/couchbase-cxx-client/core/transactions/internal/exceptions_internal.hxx +5 -0
  72. package/deps/couchbase-cxx-client/core/transactions/internal/utils.hxx +4 -0
  73. package/deps/couchbase-cxx-client/core/vector_query_combination.hxx +23 -0
  74. package/deps/couchbase-cxx-client/couchbase/bucket.hxx +29 -0
  75. package/deps/couchbase-cxx-client/couchbase/cluster.hxx +110 -0
  76. package/deps/couchbase-cxx-client/couchbase/codec/json_transcoder.hxx +1 -1
  77. package/deps/couchbase-cxx-client/couchbase/codec/raw_binary_transcoder.hxx +2 -1
  78. package/deps/couchbase-cxx-client/couchbase/codec/raw_json_transcoder.hxx +78 -0
  79. package/deps/couchbase-cxx-client/couchbase/codec/raw_string_transcoder.hxx +72 -0
  80. package/deps/couchbase-cxx-client/couchbase/collection_query_index_manager.hxx +80 -11
  81. package/deps/couchbase-cxx-client/couchbase/create_collection_options.hxx +29 -1
  82. package/deps/couchbase-cxx-client/couchbase/diagnostics_options.hxx +75 -0
  83. package/deps/couchbase-cxx-client/couchbase/diagnostics_result.hxx +124 -0
  84. package/deps/couchbase-cxx-client/couchbase/endpoint_diagnostics.hxx +206 -0
  85. package/deps/couchbase-cxx-client/couchbase/endpoint_ping_report.hxx +205 -0
  86. package/deps/couchbase-cxx-client/couchbase/fmt/key_value_status_code.hxx +3 -1
  87. package/deps/couchbase-cxx-client/couchbase/get_options.hxx +1 -6
  88. package/deps/couchbase-cxx-client/couchbase/key_value_status_code.hxx +1 -0
  89. package/deps/couchbase-cxx-client/couchbase/management/collection_spec.hxx +1 -1
  90. package/deps/couchbase-cxx-client/couchbase/ping_options.hxx +93 -0
  91. package/deps/couchbase-cxx-client/couchbase/ping_result.hxx +118 -0
  92. package/deps/couchbase-cxx-client/couchbase/query_index_manager.hxx +6 -8
  93. package/deps/couchbase-cxx-client/couchbase/scope.hxx +24 -8
  94. package/deps/couchbase-cxx-client/couchbase/scope_search_index_manager.hxx +291 -0
  95. package/deps/couchbase-cxx-client/couchbase/search_request.hxx +120 -0
  96. package/deps/couchbase-cxx-client/couchbase/service_type.hxx +58 -0
  97. package/deps/couchbase-cxx-client/couchbase/update_collection_options.hxx +32 -3
  98. package/deps/couchbase-cxx-client/couchbase/vector_query.hxx +99 -0
  99. package/deps/couchbase-cxx-client/couchbase/vector_search.hxx +85 -0
  100. package/deps/couchbase-cxx-client/couchbase/vector_search_options.hxx +76 -0
  101. package/dist/binding.d.ts +33 -2
  102. package/dist/binding.js +4 -1
  103. package/dist/bindingutilities.d.ts +16 -3
  104. package/dist/bindingutilities.js +47 -7
  105. package/dist/cluster.d.ts +12 -1
  106. package/dist/cluster.js +22 -0
  107. package/dist/couchbase.d.ts +2 -0
  108. package/dist/couchbase.js +2 -0
  109. package/dist/queryindexmanager.d.ts +4 -4
  110. package/dist/queryindexmanager.js +7 -7
  111. package/dist/scope.d.ts +21 -0
  112. package/dist/scope.js +34 -0
  113. package/dist/scopesearchindexmanager.d.ts +116 -0
  114. package/dist/scopesearchindexmanager.js +406 -0
  115. package/dist/sdspecs.js +10 -9
  116. package/dist/sdutils.d.ts +1 -0
  117. package/dist/sdutils.js +4 -0
  118. package/dist/searchexecutor.d.ts +5 -3
  119. package/dist/searchexecutor.js +27 -4
  120. package/dist/searchindexmanager.d.ts +58 -3
  121. package/dist/searchindexmanager.js +188 -104
  122. package/dist/searchtypes.d.ts +46 -0
  123. package/dist/searchtypes.js +81 -1
  124. package/dist/vectorsearch.d.ts +99 -0
  125. package/dist/vectorsearch.js +132 -0
  126. package/dist/viewexecutor.js +13 -9
  127. package/dist/viewindexmanager.d.ts +70 -7
  128. package/dist/viewindexmanager.js +236 -103
  129. package/dist/viewtypes.d.ts +26 -0
  130. package/dist/viewtypes.js +17 -1
  131. package/package.json +7 -7
  132. package/src/constants.cpp +12 -0
  133. package/src/jstocbpp_autogen.hpp +113 -13
  134. package/tools/gen-bindings-json.py +2 -0
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ViewIndexManager = exports.DesignDocument = exports.DesignDocumentView = void 0;
4
- const errors_1 = require("./errors");
5
- const httpexecutor_1 = require("./httpexecutor");
6
4
  const utilities_1 = require("./utilities");
5
+ const viewtypes_1 = require("./viewtypes");
6
+ const bindingutilities_1 = require("./bindingutilities");
7
7
  /**
8
8
  * Contains information about a view in a design document.
9
9
  *
@@ -27,6 +27,25 @@ class DesignDocumentView {
27
27
  this.map = data.map;
28
28
  this.reduce = data.reduce;
29
29
  }
30
+ /**
31
+ * @internal
32
+ */
33
+ static _toCppData(name, data) {
34
+ return {
35
+ name: name,
36
+ map: data.map,
37
+ reduce: data.reduce,
38
+ };
39
+ }
40
+ /**
41
+ * @internal
42
+ */
43
+ static _fromCppData(data) {
44
+ return new DesignDocumentView({
45
+ map: data.map,
46
+ reduce: data.reduce,
47
+ });
48
+ }
30
49
  }
31
50
  exports.DesignDocumentView = DesignDocumentView;
32
51
  /**
@@ -59,6 +78,8 @@ class DesignDocument {
59
78
  }
60
79
  this.name = data.name;
61
80
  this.views = data.views || {};
81
+ this.namespace = data.namespace || viewtypes_1.DesignDocumentNamespace.Production;
82
+ this.rev = data.rev;
62
83
  }
63
84
  /**
64
85
  * @internal
@@ -74,6 +95,36 @@ class DesignDocument {
74
95
  }
75
96
  return new DesignDocument({ name: ddocName, views: views });
76
97
  }
98
+ /**
99
+ * @internal
100
+ */
101
+ static _toCppData(data, namespace) {
102
+ const cppView = {};
103
+ for (const [k, v] of Object.entries(data.views)) {
104
+ cppView[k] = DesignDocumentView._toCppData(k, v);
105
+ }
106
+ return {
107
+ rev: data.rev,
108
+ name: data.name,
109
+ ns: (0, bindingutilities_1.designDocumentNamespaceToCpp)(namespace),
110
+ views: cppView,
111
+ };
112
+ }
113
+ /**
114
+ * @internal
115
+ */
116
+ static _fromCppData(ddoc) {
117
+ const views = {};
118
+ for (const [viewName, viewData] of Object.entries(ddoc.views)) {
119
+ views[viewName] = DesignDocumentView._fromCppData(viewData);
120
+ }
121
+ return new DesignDocument({
122
+ name: ddoc.name,
123
+ views: views,
124
+ namespace: (0, bindingutilities_1.designDocumentNamespaceFromCpp)(ddoc.ns),
125
+ rev: ddoc.rev,
126
+ });
127
+ }
77
128
  }
78
129
  exports.DesignDocument = DesignDocument;
79
130
  /**
@@ -89,12 +140,6 @@ class ViewIndexManager {
89
140
  constructor(bucket) {
90
141
  this._bucket = bucket;
91
142
  }
92
- /**
93
- * @internal
94
- */
95
- get _http() {
96
- return new httpexecutor_1.HttpExecutor(this._bucket.conn);
97
- }
98
143
  /**
99
144
  * @internal
100
145
  */
@@ -102,142 +147,232 @@ class ViewIndexManager {
102
147
  return this._bucket.cluster;
103
148
  }
104
149
  /**
105
- * Returns a list of all the design documents in this bucket.
106
- *
107
- * @param options Optional parameters for this operation.
108
- * @param callback A node-style callback to be invoked after execution.
150
+ * @internal
109
151
  */
110
- async getAllDesignDocuments(options, callback) {
111
- if (options instanceof Function) {
112
- callback = arguments[0];
152
+ async getAllDesignDocuments() {
153
+ let namespace;
154
+ let options;
155
+ let callback;
156
+ // deprecated path: options and maybe callback passed in
157
+ if (typeof arguments[0] === 'object') {
158
+ namespace = undefined;
159
+ options = arguments[0];
160
+ callback = arguments[1];
161
+ }
162
+ else if (arguments[0] instanceof Function) {
163
+ // deprecated path: no options, only callback passed in
164
+ namespace = undefined;
113
165
  options = undefined;
166
+ callback = arguments[0];
167
+ }
168
+ else {
169
+ // either no args passed in or desired path (namespace is 1st arg)
170
+ namespace = arguments[0];
171
+ // still need to handle possible no options, but callback passed in
172
+ if (arguments[1] instanceof Function) {
173
+ callback = arguments[1];
174
+ options = undefined;
175
+ }
176
+ else {
177
+ options = arguments[1];
178
+ callback = arguments[2];
179
+ }
114
180
  }
115
181
  if (!options) {
116
182
  options = {};
117
183
  }
118
184
  const timeout = options.timeout || this._cluster.managementTimeout;
119
- return utilities_1.PromiseHelper.wrapAsync(async () => {
120
- const bucketName = this._bucket.name;
121
- const res = await this._http.request({
122
- type: httpexecutor_1.HttpServiceType.Management,
123
- method: httpexecutor_1.HttpMethod.Get,
124
- path: `/pools/default/buckets/${bucketName}/ddocs`,
185
+ const ns = namespace !== null && namespace !== void 0 ? namespace : viewtypes_1.DesignDocumentNamespace.Production;
186
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
187
+ this._cluster.conn.managementViewIndexGetAll({
188
+ bucket_name: this._bucket.name,
189
+ ns: (0, bindingutilities_1.designDocumentNamespaceToCpp)(ns),
125
190
  timeout: timeout,
191
+ }, (cppErr, resp) => {
192
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
193
+ if (err) {
194
+ return wrapCallback(err, null);
195
+ }
196
+ const ddocs = [];
197
+ for (const ddoc of resp.design_documents) {
198
+ ddocs.push(DesignDocument._fromCppData(ddoc));
199
+ }
200
+ wrapCallback(null, ddocs);
126
201
  });
127
- if (res.statusCode !== 200) {
128
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
129
- throw new errors_1.CouchbaseError('failed to get design documents', undefined, errCtx);
130
- }
131
- const ddocsData = JSON.parse(res.body.toString());
132
- const ddocs = ddocsData.rows.map((ddocData) => {
133
- const ddocName = ddocData.doc.meta.id.substr(8);
134
- return DesignDocument._fromNsData(ddocName, ddocData.doc.json);
135
- });
136
- return ddocs;
137
202
  }, callback);
138
203
  }
139
204
  /**
140
- * Returns the specified design document.
141
- *
142
- * @param designDocName The name of the design document to fetch.
143
- * @param options Optional parameters for this operation.
144
- * @param callback A node-style callback to be invoked after execution.
205
+ * @internal
145
206
  */
146
- async getDesignDocument(designDocName, options, callback) {
147
- if (options instanceof Function) {
148
- callback = arguments[1];
207
+ async getDesignDocument() {
208
+ let designDocName = arguments[0];
209
+ let namespace;
210
+ let options;
211
+ let callback;
212
+ // deprecated path: options and maybe callback passed in
213
+ if (typeof arguments[1] === 'object') {
214
+ namespace = undefined;
215
+ options = arguments[1];
216
+ callback = arguments[2];
217
+ }
218
+ else if (arguments[1] instanceof Function) {
219
+ // deprecated path: no options, only callback passed in
220
+ namespace = undefined;
149
221
  options = undefined;
222
+ callback = arguments[1];
223
+ }
224
+ else {
225
+ // either no other args passed in or desired path (namespace is 2nd arg)
226
+ namespace = arguments[1];
227
+ // still need to handle possible no options, but callback passed in
228
+ if (arguments[2] instanceof Function) {
229
+ callback = arguments[2];
230
+ options = undefined;
231
+ }
232
+ else {
233
+ options = arguments[2];
234
+ callback = arguments[3];
235
+ }
150
236
  }
151
237
  if (!options) {
152
238
  options = {};
153
239
  }
154
240
  const timeout = options.timeout || this._cluster.managementTimeout;
155
- return utilities_1.PromiseHelper.wrapAsync(async () => {
156
- const bucketName = this._bucket.name;
157
- const res = await this._http.request({
158
- type: httpexecutor_1.HttpServiceType.Views,
159
- method: httpexecutor_1.HttpMethod.Get,
160
- path: `/${bucketName}/_design/${designDocName}`,
241
+ // for compatibility with older SDK versions (i.e. deprecated getDesignDocument())
242
+ if (designDocName.startsWith('dev_')) {
243
+ namespace = viewtypes_1.DesignDocumentNamespace.Development;
244
+ designDocName = designDocName.substring(4);
245
+ }
246
+ const ns = namespace !== null && namespace !== void 0 ? namespace : viewtypes_1.DesignDocumentNamespace.Production;
247
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
248
+ this._cluster.conn.managementViewIndexGet({
249
+ bucket_name: this._bucket.name,
250
+ document_name: designDocName,
251
+ ns: (0, bindingutilities_1.designDocumentNamespaceToCpp)(ns),
161
252
  timeout: timeout,
162
- });
163
- if (res.statusCode !== 200) {
164
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
165
- if (res.statusCode === 404) {
166
- throw new errors_1.DesignDocumentNotFoundError(undefined, errCtx);
253
+ }, (cppErr, resp) => {
254
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
255
+ if (err) {
256
+ return wrapCallback(err, null);
167
257
  }
168
- throw new errors_1.CouchbaseError('failed to get the design document', undefined, errCtx);
169
- }
170
- const ddocData = JSON.parse(res.body.toString());
171
- return DesignDocument._fromNsData(designDocName, ddocData);
258
+ const ddoc = DesignDocument._fromCppData(resp.document);
259
+ wrapCallback(null, ddoc);
260
+ });
172
261
  }, callback);
173
262
  }
174
263
  /**
175
- * Creates or updates a design document.
176
- *
177
- * @param designDoc The DesignDocument to upsert.
178
- * @param options Optional parameters for this operation.
179
- * @param callback A node-style callback to be invoked after execution.
264
+ * @internal
180
265
  */
181
- async upsertDesignDocument(designDoc, options, callback) {
182
- if (options instanceof Function) {
183
- callback = arguments[1];
266
+ async upsertDesignDocument() {
267
+ const designDoc = arguments[0];
268
+ let namespace;
269
+ let options;
270
+ let callback;
271
+ // deprecated path: options and maybe callback passed in
272
+ if (typeof arguments[1] === 'object') {
273
+ namespace = undefined;
274
+ options = arguments[1];
275
+ callback = arguments[2];
276
+ }
277
+ else if (arguments[1] instanceof Function) {
278
+ // deprecated path: no options, only callback passed in
279
+ namespace = undefined;
184
280
  options = undefined;
281
+ callback = arguments[1];
282
+ }
283
+ else {
284
+ // either no other args passed in or desired path (namespace is 2nd arg)
285
+ namespace = arguments[1];
286
+ // still need to handle possible no options, but callback passed in
287
+ if (arguments[2] instanceof Function) {
288
+ callback = arguments[2];
289
+ options = undefined;
290
+ }
291
+ else {
292
+ options = arguments[2];
293
+ callback = arguments[3];
294
+ }
185
295
  }
186
296
  if (!options) {
187
297
  options = {};
188
298
  }
189
299
  const timeout = options.timeout || this._cluster.managementTimeout;
190
- return utilities_1.PromiseHelper.wrapAsync(async () => {
191
- const bucketName = this._bucket.name;
192
- const designDocData = {
193
- views: designDoc.views,
194
- };
195
- const encodedData = JSON.stringify(designDocData);
196
- const res = await this._http.request({
197
- type: httpexecutor_1.HttpServiceType.Views,
198
- method: httpexecutor_1.HttpMethod.Put,
199
- path: `/${bucketName}/_design/${designDoc.name}`,
200
- contentType: 'application/json',
201
- body: encodedData,
300
+ // for compatibility with older SDK versions (i.e. deprecated upsertDesignDocument())
301
+ if (designDoc.name.startsWith('dev_')) {
302
+ namespace = viewtypes_1.DesignDocumentNamespace.Development;
303
+ designDoc.name = designDoc.name.substring(4);
304
+ }
305
+ const ns = namespace !== null && namespace !== void 0 ? namespace : viewtypes_1.DesignDocumentNamespace.Production;
306
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
307
+ this._cluster.conn.managementViewIndexUpsert({
308
+ bucket_name: this._bucket.name,
309
+ document: DesignDocument._toCppData(designDoc, ns),
202
310
  timeout: timeout,
311
+ }, (cppErr) => {
312
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
313
+ if (err) {
314
+ return wrapCallback(err, null);
315
+ }
316
+ wrapCallback(err);
203
317
  });
204
- if (res.statusCode !== 201) {
205
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
206
- throw new errors_1.CouchbaseError('failed to upsert the design document', undefined, errCtx);
207
- }
208
318
  }, callback);
209
319
  }
210
320
  /**
211
- * Drops an existing design document.
212
- *
213
- * @param designDocName The name of the design document to drop.
214
- * @param options Optional parameters for this operation.
215
- * @param callback A node-style callback to be invoked after execution.
321
+ * @internal
216
322
  */
217
- async dropDesignDocument(designDocName, options, callback) {
218
- if (options instanceof Function) {
219
- callback = arguments[1];
323
+ async dropDesignDocument() {
324
+ let designDocName = arguments[0];
325
+ let namespace;
326
+ let options;
327
+ let callback;
328
+ // deprecated path: options and maybe callback passed in
329
+ if (typeof arguments[1] === 'object') {
330
+ namespace = undefined;
331
+ options = arguments[1];
332
+ callback = arguments[2];
333
+ }
334
+ else if (arguments[1] instanceof Function) {
335
+ // deprecated path: no options, only callback passed in
336
+ namespace = undefined;
220
337
  options = undefined;
338
+ callback = arguments[1];
339
+ }
340
+ else {
341
+ // either no other args passed in or desired path (namespace is 2nd arg)
342
+ namespace = arguments[1];
343
+ // still need to handle possible no options, but callback passed in
344
+ if (arguments[2] instanceof Function) {
345
+ callback = arguments[2];
346
+ options = undefined;
347
+ }
348
+ else {
349
+ options = arguments[2];
350
+ callback = arguments[3];
351
+ }
221
352
  }
222
353
  if (!options) {
223
354
  options = {};
224
355
  }
225
356
  const timeout = options.timeout || this._cluster.managementTimeout;
226
- return utilities_1.PromiseHelper.wrapAsync(async () => {
227
- const bucketName = this._bucket.name;
228
- const res = await this._http.request({
229
- type: httpexecutor_1.HttpServiceType.Views,
230
- method: httpexecutor_1.HttpMethod.Delete,
231
- path: `/${bucketName}/_design/${designDocName}`,
357
+ // for compatibility with older SDK versions (i.e. deprecated dropDesignDocument())
358
+ if (designDocName.startsWith('dev_')) {
359
+ namespace = viewtypes_1.DesignDocumentNamespace.Development;
360
+ designDocName = designDocName.substring(4);
361
+ }
362
+ const ns = namespace !== null && namespace !== void 0 ? namespace : viewtypes_1.DesignDocumentNamespace.Production;
363
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
364
+ this._cluster.conn.managementViewIndexDrop({
365
+ bucket_name: this._bucket.name,
366
+ document_name: designDocName,
367
+ ns: (0, bindingutilities_1.designDocumentNamespaceToCpp)(ns),
232
368
  timeout: timeout,
233
- });
234
- if (res.statusCode !== 200) {
235
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
236
- if (res.statusCode === 404) {
237
- throw new errors_1.DesignDocumentNotFoundError(undefined, errCtx);
369
+ }, (cppErr) => {
370
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
371
+ if (err) {
372
+ return wrapCallback(err, null);
238
373
  }
239
- throw new errors_1.CouchbaseError('failed to drop the design document', undefined, errCtx);
240
- }
374
+ wrapCallback(err);
375
+ });
241
376
  }, callback);
242
377
  }
243
378
  /**
@@ -261,12 +396,10 @@ class ViewIndexManager {
261
396
  const timeout = options.timeout || this._cluster.managementTimeout;
262
397
  const timer = new utilities_1.CompoundTimeout(timeout);
263
398
  return utilities_1.PromiseHelper.wrapAsync(async () => {
264
- const designDoc = await this.getDesignDocument(`dev_${designDocName}`, {
399
+ const designDoc = await this.getDesignDocument(designDocName, viewtypes_1.DesignDocumentNamespace.Development, {
265
400
  timeout: timer.left(),
266
401
  });
267
- // Replace the name without the `dev_` prefix on it.
268
- designDoc.name = designDocName;
269
- await this.upsertDesignDocument(designDoc, {
402
+ await this.upsertDesignDocument(designDoc, viewtypes_1.DesignDocumentNamespace.Production, {
270
403
  timeout: timer.left(),
271
404
  });
272
405
  }, callback);
@@ -69,6 +69,21 @@ export declare class ViewRow<TValue = any, TKey = any> {
69
69
  */
70
70
  constructor(data: ViewRow);
71
71
  }
72
+ /**
73
+ * Specifies the namespace for the associated Design Document.
74
+ *
75
+ * @category Views
76
+ */
77
+ export declare enum DesignDocumentNamespace {
78
+ /**
79
+ * Indicates that the Design Document namespace is within the development environment.
80
+ */
81
+ Development = "development",
82
+ /**
83
+ * Indicates that the Design Document namespace is within the producion environment.
84
+ */
85
+ Production = "production"
86
+ }
72
87
  /**
73
88
  * Represents the various scan consistency options that are available when
74
89
  * querying against the views service.
@@ -270,4 +285,15 @@ export interface ViewQueryOptions {
270
285
  * @deprecated Use {@link ViewQueryOptions.onError} instead.
271
286
  */
272
287
  on_error?: ViewErrorMode;
288
+ /**
289
+ * Specifies any additional parameters which should be passed to the view engine
290
+ * when executing the view query.
291
+ */
292
+ raw?: {
293
+ [key: string]: string;
294
+ };
295
+ /**
296
+ * Specifies the design document namespace to use when executing the view query.
297
+ */
298
+ namespace?: DesignDocumentNamespace;
273
299
  }
package/dist/viewtypes.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ViewErrorMode = exports.ViewOrdering = exports.ViewScanConsistency = exports.ViewRow = exports.ViewMetaData = exports.ViewResult = void 0;
3
+ exports.ViewErrorMode = exports.ViewOrdering = exports.ViewScanConsistency = exports.DesignDocumentNamespace = exports.ViewRow = exports.ViewMetaData = exports.ViewResult = void 0;
4
4
  /**
5
5
  * Contains the results of a view query.
6
6
  *
@@ -56,6 +56,22 @@ class ViewRow {
56
56
  }
57
57
  }
58
58
  exports.ViewRow = ViewRow;
59
+ /**
60
+ * Specifies the namespace for the associated Design Document.
61
+ *
62
+ * @category Views
63
+ */
64
+ var DesignDocumentNamespace;
65
+ (function (DesignDocumentNamespace) {
66
+ /**
67
+ * Indicates that the Design Document namespace is within the development environment.
68
+ */
69
+ DesignDocumentNamespace["Development"] = "development";
70
+ /**
71
+ * Indicates that the Design Document namespace is within the producion environment.
72
+ */
73
+ DesignDocumentNamespace["Production"] = "production";
74
+ })(DesignDocumentNamespace || (exports.DesignDocumentNamespace = DesignDocumentNamespace = {}));
59
75
  /**
60
76
  * Represents the various scan consistency options that are available when
61
77
  * querying against the views service.
package/package.json CHANGED
@@ -54,7 +54,7 @@
54
54
  "type": "git",
55
55
  "url": "http://github.com/couchbase/couchnode.git"
56
56
  },
57
- "version": "4.2.9",
57
+ "version": "4.2.11-rc.1",
58
58
  "config": {
59
59
  "native": false
60
60
  },
@@ -79,12 +79,12 @@
79
79
  ]
80
80
  },
81
81
  "optionalDependencies": {
82
- "@couchbase/couchbase-darwin-arm64-napi": "4.2.9",
83
- "@couchbase/couchbase-darwin-x64-napi": "4.2.9",
84
- "@couchbase/couchbase-linux-arm64-napi": "4.2.9",
85
- "@couchbase/couchbase-linuxmusl-x64-napi": "4.2.9",
86
- "@couchbase/couchbase-linux-x64-napi": "4.2.9",
87
- "@couchbase/couchbase-win32-x64-napi": "4.2.9"
82
+ "@couchbase/couchbase-darwin-arm64-napi": "4.2.11-rc.1",
83
+ "@couchbase/couchbase-darwin-x64-napi": "4.2.11-rc.1",
84
+ "@couchbase/couchbase-linux-arm64-napi": "4.2.11-rc.1",
85
+ "@couchbase/couchbase-linuxmusl-x64-napi": "4.2.11-rc.1",
86
+ "@couchbase/couchbase-linux-x64-napi": "4.2.11-rc.1",
87
+ "@couchbase/couchbase-win32-x64-napi": "4.2.11-rc.1"
88
88
  },
89
89
  "files": [
90
90
  "LICENSE",
package/src/constants.cpp CHANGED
@@ -865,6 +865,7 @@ void Constants::InitAutogen(Napi::Env env, Napi::Object exports)
865
865
  couchbase::key_value_status_code::opaque_no_match},
866
866
  {"locked", couchbase::key_value_status_code::locked},
867
867
  {"not_locked", couchbase::key_value_status_code::not_locked},
868
+ {"config_only", couchbase::key_value_status_code::config_only},
868
869
  {"auth_stale", couchbase::key_value_status_code::auth_stale},
869
870
  {"auth_error", couchbase::key_value_status_code::auth_error},
870
871
  {"auth_continue",
@@ -1051,6 +1052,17 @@ void Constants::InitAutogen(Napi::Env env, Napi::Object exports)
1051
1052
  {"three", couchbase::replicate_to::three},
1052
1053
  }));
1053
1054
 
1055
+ exports.Set(
1056
+ "vector_query_combination",
1057
+ cbppEnumToJs<couchbase::core::vector_query_combination>(
1058
+ env,
1059
+ {
1060
+ {"combination_and",
1061
+ couchbase::core::vector_query_combination::combination_and},
1062
+ {"combination_or",
1063
+ couchbase::core::vector_query_combination::combination_or},
1064
+ }));
1065
+
1054
1066
  //#endregion Autogenerated Constants
1055
1067
  }
1056
1068