couchbase 3.2.0 → 3.2.4

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -98,7 +98,7 @@ class ViewExecutor {
98
98
  queryOpts.startkey_docid = options.idRange.start;
99
99
  queryOpts.endkey_docid = options.idRange.end;
100
100
  }
101
- const queryData = utilities_1.cbQsStringify(queryOpts);
101
+ const queryData = utilities_1.cbQsStringify(queryOpts, { boolAsString: true });
102
102
  const lcbTimeout = options.timeout ? options.timeout * 1000 : undefined;
103
103
  const emitter = new streamablepromises_1.StreamableRowPromise((rows, meta) => {
104
104
  return new viewtypes_1.ViewResult({
@@ -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.ViewIndexManager = exports.DesignDocument = exports.DesignDocumentView = void 0;
13
4
  const errors_1 = require("./errors");
@@ -107,38 +98,36 @@ class ViewIndexManager {
107
98
  * @param options Optional parameters for this operation.
108
99
  * @param callback A node-style callback to be invoked after execution.
109
100
  */
110
- getAllDesignDocuments(options, callback) {
111
- return __awaiter(this, arguments, void 0, function* () {
112
- if (options instanceof Function) {
113
- callback = arguments[0];
114
- options = undefined;
115
- }
116
- if (!options) {
117
- options = {};
101
+ async getAllDesignDocuments(options, callback) {
102
+ if (options instanceof Function) {
103
+ callback = arguments[0];
104
+ options = undefined;
105
+ }
106
+ if (!options) {
107
+ options = {};
108
+ }
109
+ const parentSpan = options.parentSpan;
110
+ const timeout = options.timeout;
111
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
112
+ const bucketName = this._bucket.name;
113
+ const res = await this._http.request({
114
+ type: httpexecutor_1.HttpServiceType.Management,
115
+ method: httpexecutor_1.HttpMethod.Get,
116
+ path: `/pools/default/buckets/${bucketName}/ddocs`,
117
+ parentSpan: parentSpan,
118
+ timeout: timeout,
119
+ });
120
+ if (res.statusCode !== 200) {
121
+ const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
122
+ throw new errors_1.CouchbaseError('failed to get design documents', undefined, errCtx);
118
123
  }
119
- const parentSpan = options.parentSpan;
120
- const timeout = options.timeout;
121
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
122
- const bucketName = this._bucket.name;
123
- const res = yield this._http.request({
124
- type: httpexecutor_1.HttpServiceType.Management,
125
- method: httpexecutor_1.HttpMethod.Get,
126
- path: `/pools/default/buckets/${bucketName}/ddocs`,
127
- parentSpan: parentSpan,
128
- timeout: timeout,
129
- });
130
- if (res.statusCode !== 200) {
131
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
132
- throw new errors_1.CouchbaseError('failed to get design documents', undefined, errCtx);
133
- }
134
- const ddocsData = JSON.parse(res.body.toString());
135
- const ddocs = ddocsData.rows.map((ddocData) => {
136
- const ddocName = ddocData.doc.meta.id.substr(8);
137
- return DesignDocument._fromNsData(ddocName, ddocData.doc.json);
138
- });
139
- return ddocs;
140
- }), callback);
141
- });
124
+ const ddocsData = JSON.parse(res.body.toString());
125
+ const ddocs = ddocsData.rows.map((ddocData) => {
126
+ const ddocName = ddocData.doc.meta.id.substr(8);
127
+ return DesignDocument._fromNsData(ddocName, ddocData.doc.json);
128
+ });
129
+ return ddocs;
130
+ }, callback);
142
131
  }
143
132
  /**
144
133
  * Returns the specified design document.
@@ -147,36 +136,34 @@ class ViewIndexManager {
147
136
  * @param options Optional parameters for this operation.
148
137
  * @param callback A node-style callback to be invoked after execution.
149
138
  */
150
- getDesignDocument(designDocName, options, callback) {
151
- return __awaiter(this, arguments, void 0, function* () {
152
- if (options instanceof Function) {
153
- callback = arguments[1];
154
- options = undefined;
155
- }
156
- if (!options) {
157
- options = {};
158
- }
159
- const parentSpan = options.parentSpan;
160
- const timeout = options.timeout;
161
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
162
- const res = yield this._http.request({
163
- type: httpexecutor_1.HttpServiceType.Views,
164
- method: httpexecutor_1.HttpMethod.Get,
165
- path: `/_design/${designDocName}`,
166
- parentSpan: parentSpan,
167
- timeout: timeout,
168
- });
169
- if (res.statusCode !== 200) {
170
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
171
- if (res.statusCode === 404) {
172
- throw new errors_1.DesignDocumentNotFoundError(undefined, errCtx);
173
- }
174
- throw new errors_1.CouchbaseError('failed to get the design document', undefined, errCtx);
139
+ async getDesignDocument(designDocName, options, callback) {
140
+ if (options instanceof Function) {
141
+ callback = arguments[1];
142
+ options = undefined;
143
+ }
144
+ if (!options) {
145
+ options = {};
146
+ }
147
+ const parentSpan = options.parentSpan;
148
+ const timeout = options.timeout;
149
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
150
+ const res = await this._http.request({
151
+ type: httpexecutor_1.HttpServiceType.Views,
152
+ method: httpexecutor_1.HttpMethod.Get,
153
+ path: `/_design/${designDocName}`,
154
+ parentSpan: parentSpan,
155
+ timeout: timeout,
156
+ });
157
+ if (res.statusCode !== 200) {
158
+ const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
159
+ if (res.statusCode === 404) {
160
+ throw new errors_1.DesignDocumentNotFoundError(undefined, errCtx);
175
161
  }
176
- const ddocData = JSON.parse(res.body.toString());
177
- return DesignDocument._fromNsData(designDocName, ddocData);
178
- }), callback);
179
- });
162
+ throw new errors_1.CouchbaseError('failed to get the design document', undefined, errCtx);
163
+ }
164
+ const ddocData = JSON.parse(res.body.toString());
165
+ return DesignDocument._fromNsData(designDocName, ddocData);
166
+ }, callback);
180
167
  }
