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.
- 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
|
@@ -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.AnalyticsIndexManager = exports.AzureExternalAnalyticsLink = exports.S3ExternalAnalyticsLink = exports.CouchbaseRemoteAnalyticsLink = exports.AnalyticsLink = exports.CouchbaseAnalyticsEncryptionSettings = exports.AnalyticsIndex = exports.AnalyticsDataset = exports.AnalyticsEncryptionLevel = exports.AnalyticsLinkType = void 0;
|
|
13
4
|
const errors_1 = require("./errors");
|
|
@@ -184,19 +175,29 @@ class CouchbaseRemoteAnalyticsLink extends AnalyticsLink {
|
|
|
184
175
|
name: data.name,
|
|
185
176
|
};
|
|
186
177
|
}
|
|
187
|
-
return
|
|
178
|
+
return {
|
|
179
|
+
type: 'couchbase',
|
|
180
|
+
...dvSpecific,
|
|
181
|
+
hostname: data.hostname,
|
|
182
|
+
username: data.username,
|
|
183
|
+
password: data.password,
|
|
184
|
+
encryption: data.encryption ? data.encryption.encryptionLevel : undefined,
|
|
185
|
+
certificate: data.encryption
|
|
188
186
|
? data.encryption.certificate
|
|
189
187
|
? data.encryption.certificate.toString()
|
|
190
188
|
: undefined
|
|
191
|
-
: undefined,
|
|
189
|
+
: undefined,
|
|
190
|
+
clientCertificate: data.encryption
|
|
192
191
|
? data.encryption.clientCertificate
|
|
193
192
|
? data.encryption.clientCertificate.toString()
|
|
194
193
|
: undefined
|
|
195
|
-
: undefined,
|
|
194
|
+
: undefined,
|
|
195
|
+
clientKey: data.encryption
|
|
196
196
|
? data.encryption.clientKey
|
|
197
197
|
? data.encryption.clientKey.toString()
|
|
198
198
|
: undefined
|
|
199
|
-
: undefined
|
|
199
|
+
: undefined,
|
|
200
|
+
};
|
|
200
201
|
}
|
|
201
202
|
/**
|
|
202
203
|
* @internal
|
|
@@ -256,7 +257,15 @@ class S3ExternalAnalyticsLink extends AnalyticsLink {
|
|
|
256
257
|
name: data.name,
|
|
257
258
|
};
|
|
258
259
|
}
|
|
259
|
-
return
|
|
260
|
+
return {
|
|
261
|
+
type: 's3',
|
|
262
|
+
...dvSpecific,
|
|
263
|
+
accessKeyId: data.accessKeyId,
|
|
264
|
+
secretAccessKey: data.secretAccessKey,
|
|
265
|
+
region: data.region,
|
|
266
|
+
sessionToken: data.sessionToken,
|
|
267
|
+
serviceEndpoint: data.serviceEndpoint,
|
|
268
|
+
};
|
|
260
269
|
}
|
|
261
270
|
/**
|
|
262
271
|
* @internal
|
|
@@ -313,7 +322,16 @@ class AzureExternalAnalyticsLink extends AnalyticsLink {
|
|
|
313
322
|
name: data.name,
|
|
314
323
|
};
|
|
315
324
|
}
|
|
316
|
-
return
|
|
325
|
+
return {
|
|
326
|
+
type: 'azure',
|
|
327
|
+
...dvSpecific,
|
|
328
|
+
connectionString: data.connectionString,
|
|
329
|
+
accountName: data.accountName,
|
|
330
|
+
accountKey: data.accountKey,
|
|
331
|
+
sharedAccessSignature: data.sharedAccessSignature,
|
|
332
|
+
blobEndpoint: data.blobEndpoint,
|
|
333
|
+
endpointSuffix: data.endpointSuffix,
|
|
334
|
+
};
|
|
317
335
|
}
|
|
318
336
|
/**
|
|
319
337
|
* @internal
|
|
@@ -356,38 +374,36 @@ class AnalyticsIndexManager {
|
|
|
356
374
|
* @param options Optional parameters for this operation.
|
|
357
375
|
* @param callback A node-style callback to be invoked after execution.
|
|
358
376
|
*/
|
|
359
|
-
createDataverse(dataverseName, options, callback) {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
377
|
+
async createDataverse(dataverseName, options, callback) {
|
|
378
|
+
if (options instanceof Function) {
|
|
379
|
+
callback = arguments[1];
|
|
380
|
+
options = undefined;
|
|
381
|
+
}
|
|
382
|
+
if (!options) {
|
|
383
|
+
options = {};
|
|
384
|
+
}
|
|
385
|
+
let qs = '';
|
|
386
|
+
qs += 'CREATE DATAVERSE';
|
|
387
|
+
qs += ' `' + dataverseName.split('/').join('`.`') + '`';
|
|
388
|
+
if (options.ignoreIfExists) {
|
|
389
|
+
qs += ' IF NOT EXISTS';
|
|
390
|
+
}
|
|
391
|
+
const parentSpan = options.parentSpan;
|
|
392
|
+
const timeout = options.timeout;
|
|
393
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
394
|
+
try {
|
|
395
|
+
await this._cluster.analyticsQuery(qs, {
|
|
396
|
+
parentSpan: parentSpan,
|
|
397
|
+
timeout: timeout,
|
|
398
|
+
});
|
|
373
399
|
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
try {
|
|
378
|
-
yield this._cluster.analyticsQuery(qs, {
|
|
379
|
-
parentSpan: parentSpan,
|
|
380
|
-
timeout: timeout,
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
catch (err) {
|
|
384
|
-
if (err instanceof errors_1.DataverseExistsError) {
|
|
385
|
-
throw err;
|
|
386
|
-
}
|
|
387
|
-
throw new errors_1.CouchbaseError('failed to create dataverse', err);
|
|
400
|
+
catch (err) {
|
|
401
|
+
if (err instanceof errors_1.DataverseExistsError) {
|
|
402
|
+
throw err;
|
|
388
403
|
}
|
|
389
|
-
|
|
390
|
-
|
|
404
|
+
throw new errors_1.CouchbaseError('failed to create dataverse', err);
|
|
405
|
+
}
|
|
406
|
+
}, callback);
|
|
391
407
|
}
|
|
392
408
|
/**
|
|
393
409
|
* Drops a previously created dataverse.
|
|
@@ -396,38 +412,36 @@ class AnalyticsIndexManager {
|
|
|
396
412
|
* @param options Optional parameters for this operation.
|
|
397
413
|
* @param callback A node-style callback to be invoked after execution.
|
|
398
414
|
*/
|
|
399
|
-
dropDataverse(dataverseName, options, callback) {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
415
|
+
async dropDataverse(dataverseName, options, callback) {
|
|
416
|
+
if (options instanceof Function) {
|
|
417
|
+
callback = arguments[1];
|
|
418
|
+
options = undefined;
|
|
419
|
+
}
|
|
420
|
+
if (!options) {
|
|
421
|
+
options = {};
|
|
422
|
+
}
|
|
423
|
+
let qs = '';
|
|
424
|
+
qs += 'DROP DATAVERSE';
|
|
425
|
+
qs += ' `' + dataverseName.split('/').join('`.`') + '`';
|
|
426
|
+
if (options.ignoreIfNotExists) {
|
|
427
|
+
qs += ' IF EXISTS';
|
|
428
|
+
}
|
|
429
|
+
const parentSpan = options.parentSpan;
|
|
430
|
+
const timeout = options.timeout;
|
|
431
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
432
|
+
try {
|
|
433
|
+
await this._cluster.analyticsQuery(qs, {
|
|
434
|
+
parentSpan: parentSpan,
|
|
435
|
+
timeout: timeout,
|
|
436
|
+
});
|
|
413
437
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
try {
|
|
418
|
-
yield this._cluster.analyticsQuery(qs, {
|
|
419
|
-
parentSpan: parentSpan,
|
|
420
|
-
timeout: timeout,
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
catch (err) {
|
|
424
|
-
if (err instanceof errors_1.DataverseNotFoundError) {
|
|
425
|
-
throw err;
|
|
426
|
-
}
|
|
427
|
-
throw new errors_1.CouchbaseError('failed to drop dataverse', err);
|
|
438
|
+
catch (err) {
|
|
439
|
+
if (err instanceof errors_1.DataverseNotFoundError) {
|
|
440
|
+
throw err;
|
|
428
441
|
}
|
|
429
|
-
|
|
430
|
-
|
|
442
|
+
throw new errors_1.CouchbaseError('failed to drop dataverse', err);
|
|
443
|
+
}
|
|
444
|
+
}, callback);
|
|
431
445
|
}
|
|
432
446
|
/**
|
|
433
447
|
* Creates a new dataset.
|
|
@@ -437,52 +451,50 @@ class AnalyticsIndexManager {
|
|
|
437
451
|
* @param options Optional parameters for this operation.
|
|
438
452
|
* @param callback A node-style callback to be invoked after execution.
|
|
439
453
|
*/
|
|
440
|
-
createDataset(bucketName, datasetName, options, callback) {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
'
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
454
|
+
async createDataset(bucketName, datasetName, options, callback) {
|
|
455
|
+
if (options instanceof Function) {
|
|
456
|
+
callback = arguments[2];
|
|
457
|
+
options = undefined;
|
|
458
|
+
}
|
|
459
|
+
if (!options) {
|
|
460
|
+
options = {};
|
|
461
|
+
}
|
|
462
|
+
let qs = '';
|
|
463
|
+
qs += 'CREATE DATASET';
|
|
464
|
+
if (options.ignoreIfExists) {
|
|
465
|
+
qs += ' IF NOT EXISTS';
|
|
466
|
+
}
|
|
467
|
+
if (options.dataverseName) {
|
|
468
|
+
qs +=
|
|
469
|
+
' `' +
|
|
470
|
+
options.dataverseName.split('/').join('`.`') +
|
|
471
|
+
'`.`' +
|
|
472
|
+
datasetName +
|
|
473
|
+
'`';
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
qs += ' `' + datasetName + '`';
|
|
477
|
+
}
|
|
478
|
+
qs += ' ON `' + bucketName + '`';
|
|
479
|
+
if (options.condition) {
|
|
480
|
+
qs += ' WHERE ' + options.condition;
|
|
481
|
+
}
|
|
482
|
+
const parentSpan = options.parentSpan;
|
|
483
|
+
const timeout = options.timeout;
|
|
484
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
485
|
+
try {
|
|
486
|
+
await this._cluster.analyticsQuery(qs, {
|
|
487
|
+
parentSpan: parentSpan,
|
|
488
|
+
timeout: timeout,
|
|
489
|
+
});
|
|
468
490
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
try {
|
|
473
|
-
yield this._cluster.analyticsQuery(qs, {
|
|
474
|
-
parentSpan: parentSpan,
|
|
475
|
-
timeout: timeout,
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
catch (err) {
|
|
479
|
-
if (err instanceof errors_1.DatasetExistsError) {
|
|
480
|
-
throw err;
|
|
481
|
-
}
|
|
482
|
-
throw new errors_1.CouchbaseError('failed to create dataset', err);
|
|
491
|
+
catch (err) {
|
|
492
|
+
if (err instanceof errors_1.DatasetExistsError) {
|
|
493
|
+
throw err;
|
|
483
494
|
}
|
|
484
|
-
|
|
485
|
-
|
|
495
|
+
throw new errors_1.CouchbaseError('failed to create dataset', err);
|
|
496
|
+
}
|
|
497
|
+
}, callback);
|
|
486
498
|
}
|
|
487
499
|
/**
|
|
488
500
|
* Drops a previously created dataset.
|
|
@@ -491,48 +503,46 @@ class AnalyticsIndexManager {
|
|
|
491
503
|
* @param options Optional parameters for this operation.
|
|
492
504
|
* @param callback A node-style callback to be invoked after execution.
|
|
493
505
|
*/
|
|
494
|
-
dropDataset(datasetName, options, callback) {
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
'
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
506
|
+
async dropDataset(datasetName, options, callback) {
|
|
507
|
+
if (options instanceof Function) {
|
|
508
|
+
callback = arguments[1];
|
|
509
|
+
options = undefined;
|
|
510
|
+
}
|
|
511
|
+
if (!options) {
|
|
512
|
+
options = {};
|
|
513
|
+
}
|
|
514
|
+
let qs = '';
|
|
515
|
+
qs += 'DROP DATASET';
|
|
516
|
+
if (options.dataverseName) {
|
|
517
|
+
qs +=
|
|
518
|
+
' `' +
|
|
519
|
+
options.dataverseName.split('/').join('`.`') +
|
|
520
|
+
'`.`' +
|
|
521
|
+
datasetName +
|
|
522
|
+
'`';
|
|
523
|
+
}
|
|
524
|
+
else {
|
|
525
|
+
qs += ' `' + datasetName + '`';
|
|
526
|
+
}
|
|
527
|
+
if (options.ignoreIfNotExists) {
|
|
528
|
+
qs += ' IF EXISTS';
|
|
529
|
+
}
|
|
530
|
+
const parentSpan = options.parentSpan;
|
|
531
|
+
const timeout = options.timeout;
|
|
532
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
533
|
+
try {
|
|
534
|
+
await this._cluster.analyticsQuery(qs, {
|
|
535
|
+
parentSpan: parentSpan,
|
|
536
|
+
timeout: timeout,
|
|
537
|
+
});
|
|
518
538
|
}
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
try {
|
|
523
|
-
yield this._cluster.analyticsQuery(qs, {
|
|
524
|
-
parentSpan: parentSpan,
|
|
525
|
-
timeout: timeout,
|
|
526
|
-
});
|
|
539
|
+
catch (err) {
|
|
540
|
+
if (err instanceof errors_1.DatasetNotFoundError) {
|
|
541
|
+
throw err;
|
|
527
542
|
}
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
}
|
|
532
|
-
throw new errors_1.CouchbaseError('failed to drop dataset', err);
|
|
533
|
-
}
|
|
534
|
-
}), callback);
|
|
535
|
-
});
|
|
543
|
+
throw new errors_1.CouchbaseError('failed to drop dataset', err);
|
|
544
|
+
}
|
|
545
|
+
}, callback);
|
|
536
546
|
}
|
|
537
547
|
/**
|
|
538
548
|
* Returns a list of all existing datasets.
|
|
@@ -540,32 +550,30 @@ class AnalyticsIndexManager {
|
|
|
540
550
|
* @param options Optional parameters for this operation.
|
|
541
551
|
* @param callback A node-style callback to be invoked after execution.
|
|
542
552
|
*/
|
|
543
|
-
getAllDatasets(options, callback) {
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
}), callback);
|
|
568
|
-
});
|
|
553
|
+
async getAllDatasets(options, callback) {
|
|
554
|
+
if (options instanceof Function) {
|
|
555
|
+
callback = arguments[0];
|
|
556
|
+
options = undefined;
|
|
557
|
+
}
|
|
558
|
+
if (!options) {
|
|
559
|
+
options = {};
|
|
560
|
+
}
|
|
561
|
+
const qs = 'SELECT d.* FROM `Metadata`.`Dataset` d WHERE d.DataverseName <> "Metadata"';
|
|
562
|
+
const parentSpan = options.parentSpan;
|
|
563
|
+
const timeout = options.timeout;
|
|
564
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
565
|
+
const res = await this._cluster.analyticsQuery(qs, {
|
|
566
|
+
parentSpan: parentSpan,
|
|
567
|
+
timeout: timeout,
|
|
568
|
+
});
|
|
569
|
+
const datasets = res.rows.map((row) => new AnalyticsDataset({
|
|
570
|
+
name: row.DatasetName,
|
|
571
|
+
dataverseName: row.DataverseName,
|
|
572
|
+
linkName: row.LinkName,
|
|
573
|
+
bucketName: row.BucketName,
|
|
574
|
+
}));
|
|
575
|
+
return datasets;
|
|
576
|
+
}, callback);
|
|
569
577
|
}
|
|
570
578
|
/**
|
|
571
579
|
* Creates a new index.
|
|
@@ -576,46 +584,44 @@ class AnalyticsIndexManager {
|
|
|
576
584
|
* @param options Optional parameters for this operation.
|
|
577
585
|
* @param callback A node-style callback to be invoked after execution.
|
|
578
586
|
*/
|
|
579
|
-
createIndex(datasetName, indexName, fields, options, callback) {
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
'
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
}), callback);
|
|
618
|
-
});
|
|
587
|
+
async createIndex(datasetName, indexName, fields, options, callback) {
|
|
588
|
+
if (options instanceof Function) {
|
|
589
|
+
callback = arguments[3];
|
|
590
|
+
options = undefined;
|
|
591
|
+
}
|
|
592
|
+
if (!options) {
|
|
593
|
+
options = {};
|
|
594
|
+
}
|
|
595
|
+
let qs = '';
|
|
596
|
+
qs += 'CREATE INDEX';
|
|
597
|
+
qs += ' `' + indexName + '`';
|
|
598
|
+
if (options.ignoreIfExists) {
|
|
599
|
+
qs += ' IF NOT EXISTS';
|
|
600
|
+
}
|
|
601
|
+
if (options.dataverseName) {
|
|
602
|
+
qs +=
|
|
603
|
+
' ON `' +
|
|
604
|
+
options.dataverseName.split('/').join('`.`') +
|
|
605
|
+
'`.`' +
|
|
606
|
+
datasetName +
|
|
607
|
+
'`';
|
|
608
|
+
}
|
|
609
|
+
else {
|
|
610
|
+
qs += ' ON `' + datasetName + '`';
|
|
611
|
+
}
|
|
612
|
+
qs += ' (';
|
|
613
|
+
qs += Object.keys(fields)
|
|
614
|
+
.map((i) => '`' + i + '`: ' + fields[i])
|
|
615
|
+
.join(', ');
|
|
616
|
+
qs += ')';
|
|
617
|
+
const parentSpan = options.parentSpan;
|
|
618
|
+
const timeout = options.timeout;
|
|
619
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
620
|
+
await this._cluster.analyticsQuery(qs, {
|
|
621
|
+
parentSpan: parentSpan,
|
|
622
|
+
timeout: timeout,
|
|
623
|
+
});
|
|
624
|
+
}, callback);
|
|
619
625
|
}
|
|
620
626
|
/**
|
|
621
627
|
* Drops a previously created index.
|
|
@@ -625,41 +631,39 @@ class AnalyticsIndexManager {
|
|
|
625
631
|
* @param options Optional parameters for this operation.
|
|
626
632
|
* @param callback A node-style callback to be invoked after execution.
|
|
627
633
|
*/
|
|
628
|
-
dropIndex(datasetName, indexName, options, callback) {
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
'
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
}), callback);
|
|
662
|
-
});
|
|
634
|
+
async dropIndex(datasetName, indexName, options, callback) {
|
|
635
|
+
if (options instanceof Function) {
|
|
636
|
+
callback = arguments[2];
|
|
637
|
+
options = undefined;
|
|
638
|
+
}
|
|
639
|
+
if (!options) {
|
|
640
|
+
options = {};
|
|
641
|
+
}
|
|
642
|
+
let qs = '';
|
|
643
|
+
qs += 'DROP INDEX';
|
|
644
|
+
if (options.dataverseName) {
|
|
645
|
+
qs +=
|
|
646
|
+
' `' +
|
|
647
|
+
options.dataverseName.split('/').join('`.`') +
|
|
648
|
+
'`.`' +
|
|
649
|
+
datasetName +
|
|
650
|
+
'`';
|
|
651
|
+
}
|
|
652
|
+
else {
|
|
653
|
+
qs += ' `' + datasetName + '`';
|
|
654
|
+
}
|
|
655
|
+
qs += '.`' + indexName + '`';
|
|
656
|
+
if (options.ignoreIfNotExists) {
|
|
657
|
+
qs += ' IF EXISTS';
|
|
658
|
+
}
|
|
659
|
+
const parentSpan = options.parentSpan;
|
|
660
|
+
const timeout = options.timeout;
|
|
661
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
662
|
+
await this._cluster.analyticsQuery(qs, {
|
|
663
|
+
parentSpan: parentSpan,
|
|
664
|
+
timeout: timeout,
|
|
665
|
+
});
|
|
666
|
+
}, callback);
|
|
663
667
|
}
|
|
664
668
|
/**
|
|
665
669
|
* Returns a list of all existing indexes.
|
|
@@ -667,32 +671,30 @@ class AnalyticsIndexManager {
|
|
|
667
671
|
* @param options Optional parameters for this operation.
|
|
668
672
|
* @param callback A node-style callback to be invoked after execution.
|
|
669
673
|
*/
|
|
670
|
-
getAllIndexes(options, callback) {
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
}), callback);
|
|
695
|
-
});
|
|
674
|
+
async getAllIndexes(options, callback) {
|
|
675
|
+
if (options instanceof Function) {
|
|
676
|
+
callback = arguments[0];
|
|
677
|
+
options = undefined;
|
|
678
|
+
}
|
|
679
|
+
if (!options) {
|
|
680
|
+
options = {};
|
|
681
|
+
}
|
|
682
|
+
const qs = 'SELECT d.* FROM `Metadata`.`Index` d WHERE d.DataverseName <> "Metadata"';
|
|
683
|
+
const parentSpan = options.parentSpan;
|
|
684
|
+
const timeout = options.timeout;
|
|
685
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
686
|
+
const res = await this._cluster.analyticsQuery(qs, {
|
|
687
|
+
parentSpan: parentSpan,
|
|
688
|
+
timeout: timeout,
|
|
689
|
+
});
|
|
690
|
+
const indexes = res.rows.map((row) => new AnalyticsIndex({
|
|
691
|
+
name: row.IndexName,
|
|
692
|
+
datasetName: row.DatasetName,
|
|
693
|
+
dataverseName: row.DataverseName,
|
|
694
|
+
isPrimary: row.IsPrimary,
|
|
695
|
+
}));
|
|
696
|
+
return indexes;
|
|
697
|
+
}, callback);
|
|
696
698
|
}
|
|
697
699
|
/**
|
|
698
700
|
* Connects a not yet connected link.
|
|
@@ -701,25 +703,23 @@ class AnalyticsIndexManager {
|
|
|
701
703
|
* @param options Optional parameters for this operation.
|
|
702
704
|
* @param callback A node-style callback to be invoked after execution.
|
|
703
705
|
*/
|
|
704
|
-
connectLink(linkName, options, callback) {
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
}), callback);
|
|
722
|
-
});
|
|
706
|
+
async connectLink(linkName, options, callback) {
|
|
707
|
+
if (options instanceof Function) {
|
|
708
|
+
callback = arguments[1];
|
|
709
|
+
options = undefined;
|
|
710
|
+
}
|
|
711
|
+
if (!options) {
|
|
712
|
+
options = {};
|
|
713
|
+
}
|
|
714
|
+
const qs = 'CONNECT LINK ' + linkName;
|
|
715
|
+
const parentSpan = options.parentSpan;
|
|
716
|
+
const timeout = options.timeout;
|
|
717
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
718
|
+
await this._cluster.analyticsQuery(qs, {
|
|
719
|
+
parentSpan: parentSpan,
|
|
720
|
+
timeout: timeout,
|
|
721
|
+
});
|
|
722
|
+
}, callback);
|
|
723
723
|
}
|
|
724
724
|
/**
|
|
725
725
|
* Disconnects a previously connected link.
|
|
@@ -728,25 +728,23 @@ class AnalyticsIndexManager {
|
|
|
728
728
|
* @param options Optional parameters for this operation.
|
|
729
729
|
* @param callback A node-style callback to be invoked after execution.
|
|
730
730
|
*/
|
|
731
|
-
disconnectLink(linkName, options, callback) {
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
}), callback);
|
|
749
|
-
});
|
|
731
|
+
async disconnectLink(linkName, options, callback) {
|
|
732
|
+
if (options instanceof Function) {
|
|
733
|
+
callback = arguments[1];
|
|
734
|
+
options = undefined;
|
|
735
|
+
}
|
|
736
|
+
if (!options) {
|
|
737
|
+
options = {};
|
|
738
|
+
}
|
|
739
|
+
const qs = 'DISCONNECT LINK ' + linkName;
|
|
740
|
+
const parentSpan = options.parentSpan;
|
|
741
|
+
const timeout = options.timeout;
|
|
742
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
743
|
+
await this._cluster.analyticsQuery(qs, {
|
|
744
|
+
parentSpan: parentSpan,
|
|
745
|
+
timeout: timeout,
|
|
746
|
+
});
|
|
747
|
+
}, callback);
|
|
750
748
|
}
|
|
751
749
|
/**
|
|
752
750
|
* Returns a list of all pending mutations.
|
|
@@ -754,32 +752,30 @@ class AnalyticsIndexManager {
|
|
|
754
752
|
* @param options Optional parameters for this operation.
|
|
755
753
|
* @param callback A node-style callback to be invoked after execution.
|
|
756
754
|
*/
|
|
757
|
-
getPendingMutations(options, callback) {
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
}), callback);
|
|
782
|
-
});
|
|
755
|
+
async getPendingMutations(options, callback) {
|
|
756
|
+
if (options instanceof Function) {
|
|
757
|
+
callback = arguments[0];
|
|
758
|
+
options = undefined;
|
|
759
|
+
}
|
|
760
|
+
if (!options) {
|
|
761
|
+
options = {};
|
|
762
|
+
}
|
|
763
|
+
const parentSpan = options.parentSpan;
|
|
764
|
+
const timeout = options.timeout;
|
|
765
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
766
|
+
const res = await this._http.request({
|
|
767
|
+
type: httpexecutor_1.HttpServiceType.Analytics,
|
|
768
|
+
method: httpexecutor_1.HttpMethod.Get,
|
|
769
|
+
path: `/analytics/node/agg/stats/remaining`,
|
|
770
|
+
parentSpan: parentSpan,
|
|
771
|
+
timeout: timeout,
|
|
772
|
+
});
|
|
773
|
+
if (res.statusCode !== 200) {
|
|
774
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
|
775
|
+
throw new errors_1.CouchbaseError('failed to get pending mutations', undefined, errCtx);
|
|
776
|
+
}
|
|
777
|
+
return JSON.parse(res.body.toString());
|
|
778
|
+
}, callback);
|
|
783
779
|
}
|
|
784
780
|
/**
|
|
785
781
|
* Creates a new analytics remote link.
|
|
@@ -788,44 +784,42 @@ class AnalyticsIndexManager {
|
|
|
788
784
|
* @param options Optional parameters for this operation.
|
|
789
785
|
* @param callback A node-style callback to be invoked after execution.
|
|
790
786
|
*/
|
|
791
|
-
createLink(link, options, callback) {
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
throw new errors_1.LinkExistsError(undefined, errCtx);
|
|
821
|
-
}
|
|
822
|
-
else if (errText.includes('24034')) {
|
|
823
|
-
throw new errors_1.DataverseNotFoundError(undefined, errCtx);
|
|
824
|
-
}
|
|
825
|
-
throw new errors_1.CouchbaseError('failed to create link', undefined, errCtx);
|
|
787
|
+
async createLink(link, options, callback) {
|
|
788
|
+
if (options instanceof Function) {
|
|
789
|
+
callback = arguments[1];
|
|
790
|
+
options = undefined;
|
|
791
|
+
}
|
|
792
|
+
if (!options) {
|
|
793
|
+
options = {};
|
|
794
|
+
}
|
|
795
|
+
const parentSpan = options.parentSpan;
|
|
796
|
+
const timeout = options.timeout;
|
|
797
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
798
|
+
const linkData = AnalyticsLink._toHttpData(link);
|
|
799
|
+
const res = await this._http.request({
|
|
800
|
+
type: httpexecutor_1.HttpServiceType.Analytics,
|
|
801
|
+
method: httpexecutor_1.HttpMethod.Post,
|
|
802
|
+
path: linkData.httpPath,
|
|
803
|
+
contentType: 'application/x-www-form-urlencoded',
|
|
804
|
+
body: utilities_1.cbQsStringify({
|
|
805
|
+
linkData,
|
|
806
|
+
httpPath: undefined,
|
|
807
|
+
}),
|
|
808
|
+
parentSpan: parentSpan,
|
|
809
|
+
timeout: timeout,
|
|
810
|
+
});
|
|
811
|
+
if (res.statusCode !== 200) {
|
|
812
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
|
813
|
+
const errText = res.body.toString().toLowerCase();
|
|
814
|
+
if (errText.includes('24055')) {
|
|
815
|
+
throw new errors_1.LinkExistsError(undefined, errCtx);
|
|
826
816
|
}
|
|
827
|
-
|
|
828
|
-
|
|
817
|
+
else if (errText.includes('24034')) {
|
|
818
|
+
throw new errors_1.DataverseNotFoundError(undefined, errCtx);
|
|
819
|
+
}
|
|
820
|
+
throw new errors_1.CouchbaseError('failed to create link', undefined, errCtx);
|
|
821
|
+
}
|
|
822
|
+
}, callback);
|
|
829
823
|
}
|
|
830
824
|
/**
|
|
831
825
|
* Replaces an existing analytics remote link.
|
|
@@ -834,44 +828,42 @@ class AnalyticsIndexManager {
|
|
|
834
828
|
* @param options Optional parameters for this operation.
|
|
835
829
|
* @param callback A node-style callback to be invoked after execution.
|
|
836
830
|
*/
|
|
837
|
-
replaceLink(link, options, callback) {
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
throw new errors_1.LinkExistsError(undefined, errCtx);
|
|
867
|
-
}
|
|
868
|
-
else if (errText.includes('24034')) {
|
|
869
|
-
throw new errors_1.DataverseNotFoundError(undefined, errCtx);
|
|
870
|
-
}
|
|
871
|
-
throw new errors_1.CouchbaseError('failed to replace link', undefined, errCtx);
|
|
831
|
+
async replaceLink(link, options, callback) {
|
|
832
|
+
if (options instanceof Function) {
|
|
833
|
+
callback = arguments[1];
|
|
834
|
+
options = undefined;
|
|
835
|
+
}
|
|
836
|
+
if (!options) {
|
|
837
|
+
options = {};
|
|
838
|
+
}
|
|
839
|
+
const parentSpan = options.parentSpan;
|
|
840
|
+
const timeout = options.timeout;
|
|
841
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
842
|
+
const linkData = AnalyticsLink._toHttpData(link);
|
|
843
|
+
const res = await this._http.request({
|
|
844
|
+
type: httpexecutor_1.HttpServiceType.Analytics,
|
|
845
|
+
method: httpexecutor_1.HttpMethod.Put,
|
|
846
|
+
path: linkData.httpPath,
|
|
847
|
+
contentType: 'application/x-www-form-urlencoded',
|
|
848
|
+
body: utilities_1.cbQsStringify({
|
|
849
|
+
linkData,
|
|
850
|
+
httpPath: undefined,
|
|
851
|
+
}),
|
|
852
|
+
parentSpan: parentSpan,
|
|
853
|
+
timeout: timeout,
|
|
854
|
+
});
|
|
855
|
+
if (res.statusCode !== 200) {
|
|
856
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
|
857
|
+
const errText = res.body.toString().toLowerCase();
|
|
858
|
+
if (errText.includes('24055')) {
|
|
859
|
+
throw new errors_1.LinkExistsError(undefined, errCtx);
|
|
872
860
|
}
|
|
873
|
-
|
|
874
|
-
|
|
861
|
+
else if (errText.includes('24034')) {
|
|
862
|
+
throw new errors_1.DataverseNotFoundError(undefined, errCtx);
|
|
863
|
+
}
|
|
864
|
+
throw new errors_1.CouchbaseError('failed to replace link', undefined, errCtx);
|
|
865
|
+
}
|
|
866
|
+
}, callback);
|
|
875
867
|
}
|
|
876
868
|
/**
|
|
877
869
|
* Drops an existing analytics remote link.
|
|
@@ -881,55 +873,53 @@ class AnalyticsIndexManager {
|
|
|
881
873
|
* @param options Optional parameters for this operation.
|
|
882
874
|
* @param callback A node-style callback to be invoked after execution.
|
|
883
875
|
*/
|
|
884
|
-
dropLink(linkName, dataverseName, options, callback) {
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
876
|
+
async dropLink(linkName, dataverseName, options, callback) {
|
|
877
|
+
if (options instanceof Function) {
|
|
878
|
+
callback = arguments[2];
|
|
879
|
+
options = undefined;
|
|
880
|
+
}
|
|
881
|
+
if (!options) {
|
|
882
|
+
options = {};
|
|
883
|
+
}
|
|
884
|
+
const parentSpan = options.parentSpan;
|
|
885
|
+
const timeout = options.timeout;
|
|
886
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
887
|
+
let httpPath;
|
|
888
|
+
let httpParams;
|
|
889
|
+
if (dataverseName.indexOf('/') !== -1) {
|
|
890
|
+
const encDataverse = encodeURIComponent(dataverseName);
|
|
891
|
+
const encName = encodeURIComponent(linkName);
|
|
892
|
+
httpPath = `/analytics/link/${encDataverse}/${encName}`;
|
|
893
|
+
httpParams = {};
|
|
892
894
|
}
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
895
|
+
else {
|
|
896
|
+
httpPath = `/analytics/link`;
|
|
897
|
+
httpParams = {
|
|
898
|
+
dataverse: dataverseName,
|
|
899
|
+
name: linkName,
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
const res = await this._http.request({
|
|
903
|
+
type: httpexecutor_1.HttpServiceType.Analytics,
|
|
904
|
+
method: httpexecutor_1.HttpMethod.Delete,
|
|
905
|
+
path: httpPath,
|
|
906
|
+
contentType: 'application/x-www-form-urlencoded',
|
|
907
|
+
body: utilities_1.cbQsStringify(httpParams),
|
|
908
|
+
parentSpan: parentSpan,
|
|
909
|
+
timeout: timeout,
|
|
910
|
+
});
|
|
911
|
+
if (res.statusCode !== 200) {
|
|
912
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
|
913
|
+
const errText = res.body.toString().toLowerCase();
|
|
914
|
+
if (errText.includes('24055')) {
|
|
915
|
+
throw new errors_1.LinkExistsError(undefined, errCtx);
|
|
903
916
|
}
|
|
904
|
-
else {
|
|
905
|
-
|
|
906
|
-
httpParams = {
|
|
907
|
-
dataverse: dataverseName,
|
|
908
|
-
name: linkName,
|
|
909
|
-
};
|
|
917
|
+
else if (errText.includes('24034')) {
|
|
918
|
+
throw new errors_1.DataverseNotFoundError(undefined, errCtx);
|
|
910
919
|
}
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
path: httpPath,
|
|
915
|
-
contentType: 'application/x-www-form-urlencoded',
|
|
916
|
-
body: utilities_1.cbQsStringify(httpParams),
|
|
917
|
-
parentSpan: parentSpan,
|
|
918
|
-
timeout: timeout,
|
|
919
|
-
});
|
|
920
|
-
if (res.statusCode !== 200) {
|
|
921
|
-
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
|
922
|
-
const errText = res.body.toString().toLowerCase();
|
|
923
|
-
if (errText.includes('24055')) {
|
|
924
|
-
throw new errors_1.LinkExistsError(undefined, errCtx);
|
|
925
|
-
}
|
|
926
|
-
else if (errText.includes('24034')) {
|
|
927
|
-
throw new errors_1.DataverseNotFoundError(undefined, errCtx);
|
|
928
|
-
}
|
|
929
|
-
throw new errors_1.CouchbaseError('failed to delete link', undefined, errCtx);
|
|
930
|
-
}
|
|
931
|
-
}), callback);
|
|
932
|
-
});
|
|
920
|
+
throw new errors_1.CouchbaseError('failed to delete link', undefined, errCtx);
|
|
921
|
+
}
|
|
922
|
+
}, callback);
|
|
933
923
|
}
|
|
934
924
|
/**
|
|
935
925
|
* Returns a list of existing analytics remote links.
|
|
@@ -937,66 +927,64 @@ class AnalyticsIndexManager {
|
|
|
937
927
|
* @param options Optional parameters for this operation.
|
|
938
928
|
* @param callback A node-style callback to be invoked after execution.
|
|
939
929
|
*/
|
|
940
|
-
getAllLinks(options, callback) {
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
930
|
+
async getAllLinks(options, callback) {
|
|
931
|
+
if (options instanceof Function) {
|
|
932
|
+
callback = arguments[0];
|
|
933
|
+
options = undefined;
|
|
934
|
+
}
|
|
935
|
+
if (!options) {
|
|
936
|
+
options = {};
|
|
937
|
+
}
|
|
938
|
+
const dataverseName = options.dataverse;
|
|
939
|
+
const linkName = options.name;
|
|
940
|
+
const linkType = options.linkType;
|
|
941
|
+
const parentSpan = options.parentSpan;
|
|
942
|
+
const timeout = options.timeout;
|
|
943
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
944
|
+
let httpPath;
|
|
945
|
+
if (dataverseName && dataverseName.indexOf('/') !== -1) {
|
|
946
|
+
const encDataverse = encodeURIComponent(dataverseName);
|
|
947
|
+
httpPath = `/analytics/link/${encDataverse}`;
|
|
948
|
+
if (linkName) {
|
|
949
|
+
const encName = encodeURIComponent(linkName);
|
|
950
|
+
httpPath += `/${encName}`;
|
|
951
|
+
}
|
|
952
|
+
httpPath += '?';
|
|
953
|
+
if (linkType) {
|
|
954
|
+
httpPath += `type=${linkType}&`;
|
|
955
|
+
}
|
|
948
956
|
}
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
const timeout = options.timeout;
|
|
954
|
-
return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
|
|
955
|
-
let httpPath;
|
|
956
|
-
if (dataverseName && dataverseName.indexOf('/') !== -1) {
|
|
957
|
-
const encDataverse = encodeURIComponent(dataverseName);
|
|
958
|
-
httpPath = `/analytics/link/${encDataverse}`;
|
|
957
|
+
else {
|
|
958
|
+
httpPath = `/analytics/link?`;
|
|
959
|
+
if (dataverseName) {
|
|
960
|
+
httpPath += `dataverse=${dataverseName}&`;
|
|
959
961
|
if (linkName) {
|
|
960
|
-
|
|
961
|
-
httpPath += `/${encName}`;
|
|
962
|
-
}
|
|
963
|
-
httpPath += '?';
|
|
964
|
-
if (linkType) {
|
|
965
|
-
httpPath += `type=${linkType}&`;
|
|
962
|
+
httpPath += `dataverse=${linkName}&`;
|
|
966
963
|
}
|
|
967
964
|
}
|
|
968
|
-
|
|
969
|
-
httpPath
|
|
970
|
-
if (dataverseName) {
|
|
971
|
-
httpPath += `dataverse=${dataverseName}&`;
|
|
972
|
-
if (linkName) {
|
|
973
|
-
httpPath += `dataverse=${linkName}&`;
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
if (linkType) {
|
|
977
|
-
httpPath += `type=${linkType}&`;
|
|
978
|
-
}
|
|
965
|
+
if (linkType) {
|
|
966
|
+
httpPath += `type=${linkType}&`;
|
|
979
967
|
}
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
throw new errors_1.CouchbaseError('failed to get links', undefined, errCtx);
|
|
968
|
+
}
|
|
969
|
+
const res = await this._http.request({
|
|
970
|
+
type: httpexecutor_1.HttpServiceType.Analytics,
|
|
971
|
+
method: httpexecutor_1.HttpMethod.Get,
|
|
972
|
+
path: httpPath,
|
|
973
|
+
parentSpan: parentSpan,
|
|
974
|
+
timeout: timeout,
|
|
975
|
+
});
|
|
976
|
+
if (res.statusCode !== 200) {
|
|
977
|
+
const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
|
|
978
|
+
const errText = res.body.toString().toLowerCase();
|
|
979
|
+
if (errText.includes('24034')) {
|
|
980
|
+
throw new errors_1.DataverseNotFoundError(undefined, errCtx);
|
|
994
981
|
}
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
982
|
+
throw new errors_1.CouchbaseError('failed to get links', undefined, errCtx);
|
|
983
|
+
}
|
|
984
|
+
const linksData = JSON.parse(res.body.toString());
|
|
985
|
+
const links = linksData.map((linkData) => AnalyticsLink._fromHttpData(linkData));
|
|
986
|
+
return links;
|
|
987
|
+
}, callback);
|
|
1000
988
|
}
|
|
1001
989
|
}
|
|
1002
990
|
exports.AnalyticsIndexManager = AnalyticsIndexManager;
|