couchbase 3.2.0 → 3.2.4
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +24 -18
- package/binding.gyp +88 -85
- package/deps/lcb/CMakeLists.txt +1 -1
- package/deps/lcb/CONTRIBUTING.md +1 -1
- package/deps/lcb/README.markdown +2 -2
- package/deps/lcb/RELEASE_NOTES.markdown +99 -14
- package/deps/lcb/cmake/Modules/GetVersionInfo.cmake +1 -1
- package/deps/lcb/contrib/cbsasl/src/scram-sha/scram_utils.cc +22 -26
- package/deps/lcb/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp +20 -7
- package/deps/lcb/doc/Doxyfile +1 -1
- package/deps/lcb/example/CMakeLists.txt +4 -4
- package/deps/lcb/example/libuvdirect/main.c +39 -12
- package/deps/lcb/example/minimal/durability.cc +149 -0
- package/deps/lcb/example/minimal/query.c +11 -9
- package/deps/lcb/gyp_config/common/libcouchbase/configuration.h +3 -3
- package/deps/lcb/gyp_config/linux/arm64/config.h +243 -0
- package/deps/lcb/include/libcouchbase/couchbase.h +80 -5
- package/deps/lcb/include/libcouchbase/error.h +2 -0
- package/deps/lcb/include/libcouchbase/ixmgmt.h +15 -10
- package/deps/lcb/include/libcouchbase/tracing.h +2 -2
- package/deps/lcb/include/memcached/protocol_binary.h +21 -0
- package/deps/lcb/libcouchbase.gyp +347 -349
- package/deps/lcb/packaging/deb/control +1 -1
- package/deps/lcb/src/analytics/analytics_handle.cc +13 -5
- package/deps/lcb/src/analytics/analytics_handle.hh +29 -0
- package/deps/lcb/src/bootstrap.cc +6 -3
- package/deps/lcb/src/capi/cmd_analytics.cc +12 -1
- package/deps/lcb/src/capi/cmd_analytics.hh +30 -0
- package/deps/lcb/src/capi/cmd_counter.hh +23 -0
- package/deps/lcb/src/capi/cmd_exists.hh +24 -1
- package/deps/lcb/src/capi/cmd_get.hh +22 -0
- package/deps/lcb/src/capi/cmd_get_replica.hh +23 -0
- package/deps/lcb/src/capi/cmd_http.hh +7 -0
- package/deps/lcb/src/capi/cmd_query.cc +11 -1
- package/deps/lcb/src/capi/cmd_query.hh +31 -0
- package/deps/lcb/src/capi/cmd_remove.hh +23 -0
- package/deps/lcb/src/capi/cmd_search.cc +6 -0
- package/deps/lcb/src/capi/cmd_search.hh +23 -0
- package/deps/lcb/src/capi/cmd_store.hh +33 -21
- package/deps/lcb/src/capi/cmd_subdoc.hh +35 -0
- package/deps/lcb/src/capi/cmd_touch.hh +23 -0
- package/deps/lcb/src/capi/cmd_unlock.hh +23 -0
- package/deps/lcb/src/capi/cmd_view.hh +6 -0
- package/deps/lcb/src/capi/collection_qualifier.hh +2 -2
- package/deps/lcb/src/cntl.cc +45 -11
- package/deps/lcb/src/crypto.cc +2 -2
- package/deps/lcb/src/dns-srv.cc +5 -3
- package/deps/lcb/src/errmap.cc +5 -9
- package/deps/lcb/src/errmap.h +7 -3
- package/deps/lcb/src/handler.cc +24 -18
- package/deps/lcb/src/hostlist.h +2 -2
- package/deps/lcb/src/http/http-priv.h +2 -2
- package/deps/lcb/src/http/http.cc +5 -2
- package/deps/lcb/src/instance.cc +20 -11
- package/deps/lcb/src/internal.h +9 -0
- package/deps/lcb/src/lcbio/connect.cc +14 -2
- package/deps/lcb/src/lcbio/connect.h +2 -2
- package/deps/lcb/src/lcbio/ctx.cc +4 -2
- package/deps/lcb/src/lcbio/ioutils.cc +9 -10
- package/deps/lcb/src/lcbio/manager.cc +1 -1
- package/deps/lcb/src/mcserver/mcserver.cc +9 -6
- package/deps/lcb/src/mcserver/negotiate.cc +39 -17
- package/deps/lcb/src/n1ql/ixmgmt.cc +1 -2
- package/deps/lcb/src/n1ql/query_handle.cc +41 -19
- package/deps/lcb/src/n1ql/query_handle.hh +28 -1
- package/deps/lcb/src/operations/counter.cc +18 -5
- package/deps/lcb/src/operations/exists.cc +25 -4
- package/deps/lcb/src/operations/get.cc +39 -19
- package/deps/lcb/src/operations/get_replica.cc +28 -8
- package/deps/lcb/src/operations/observe.cc +1 -1
- package/deps/lcb/src/operations/ping.cc +8 -8
- package/deps/lcb/src/operations/pktfwd.cc +2 -1
- package/deps/lcb/src/operations/remove.cc +39 -22
- package/deps/lcb/src/operations/store.cc +18 -5
- package/deps/lcb/src/operations/subdoc.cc +18 -6
- package/deps/lcb/src/operations/touch.cc +34 -16
- package/deps/lcb/src/operations/unlock.cc +24 -5
- package/deps/lcb/src/packetutils.h +3 -2
- package/deps/lcb/src/retryq.cc +24 -5
- package/deps/lcb/src/search/search.cc +1 -0
- package/deps/lcb/src/search/search_handle.cc +30 -8
- package/deps/lcb/src/search/search_handle.hh +29 -0
- package/deps/lcb/src/settings.cc +1 -1
- package/deps/lcb/src/ssl/ssl_common.c +6 -7
- package/deps/lcb/src/tracing/span.cc +47 -14
- package/deps/lcb/src/tracing/tracer.cc +11 -2
- package/deps/lcb/src/tracing/tracing-internal.h +105 -93
- package/deps/lcb/src/utilities.cc +43 -0
- package/deps/lcb/src/utilities.h +53 -0
- package/deps/lcb/src/vbucket/vbucket.c +34 -33
- package/deps/lcb/src/views/view_handle.cc +13 -5
- package/deps/lcb/src/views/view_handle.hh +29 -0
- package/deps/lcb/tests/CMakeLists.txt +21 -0
- package/deps/lcb/tests/basic/t_ctlcodes.cc +24 -3
- package/deps/lcb/tests/basic/t_jsparse.cc +8 -0
- package/deps/lcb/tests/basic/t_n1qlstrings.cc +73 -0
- package/deps/lcb/tests/iotests/mock-environment.cc +30 -1
- package/deps/lcb/tests/iotests/mock-environment.h +49 -0
- package/deps/lcb/tests/iotests/mock-unit-test.cc +104 -6
- package/deps/lcb/tests/iotests/mock-unit-test.h +34 -0
- package/deps/lcb/tests/iotests/t_collections.cc +1 -1
- package/deps/lcb/tests/iotests/t_confmon.cc +4 -2
- package/deps/lcb/tests/iotests/t_get.cc +109 -7
- package/deps/lcb/tests/iotests/t_http.cc +9 -4
- package/deps/lcb/tests/iotests/t_lock.cc +18 -0
- package/deps/lcb/tests/iotests/t_mutate.cc +157 -63
- package/deps/lcb/tests/iotests/t_n1ql.cc +330 -33
- package/deps/lcb/tests/iotests/t_views.cc +1 -0
- package/deps/lcb/tests/iotests/testutil.cc +168 -0
- package/deps/lcb/tests/iotests/testutil.h +116 -0
- package/deps/lcb/tests/mocksupport/procutil.c +32 -28
- package/deps/lcb/tests/mocksupport/server.c +0 -1
- package/deps/lcb/tests/mocksupport/timeout.c +2 -2
- package/deps/lcb/tools/cbc.cc +7 -0
- package/dist/analyticsindexmanager.js +512 -524
- package/dist/binding.d.ts +3 -0
- package/dist/bindingutilities.js +4 -0
- package/dist/bucket.js +1 -1
- package/dist/bucketmanager.d.ts +31 -1
- package/dist/bucketmanager.js +194 -186
- package/dist/cluster.d.ts +7 -0
- package/dist/cluster.js +48 -38
- package/dist/collection.js +11 -17
- package/dist/collectionmanager.js +181 -197
- package/dist/connection.d.ts +3 -1
- package/dist/connection.js +27 -16
- package/dist/couchbase.d.ts +1 -0
- package/dist/couchbase.js +3 -13
- package/dist/datastructures.js +239 -310
- package/dist/diagnosticsexecutor.js +70 -85
- package/dist/errors.d.ts +70 -0
- package/dist/errors.js +96 -2
- package/dist/eventingfunctionmanager.d.ts +804 -0
- package/dist/eventingfunctionmanager.js +993 -0
- package/dist/httpexecutor.d.ts +2 -1
- package/dist/httpexecutor.js +30 -37
- package/dist/queryindexmanager.js +240 -266
- package/dist/scope.js +10 -4
- package/dist/sdspecs.d.ts +1 -1
- package/dist/searchexecutor.js +3 -0
- package/dist/searchindexmanager.js +240 -271
- package/dist/searchquery.d.ts +17 -0
- package/dist/searchquery.js +22 -1
- package/dist/searchtypes.d.ts +7 -2
- package/dist/searchtypes.js +2 -2
- package/dist/usermanager.js +251 -264
- package/dist/utilities.d.ts +2 -0
- package/dist/utilities.js +7 -2
- package/dist/viewexecutor.js +1 -1
- package/dist/viewindexmanager.js +131 -150
- package/package.json +1 -1
- package/src/addondata.cpp +58 -0
- package/src/addondata.h +40 -0
- package/src/binding.cpp +3 -1
- package/src/cas.h +2 -2
- package/src/connection.cpp +25 -178
- package/src/connection.h +8 -65
- package/src/connection_ops.cpp +57 -34
- package/src/constants.cpp +3 -0
- package/src/instance.cpp +235 -0
- package/src/instance.h +102 -0
- package/src/{connection_callbacks.cpp → instance_callbacks.cpp} +34 -34
- package/src/logger.cpp +11 -1
- package/src/logger.h +3 -0
- package/src/metrics.cpp +10 -0
- package/src/metrics.h +3 -0
- package/src/mutationtoken.h +2 -2
- package/src/opbuilder.h +13 -15
- package/src/respreader.cpp +1 -0
- package/src/respreader.h +6 -4
- package/src/tracespan.h +11 -11
- package/src/tracing.cpp +11 -0
- package/src/tracing.h +3 -0
- package/src/valueparser.h +5 -0
- package/deps/lcb/example/observe/durability.c +0 -110
package/dist/viewexecutor.js
CHANGED
@@ -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({
|
package/dist/viewindexmanager.js
CHANGED
@@ -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
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
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
|
120
|
-
const
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
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
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
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
|
-
|
177
|
-
|
178
|
-
|
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
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
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
|
-
|
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
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
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
|
-
|
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
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
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.
|
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
|
package/src/addondata.h
ADDED
@@ -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
|
-
|
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
|
-
|
26
|
-
return class_constructor;
|
26
|
+
return addondata::Get()->_casConstructor;
|
27
27
|
}
|
28
28
|
|
29
29
|
private:
|