181
168
  /**
182
169
  * Creates or updates a design document.
@@ -185,37 +172,35 @@ class ViewIndexManager {
185
172
  * @param options Optional parameters for this operation.
186
173
  * @param callback A node-style callback to be invoked after execution.
187
174
  */
188
- upsertDesignDocument(designDoc, options, callback) {
189
- return __awaiter(this, arguments, void 0, function* () {
190
- if (options instanceof Function) {
191
- callback = arguments[2];
192
- options = undefined;
193
- }
194
- if (!options) {
195
- options = {};
175
+ async upsertDesignDocument(designDoc, options, callback) {
176
+ if (options instanceof Function) {
177
+ callback = arguments[1];
178
+ options = undefined;
179
+ }
180
+ if (!options) {
181
+ options = {};
182
+ }
183
+ const parentSpan = options.parentSpan;
184
+ const timeout = options.timeout;
185
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
186
+ const designDocData = {
187
+ views: designDoc.views,
188
+ };
189
+ const encodedData = JSON.stringify(designDocData);
190
+ const res = await this._http.request({
191
+ type: httpexecutor_1.HttpServiceType.Views,
192
+ method: httpexecutor_1.HttpMethod.Put,
193
+ path: `/_design/${designDoc.name}`,
194
+ contentType: 'application/json',
195
+ body: encodedData,
196
+ parentSpan: parentSpan,
197
+ timeout: timeout,
198
+ });
199
+ if (res.statusCode !== 201) {
200
+ const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
201
+ throw new errors_1.CouchbaseError('failed to upsert the design document', undefined, errCtx);
196
202
  }
197
- const parentSpan = options.parentSpan;
198
- const timeout = options.timeout;
199
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
200
- const designDocData = {
201
- views: designDoc.views,
202
- };
203
- const encodedData = JSON.stringify(designDocData);
204
- const res = yield this._http.request({
205
- type: httpexecutor_1.HttpServiceType.Views,
206
- method: httpexecutor_1.HttpMethod.Put,
207
- path: `/_design/${designDoc.name}`,
208
- contentType: 'application/json',
209
- body: encodedData,
210
- parentSpan: parentSpan,
211
- timeout: timeout,
212
- });
213
- if (res.statusCode !== 201) {
214
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
215
- throw new errors_1.CouchbaseError('failed to upsert the design document', undefined, errCtx);
216
- }
217
- }), callback);
218
- });
203
+ }, callback);
219
204
  }
220
205
  /**
221
206
  * Drops an existing design document.
@@ -224,34 +209,32 @@ class ViewIndexManager {
224
209
  * @param options Optional parameters for this operation.
225
210
  * @param callback A node-style callback to be invoked after execution.
226
211
  */
227
- dropDesignDocument(designDocName, options, callback) {
228
- return __awaiter(this, arguments, void 0, function* () {
229
- if (options instanceof Function) {
230
- callback = arguments[1];
231
- options = undefined;
232
- }
233
- if (!options) {
234
- options = {};
235
- }
236
- const parentSpan = options.parentSpan;
237
- const timeout = options.timeout;
238
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
239
- const res = yield this._http.request({
240
- type: httpexecutor_1.HttpServiceType.Views,
241
- method: httpexecutor_1.HttpMethod.Delete,
242
- path: `/_design/${designDocName}`,
243
- parentSpan: parentSpan,
244
- timeout: timeout,
245
- });
246
- if (res.statusCode !== 200) {
247
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
248
- if (res.statusCode === 404) {
249
- throw new errors_1.DesignDocumentNotFoundError(undefined, errCtx);
250
- }
251
- throw new errors_1.CouchbaseError('failed to drop the design document', undefined, errCtx);
212
+ async dropDesignDocument(designDocName, options, callback) {
213
+ if (options instanceof Function) {
214
+ callback = arguments[1];
215
+ options = undefined;
216
+ }
217
+ if (!options) {
218
+ options = {};
219
+ }
220
+ const parentSpan = options.parentSpan;
221
+ const timeout = options.timeout;
222
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
223
+ const res = await this._http.request({
224
+ type: httpexecutor_1.HttpServiceType.Views,
225
+ method: httpexecutor_1.HttpMethod.Delete,
226
+ path: `/_design/${designDocName}`,
227
+ parentSpan: parentSpan,
228
+ timeout: timeout,
229
+ });
230
+ if (res.statusCode !== 200) {
231
+ const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
232
+ if (res.statusCode === 404) {
233
+ throw new errors_1.DesignDocumentNotFoundError(undefined, errCtx);
252
234
  }
253
- }), callback);
254
- });
235
+ throw new errors_1.CouchbaseError('failed to drop the design document', undefined, errCtx);
236
+ }
237
+ }, callback);
255
238
  }
256
239
  /**
257
240
  * Publishes a development design document to be a production design document.
@@ -263,30 +246,28 @@ class ViewIndexManager {
263
246
  * @param options Optional parameters for this operation.
264
247
  * @param callback A node-style callback to be invoked after execution.
265
248
  */
266
- publishDesignDocument(designDocName, options, callback) {
267
- return __awaiter(this, arguments, void 0, function* () {
268
- if (options instanceof Function) {
269
- callback = arguments[1];
270
- options = undefined;
271
- }
272
- if (!options) {
273
- options = {};
274
- }
275
- const parentSpan = options.parentSpan;
276
- const timeout = options.timeout;
277
- const timer = new utilities_1.CompoundTimeout(timeout);
278
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
279
- const designDoc = yield this.getDesignDocument(`dev_${designDocName}`, {
280
- parentSpan: parentSpan,
281
- timeout: timer.left(),
282
- });
283
- // Replace the name without the `dev_` prefix on it.
284
- designDoc.name = designDocName;
285
- yield this.upsertDesignDocument(designDoc, {
286
- timeout: timer.left(),
287
- });
288
- }), callback);
289
- });
249
+ async publishDesignDocument(designDocName, options, callback) {
250
+ if (options instanceof Function) {
251
+ callback = arguments[1];
252
+ options = undefined;
253
+ }
254
+ if (!options) {
255
+ options = {};
256
+ }
257
+ const parentSpan = options.parentSpan;
258
+ const timeout = options.timeout;
259
+ const timer = new utilities_1.CompoundTimeout(timeout);
260
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
261
+ const designDoc = await this.getDesignDocument(`dev_${designDocName}`, {
262
+ parentSpan: parentSpan,
263
+ timeout: timer.left(),
264
+ });
265
+ // Replace the name without the `dev_` prefix on it.
266
+ designDoc.name = designDocName;
267
+ await this.upsertDesignDocument(designDoc, {
268
+ timeout: timer.left(),
269
+ });
270
+ }, callback);
290
271
  }
291
272
  }
292
273
  exports.ViewIndexManager = ViewIndexManager;
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":">=10.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","debug":"^4.3.2","nan":"^2.14.2","parse-duration":"^1.0.0","prebuild-install":"^6.1.3"},"devDependencies":{"@trivago/prettier-plugin-sort-imports":"^2.0.2","@types/bindings":"^1.5.1","@types/debug":"^4.1.6","@types/node":"^16.4.0","@typescript-eslint/eslint-plugin":"^4.28.4","@typescript-eslint/parser":"^4.28.4","chai":"^4.3.4","eslint":"^7.31.0","eslint-config-prettier":"^8.3.0","eslint-plugin-jsdoc":"^35.5.0","eslint-plugin-mocha":"^9.0.0","eslint-plugin-node":"^11.1.0","expose-gc":"^1.0.0","mocha":"^8.4.0","npm-check-updates":"^11.8.3","nyc":"^15.1.0","prebuild":"^10.0.1","prettier":"^2.3.2","semver":"^7.3.5","ts-mocha":"^8.0.0","typedoc":"^0.21.4","typescript":"^4.3.5","uuid":"^8.3.2"},"repository":{"type":"git","url":"http://github.com/couchbase/couchnode.git"},"version":"3.2.0","config":{"native":false},"scripts":{"install":"prebuild-install || node-gyp rebuild","build":"node-gyp build && tsc","rebuild":"node-gyp rebuild && tsc","prebuild":"prebuild --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"}}
1
+ {"bugs":{"url":"http://www.couchbase.com/issues/browse/JSCBC"},"description":"The official Couchbase Node.js Client Library.","engines":{"node":">=10.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","debug":"^4.3.2","nan":"^2.15.0","parse-duration":"^1.0.0","prebuild-install":"^6.1.4"},"devDependencies":{"@trivago/prettier-plugin-sort-imports":"^2.0.4","@tsconfig/node10":"^1.0.8","@types/bindings":"^1.5.1","@types/debug":"^4.1.7","@types/node":"^16.7.2","@typescript-eslint/eslint-plugin":"^4.29.3","@typescript-eslint/parser":"^4.29.3","chai":"^4.3.4","eslint":"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-plugin-jsdoc":"^36.0.8","eslint-plugin-mocha":"^9.0.0","eslint-plugin-node":"^11.1.0","expose-gc":"^1.0.0","mocha":"^8.4.0","npm-check-updates":"^11.8.3","nyc":"^15.1.0","prebuild":"^10.0.1","prettier":"^2.3.2","segfault-handler":"^1.3.0","semver":"^7.3.5","ts-mocha":"^8.0.0","ts-node":"^10.2.1","typedoc":"^0.21.6","typescript":"^4.3.5","uuid":"^8.3.2"},"repository":{"type":"git","url":"http://github.com/couchbase/couchnode.git"},"version":"3.2.4","config":{"native":false},"scripts":{"install":"prebuild-install || node-gyp rebuild","build":"node-gyp build && tsc","rebuild":"node-gyp rebuild && tsc","prebuild":"prebuild --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"}}
@@ -0,0 +1,58 @@
1
+ #include "addondata.h"
2
+ #include "connection.h"
3
+
4
+ namespace couchnode
5
+ {
6
+
7
+ AddonData::AddonData()
8
+ {
9
+ }
10
+
11
+ AddonData::~AddonData()
12
+ {
13
+ auto instances = _instances;
14
+ std::for_each(instances.begin(), instances.end(),
15
+ [](Instance *inst) { delete inst; });
16
+ }
17
+
18
+ void AddonData::add_instance(class Instance *conn)
19
+ {
20
+ _instances.push_back(conn);
21
+ }
22
+
23
+ void AddonData::remove_instance(class Instance *conn)
24
+ {
25
+ auto connIter = std::find(_instances.begin(), _instances.end(), conn);
26
+ if (connIter != _instances.end()) {
27
+ _instances.erase(connIter);
28
+ }
29
+ }
30
+
31
+ namespace addondata
32
+ {
33
+
34
+ NAN_MODULE_INIT(Init)
35
+ {
36
+ auto data = new AddonData();
37
+
38
+ auto isolate = v8::Isolate::GetCurrent();
39
+ Nan::SetIsolateData(isolate, data);
40
+ node::AddEnvironmentCleanupHook(isolate, cleanup, isolate);
41
+ }
42
+
43
+ void cleanup(void *p)
44
+ {
45
+ v8::Isolate *isolate = static_cast<v8::Isolate *>(p);
46
+ auto data = Nan::GetIsolateData<couchnode::AddonData>(isolate);
47
+ delete data;
48
+ }
49
+
50
+ AddonData *Get()
51
+ {
52
+ return Nan::GetIsolateData<AddonData>(
53
+ Nan::GetCurrentContext()->GetIsolate());
54
+ }
55
+
56
+ } // namespace addondata
57
+
58
+ } // namespace couchnode
@@ -0,0 +1,40 @@
1
+ #pragma once
2
+ #ifndef ADDONDATA_H
3
+ #define ADDONDATA_H
4
+
5
+ #include <list>
6
+ #include <nan.h>
7
+ #include <node.h>
8
+
9
+ namespace couchnode
10
+ {
11
+
12
+ using namespace v8;
13
+
14
+ class AddonData
15
+ {
16
+ public:
17
+ AddonData();
18
+ ~AddonData();
19
+
20
+ void add_instance(class Instance *conn);
21
+ void remove_instance(class Instance *conn);
22
+
23
+ std::list<class Instance *> _instances;
24
+ Nan::Persistent<Function> _connectionConstructor;
25
+ Nan::Persistent<Function> _casConstructor;
26
+ Nan::Persistent<Function> _mutationtokenConstructor;
27
+ };
28
+
29
+ namespace addondata
30
+ {
31
+
32
+ NAN_MODULE_INIT(Init);
33
+ void cleanup(void *p);
34
+ AddonData *Get();
35
+
36
+ } // namespace addondata
37
+
38
+ } // namespace couchnode
39
+
40
+ #endif // ADDONDATA_H
package/src/binding.cpp CHANGED
@@ -1,6 +1,7 @@
1
1
  #include <nan.h>
2
2
  #include <node.h>
3
3
 
4
+ #include "addondata.h"
4
5
  #include "cas.h"
5
6
  #include "connection.h"
6
7
  #include "constants.h"
@@ -12,6 +13,7 @@ namespace couchnode
12
13
 
13
14
  static NAN_MODULE_INIT(init)
14
15
  {
16
+ addondata::Init(target);
15
17
  constants::Init(target);
16
18
 
17
19
  Cas::Init(target);
@@ -23,6 +25,6 @@ static NAN_MODULE_INIT(init)
23
25
  Nan::New<String>(lcb_get_version(NULL)).ToLocalChecked());
24
26
  }
25
27
 
26
- NODE_MODULE(couchbase_impl, couchnode::init)
28
+ NAN_MODULE_WORKER_ENABLED(couchbase_impl, couchnode::init)
27
29
 
28
30
  } // namespace couchnode
package/src/cas.h CHANGED
@@ -2,6 +2,7 @@
2
2
  #ifndef CAS_H
3
3
  #define CAS_H
4
4
 
5
+ #include "addondata.h"
5
6
  #include <libcouchbase/sysdefs.h>
6
7
  #include <nan.h>
7
8
  #include <node.h>
@@ -22,8 +23,7 @@ public:
22
23
 
23
24
  static inline Nan::Persistent<Function> &constructor()
24
25
  {
25
- static Nan::Persistent<Function> class_constructor;
26
- return class_constructor;
26
+ return addondata::Get()->_casConstructor;
27
27
  }
28
28
 
29
29
  private: