couchbase 3.2.0 → 3.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/README.md +24 -18
  2. package/binding.gyp +88 -85
  3. package/deps/lcb/CMakeLists.txt +1 -1
  4. package/deps/lcb/CONTRIBUTING.md +1 -1
  5. package/deps/lcb/README.markdown +2 -2
  6. package/deps/lcb/RELEASE_NOTES.markdown +99 -14
  7. package/deps/lcb/cmake/Modules/GetVersionInfo.cmake +1 -1
  8. package/deps/lcb/contrib/cbsasl/src/scram-sha/scram_utils.cc +22 -26
  9. package/deps/lcb/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp +20 -7
  10. package/deps/lcb/doc/Doxyfile +1 -1
  11. package/deps/lcb/example/CMakeLists.txt +4 -4
  12. package/deps/lcb/example/libuvdirect/main.c +39 -12
  13. package/deps/lcb/example/minimal/durability.cc +149 -0
  14. package/deps/lcb/example/minimal/query.c +11 -9
  15. package/deps/lcb/gyp_config/common/libcouchbase/configuration.h +3 -3
  16. package/deps/lcb/gyp_config/linux/arm64/config.h +243 -0
  17. package/deps/lcb/include/libcouchbase/couchbase.h +80 -5
  18. package/deps/lcb/include/libcouchbase/error.h +2 -0
  19. package/deps/lcb/include/libcouchbase/ixmgmt.h +15 -10
  20. package/deps/lcb/include/libcouchbase/tracing.h +2 -2
  21. package/deps/lcb/include/memcached/protocol_binary.h +21 -0
  22. package/deps/lcb/libcouchbase.gyp +347 -349
  23. package/deps/lcb/packaging/deb/control +1 -1
  24. package/deps/lcb/src/analytics/analytics_handle.cc +13 -5
  25. package/deps/lcb/src/analytics/analytics_handle.hh +29 -0
  26. package/deps/lcb/src/bootstrap.cc +6 -3
  27. package/deps/lcb/src/capi/cmd_analytics.cc +12 -1
  28. package/deps/lcb/src/capi/cmd_analytics.hh +30 -0
  29. package/deps/lcb/src/capi/cmd_counter.hh +23 -0
  30. package/deps/lcb/src/capi/cmd_exists.hh +24 -1
  31. package/deps/lcb/src/capi/cmd_get.hh +22 -0
  32. package/deps/lcb/src/capi/cmd_get_replica.hh +23 -0
  33. package/deps/lcb/src/capi/cmd_http.hh +7 -0
  34. package/deps/lcb/src/capi/cmd_query.cc +11 -1
  35. package/deps/lcb/src/capi/cmd_query.hh +31 -0
  36. package/deps/lcb/src/capi/cmd_remove.hh +23 -0
  37. package/deps/lcb/src/capi/cmd_search.cc +6 -0
  38. package/deps/lcb/src/capi/cmd_search.hh +23 -0
  39. package/deps/lcb/src/capi/cmd_store.hh +33 -21
  40. package/deps/lcb/src/capi/cmd_subdoc.hh +35 -0
  41. package/deps/lcb/src/capi/cmd_touch.hh +23 -0
  42. package/deps/lcb/src/capi/cmd_unlock.hh +23 -0
  43. package/deps/lcb/src/capi/cmd_view.hh +6 -0
  44. package/deps/lcb/src/capi/collection_qualifier.hh +2 -2
  45. package/deps/lcb/src/cntl.cc +45 -11
  46. package/deps/lcb/src/crypto.cc +2 -2
  47. package/deps/lcb/src/dns-srv.cc +5 -3
  48. package/deps/lcb/src/errmap.cc +5 -9
  49. package/deps/lcb/src/errmap.h +7 -3
  50. package/deps/lcb/src/handler.cc +24 -18
  51. package/deps/lcb/src/hostlist.h +2 -2
  52. package/deps/lcb/src/http/http-priv.h +2 -2
  53. package/deps/lcb/src/http/http.cc +5 -2
  54. package/deps/lcb/src/instance.cc +20 -11
  55. package/deps/lcb/src/internal.h +9 -0
  56. package/deps/lcb/src/lcbio/connect.cc +14 -2
  57. package/deps/lcb/src/lcbio/connect.h +2 -2
  58. package/deps/lcb/src/lcbio/ctx.cc +4 -2
  59. package/deps/lcb/src/lcbio/ioutils.cc +9 -10
  60. package/deps/lcb/src/lcbio/manager.cc +1 -1
  61. package/deps/lcb/src/mcserver/mcserver.cc +9 -6
  62. package/deps/lcb/src/mcserver/negotiate.cc +39 -17
  63. package/deps/lcb/src/n1ql/ixmgmt.cc +1 -2
  64. package/deps/lcb/src/n1ql/query_handle.cc +41 -19
  65. package/deps/lcb/src/n1ql/query_handle.hh +28 -1
  66. package/deps/lcb/src/operations/counter.cc +18 -5
  67. package/deps/lcb/src/operations/exists.cc +25 -4
  68. package/deps/lcb/src/operations/get.cc +39 -19
  69. package/deps/lcb/src/operations/get_replica.cc +28 -8
  70. package/deps/lcb/src/operations/observe.cc +1 -1
  71. package/deps/lcb/src/operations/ping.cc +8 -8
  72. package/deps/lcb/src/operations/pktfwd.cc +2 -1
  73. package/deps/lcb/src/operations/remove.cc +39 -22
  74. package/deps/lcb/src/operations/store.cc +18 -5
  75. package/deps/lcb/src/operations/subdoc.cc +18 -6
  76. package/deps/lcb/src/operations/touch.cc +34 -16
  77. package/deps/lcb/src/operations/unlock.cc +24 -5
  78. package/deps/lcb/src/packetutils.h +3 -2
  79. package/deps/lcb/src/retryq.cc +24 -5
  80. package/deps/lcb/src/search/search.cc +1 -0
  81. package/deps/lcb/src/search/search_handle.cc +30 -8
  82. package/deps/lcb/src/search/search_handle.hh +29 -0
  83. package/deps/lcb/src/settings.cc +1 -1
  84. package/deps/lcb/src/ssl/ssl_common.c +6 -7
  85. package/deps/lcb/src/tracing/span.cc +47 -14
  86. package/deps/lcb/src/tracing/tracer.cc +11 -2
  87. package/deps/lcb/src/tracing/tracing-internal.h +105 -93
  88. package/deps/lcb/src/utilities.cc +43 -0
  89. package/deps/lcb/src/utilities.h +53 -0
  90. package/deps/lcb/src/vbucket/vbucket.c +34 -33
  91. package/deps/lcb/src/views/view_handle.cc +13 -5
  92. package/deps/lcb/src/views/view_handle.hh +29 -0
  93. package/deps/lcb/tests/CMakeLists.txt +21 -0
  94. package/deps/lcb/tests/basic/t_ctlcodes.cc +24 -3
  95. package/deps/lcb/tests/basic/t_jsparse.cc +8 -0
  96. package/deps/lcb/tests/basic/t_n1qlstrings.cc +73 -0
  97. package/deps/lcb/tests/iotests/mock-environment.cc +30 -1
  98. package/deps/lcb/tests/iotests/mock-environment.h +49 -0
  99. package/deps/lcb/tests/iotests/mock-unit-test.cc +104 -6
  100. package/deps/lcb/tests/iotests/mock-unit-test.h +34 -0
  101. package/deps/lcb/tests/iotests/t_collections.cc +1 -1
  102. package/deps/lcb/tests/iotests/t_confmon.cc +4 -2
  103. package/deps/lcb/tests/iotests/t_get.cc +109 -7
  104. package/deps/lcb/tests/iotests/t_http.cc +9 -4
  105. package/deps/lcb/tests/iotests/t_lock.cc +18 -0
  106. package/deps/lcb/tests/iotests/t_mutate.cc +157 -63
  107. package/deps/lcb/tests/iotests/t_n1ql.cc +330 -33
  108. package/deps/lcb/tests/iotests/t_views.cc +1 -0
  109. package/deps/lcb/tests/iotests/testutil.cc +168 -0
  110. package/deps/lcb/tests/iotests/testutil.h +116 -0
  111. package/deps/lcb/tests/mocksupport/procutil.c +32 -28
  112. package/deps/lcb/tests/mocksupport/server.c +0 -1
  113. package/deps/lcb/tests/mocksupport/timeout.c +2 -2
  114. package/deps/lcb/tools/cbc.cc +7 -0
  115. package/dist/analyticsindexmanager.js +512 -524
  116. package/dist/binding.d.ts +3 -0
  117. package/dist/bindingutilities.js +4 -0
  118. package/dist/bucket.js +1 -1
  119. package/dist/bucketmanager.d.ts +31 -1
  120. package/dist/bucketmanager.js +194 -186
  121. package/dist/cluster.d.ts +7 -0
  122. package/dist/cluster.js +48 -38
  123. package/dist/collection.js +11 -17
  124. package/dist/collectionmanager.js +181 -197
  125. package/dist/connection.d.ts +3 -1
  126. package/dist/connection.js +27 -16
  127. package/dist/couchbase.d.ts +1 -0
  128. package/dist/couchbase.js +3 -13
  129. package/dist/datastructures.js +239 -310
  130. package/dist/diagnosticsexecutor.js +70 -85
  131. package/dist/errors.d.ts +70 -0
  132. package/dist/errors.js +96 -2
  133. package/dist/eventingfunctionmanager.d.ts +804 -0
  134. package/dist/eventingfunctionmanager.js +993 -0
  135. package/dist/httpexecutor.d.ts +2 -1
  136. package/dist/httpexecutor.js +30 -37
  137. package/dist/queryindexmanager.js +240 -266
  138. package/dist/scope.js +10 -4
  139. package/dist/sdspecs.d.ts +1 -1
  140. package/dist/searchexecutor.js +3 -0
  141. package/dist/searchindexmanager.js +240 -271
  142. package/dist/searchquery.d.ts +17 -0
  143. package/dist/searchquery.js +22 -1
  144. package/dist/searchtypes.d.ts +7 -2
  145. package/dist/searchtypes.js +2 -2
  146. package/dist/usermanager.js +251 -264
  147. package/dist/utilities.d.ts +2 -0
  148. package/dist/utilities.js +7 -2
  149. package/dist/viewexecutor.js +1 -1
  150. package/dist/viewindexmanager.js +131 -150
  151. package/package.json +1 -1
  152. package/src/addondata.cpp +58 -0
  153. package/src/addondata.h +40 -0
  154. package/src/binding.cpp +3 -1
  155. package/src/cas.h +2 -2
  156. package/src/connection.cpp +25 -178
  157. package/src/connection.h +8 -65
  158. package/src/connection_ops.cpp +57 -34
  159. package/src/constants.cpp +3 -0
  160. package/src/instance.cpp +235 -0
  161. package/src/instance.h +102 -0
  162. package/src/{connection_callbacks.cpp → instance_callbacks.cpp} +34 -34
  163. package/src/logger.cpp +11 -1
  164. package/src/logger.h +3 -0
  165. package/src/metrics.cpp +10 -0
  166. package/src/metrics.h +3 -0
  167. package/src/mutationtoken.h +2 -2
  168. package/src/opbuilder.h +13 -15
  169. package/src/respreader.cpp +1 -0
  170. package/src/respreader.h +6 -4
  171. package/src/tracespan.h +11 -11
  172. package/src/tracing.cpp +11 -0
  173. package/src/tracing.h +3 -0
  174. package/src/valueparser.h +5 -0
  175. package/deps/lcb/example/observe/durability.c +0 -110
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.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 Object.assign(Object.assign({ type: 'couchbase' }, dvSpecific), { hostname: data.hostname, username: data.username, password: data.password, encryption: data.encryption ? data.encryption.encryptionLevel : undefined, certificate: data.encryption
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, clientCertificate: data.encryption
189
+ : undefined,
190
+ clientCertificate: data.encryption
192
191
  ? data.encryption.clientCertificate
193
192
  ? data.encryption.clientCertificate.toString()
194
193
  : undefined
195
- : undefined, clientKey: data.encryption
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 Object.assign(Object.assign({ type: 's3' }, dvSpecific), { accessKeyId: data.accessKeyId, secretAccessKey: data.secretAccessKey, region: data.region, sessionToken: data.sessionToken, serviceEndpoint: data.serviceEndpoint });
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 Object.assign(Object.assign({ type: 'azure' }, dvSpecific), { connectionString: data.connectionString, accountName: data.accountName, accountKey: data.accountKey, sharedAccessSignature: data.sharedAccessSignature, blobEndpoint: data.blobEndpoint, endpointSuffix: data.endpointSuffix });
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
- return __awaiter(this, arguments, void 0, function* () {
361
- if (options instanceof Function) {
362
- callback = arguments[1];
363
- options = undefined;
364
- }
365
- if (!options) {
366
- options = {};
367
- }
368
- let qs = '';
369
- qs += 'CREATE DATAVERSE';
370
- qs += ' `' + dataverseName.split('/').join('`.`') + '`';
371
- if (options.ignoreIfExists) {
372
- qs += ' IF NOT EXISTS';
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
- const parentSpan = options.parentSpan;
375
- const timeout = options.timeout;
376
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
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
- }), callback);
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
- return __awaiter(this, arguments, void 0, function* () {
401
- if (options instanceof Function) {
402
- callback = arguments[1];
403
- options = undefined;
404
- }
405
- if (!options) {
406
- options = {};
407
- }
408
- let qs = '';
409
- qs += 'DROP DATAVERSE';
410
- qs += ' `' + dataverseName.split('/').join('`.`') + '`';
411
- if (options.ignoreIfNotExists) {
412
- qs += ' IF EXISTS';
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
- const parentSpan = options.parentSpan;
415
- const timeout = options.timeout;
416
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
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
- }), callback);
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
- return __awaiter(this, arguments, void 0, function* () {
442
- if (options instanceof Function) {
443
- callback = arguments[2];
444
- options = undefined;
445
- }
446
- if (!options) {
447
- options = {};
448
- }
449
- let qs = '';
450
- qs += 'CREATE DATASET';
451
- if (options.ignoreIfExists) {
452
- qs += ' IF NOT EXISTS';
453
- }
454
- if (options.dataverseName) {
455
- qs +=
456
- ' `' +
457
- options.dataverseName.split('/').join('`.`') +
458
- '`.`' +
459
- datasetName +
460
- '`';
461
- }
462
- else {
463
- qs += ' `' + datasetName + '`';
464
- }
465
- qs += ' ON `' + bucketName + '`';
466
- if (options.condition) {
467
- qs += ' WHERE ' + options.condition;
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
- const parentSpan = options.parentSpan;
470
- const timeout = options.timeout;
471
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
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
- }), callback);
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
- return __awaiter(this, arguments, void 0, function* () {
496
- if (options instanceof Function) {
497
- callback = arguments[1];
498
- options = undefined;
499
- }
500
- if (!options) {
501
- options = {};
502
- }
503
- let qs = '';
504
- qs += 'DROP DATASET';
505
- if (options.dataverseName) {
506
- qs +=
507
- ' `' +
508
- options.dataverseName.split('/').join('`.`') +
509
- '`.`' +
510
- datasetName +
511
- '`';
512
- }
513
- else {
514
- qs += ' `' + datasetName + '`';
515
- }
516
- if (options.ignoreIfNotExists) {
517
- qs += ' IF EXISTS';
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
- const parentSpan = options.parentSpan;
520
- const timeout = options.timeout;
521
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
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
- catch (err) {
529
- if (err instanceof errors_1.DatasetNotFoundError) {
530
- throw err;
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
- return __awaiter(this, arguments, void 0, function* () {
545
- if (options instanceof Function) {
546
- callback = arguments[0];
547
- options = undefined;
548
- }
549
- if (!options) {
550
- options = {};
551
- }
552
- const qs = 'SELECT d.* FROM `Metadata`.`Dataset` d WHERE d.DataverseName <> "Metadata"';
553
- const parentSpan = options.parentSpan;
554
- const timeout = options.timeout;
555
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
556
- const res = yield this._cluster.analyticsQuery(qs, {
557
- parentSpan: parentSpan,
558
- timeout: timeout,
559
- });
560
- const datasets = res.rows.map((row) => new AnalyticsDataset({
561
- name: row.DatasetName,
562
- dataverseName: row.DataverseName,
563
- linkName: row.LinkName,
564
- bucketName: row.BucketName,
565
- }));
566
- return datasets;
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
- return __awaiter(this, arguments, void 0, function* () {
581
- if (options instanceof Function) {
582
- callback = arguments[3];
583
- options = undefined;
584
- }
585
- if (!options) {
586
- options = {};
587
- }
588
- let qs = '';
589
- qs += 'CREATE INDEX';
590
- qs += ' `' + indexName + '`';
591
- if (options.ignoreIfExists) {
592
- qs += ' IF NOT EXISTS';
593
- }
594
- if (options.dataverseName) {
595
- qs +=
596
- ' ON `' +
597
- options.dataverseName.split('/').join('`.`') +
598
- '`.`' +
599
- datasetName +
600
- '`';
601
- }
602
- else {
603
- qs += ' ON `' + datasetName + '`';
604
- }
605
- qs += ' (';
606
- qs += Object.keys(fields)
607
- .map((i) => '`' + i + '`: ' + fields[i])
608
- .join(', ');
609
- qs += ')';
610
- const parentSpan = options.parentSpan;
611
- const timeout = options.timeout;
612
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
613
- yield this._cluster.analyticsQuery(qs, {
614
- parentSpan: parentSpan,
615
- timeout: timeout,
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
- return __awaiter(this, arguments, void 0, function* () {
630
- if (options instanceof Function) {
631
- callback = arguments[2];
632
- options = undefined;
633
- }
634
- if (!options) {
635
- options = {};
636
- }
637
- let qs = '';
638
- qs += 'DROP INDEX';
639
- if (options.dataverseName) {
640
- qs +=
641
- ' `' +
642
- options.dataverseName.split('/').join('`.`') +
643
- '`.`' +
644
- datasetName +
645
- '`';
646
- }
647
- else {
648
- qs += ' `' + datasetName + '`';
649
- }
650
- qs += '.`' + indexName + '`';
651
- if (options.ignoreIfNotExists) {
652
- qs += ' IF EXISTS';
653
- }
654
- const parentSpan = options.parentSpan;
655
- const timeout = options.timeout;
656
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
657
- yield this._cluster.analyticsQuery(qs, {
658
- parentSpan: parentSpan,
659
- timeout: timeout,
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
- return __awaiter(this, arguments, void 0, function* () {
672
- if (options instanceof Function) {
673
- callback = arguments[0];
674
- options = undefined;
675
- }
676
- if (!options) {
677
- options = {};
678
- }
679
- const qs = 'SELECT d.* FROM `Metadata`.`Index` d WHERE d.DataverseName <> "Metadata"';
680
- const parentSpan = options.parentSpan;
681
- const timeout = options.timeout;
682
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
683
- const res = yield this._cluster.analyticsQuery(qs, {
684
- parentSpan: parentSpan,
685
- timeout: timeout,
686
- });
687
- const indexes = res.rows.map((row) => new AnalyticsIndex({
688
- name: row.IndexName,
689
- datasetName: row.DatasetName,
690
- dataverseName: row.DataverseName,
691
- isPrimary: row.IsPrimary,
692
- }));
693
- return indexes;
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
- return __awaiter(this, arguments, void 0, function* () {
706
- if (options instanceof Function) {
707
- callback = arguments[1];
708
- options = undefined;
709
- }
710
- if (!options) {
711
- options = {};
712
- }
713
- const qs = 'CONNECT LINK ' + linkName;
714
- const parentSpan = options.parentSpan;
715
- const timeout = options.timeout;
716
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
717
- yield this._cluster.analyticsQuery(qs, {
718
- parentSpan: parentSpan,
719
- timeout: timeout,
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
- return __awaiter(this, arguments, void 0, function* () {
733
- if (options instanceof Function) {
734
- callback = arguments[1];
735
- options = undefined;
736
- }
737
- if (!options) {
738
- options = {};
739
- }
740
- const qs = 'DISCONNECT LINK ' + linkName;
741
- const parentSpan = options.parentSpan;
742
- const timeout = options.timeout;
743
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
744
- yield this._cluster.analyticsQuery(qs, {
745
- parentSpan: parentSpan,
746
- timeout: timeout,
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
- return __awaiter(this, arguments, void 0, function* () {
759
- if (options instanceof Function) {
760
- callback = arguments[0];
761
- options = undefined;
762
- }
763
- if (!options) {
764
- options = {};
765
- }
766
- const parentSpan = options.parentSpan;
767
- const timeout = options.timeout;
768
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
769
- const res = yield this._http.request({
770
- type: httpexecutor_1.HttpServiceType.Analytics,
771
- method: httpexecutor_1.HttpMethod.Get,
772
- path: `/analytics/node/agg/stats/remaining`,
773
- parentSpan: parentSpan,
774
- timeout: timeout,
775
- });
776
- if (res.statusCode !== 200) {
777
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
778
- throw new errors_1.CouchbaseError('failed to get pending mutations', undefined, errCtx);
779
- }
780
- return JSON.parse(res.body.toString());
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
- return __awaiter(this, arguments, void 0, function* () {
793
- if (options instanceof Function) {
794
- callback = arguments[0];
795
- options = undefined;
796
- }
797
- if (!options) {
798
- options = {};
799
- }
800
- const parentSpan = options.parentSpan;
801
- const timeout = options.timeout;
802
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
803
- const linkData = AnalyticsLink._toHttpData(link);
804
- const res = yield this._http.request({
805
- type: httpexecutor_1.HttpServiceType.Analytics,
806
- method: httpexecutor_1.HttpMethod.Post,
807
- path: linkData.httpPath,
808
- contentType: 'application/x-www-form-urlencoded',
809
- body: utilities_1.cbQsStringify({
810
- linkData,
811
- httpPath: undefined,
812
- }),
813
- parentSpan: parentSpan,
814
- timeout: timeout,
815
- });
816
- if (res.statusCode !== 200) {
817
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
818
- const errText = res.body.toString().toLowerCase();
819
- if (errText.includes('24055')) {
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
- }), callback);
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
- return __awaiter(this, arguments, void 0, function* () {
839
- if (options instanceof Function) {
840
- callback = arguments[0];
841
- options = undefined;
842
- }
843
- if (!options) {
844
- options = {};
845
- }
846
- const parentSpan = options.parentSpan;
847
- const timeout = options.timeout;
848
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
849
- const linkData = AnalyticsLink._toHttpData(link);
850
- const res = yield this._http.request({
851
- type: httpexecutor_1.HttpServiceType.Analytics,
852
- method: httpexecutor_1.HttpMethod.Put,
853
- path: linkData.httpPath,
854
- contentType: 'application/x-www-form-urlencoded',
855
- body: utilities_1.cbQsStringify({
856
- linkData,
857
- httpPath: undefined,
858
- }),
859
- parentSpan: parentSpan,
860
- timeout: timeout,
861
- });
862
- if (res.statusCode !== 200) {
863
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
864
- const errText = res.body.toString().toLowerCase();
865
- if (errText.includes('24055')) {
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
- }), callback);
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
- return __awaiter(this, arguments, void 0, function* () {
886
- if (options instanceof Function) {
887
- callback = arguments[0];
888
- options = undefined;
889
- }
890
- if (!options) {
891
- options = {};
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
- const parentSpan = options.parentSpan;
894
- const timeout = options.timeout;
895
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
896
- let httpPath;
897
- let httpParams;
898
- if (dataverseName.indexOf('/') !== -1) {
899
- const encDataverse = encodeURIComponent(dataverseName);
900
- const encName = encodeURIComponent(linkName);
901
- httpPath = `/analytics/link/${encDataverse}/${encName}`;
902
- httpParams = {};
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
- httpPath = `/analytics/link`;
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
- const res = yield this._http.request({
912
- type: httpexecutor_1.HttpServiceType.Analytics,
913
- method: httpexecutor_1.HttpMethod.Delete,
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
- return __awaiter(this, arguments, void 0, function* () {
942
- if (options instanceof Function) {
943
- callback = arguments[0];
944
- options = undefined;
945
- }
946
- if (!options) {
947
- options = {};
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
- const dataverseName = options.dataverse;
950
- const linkName = options.name;
951
- const linkType = options.linkType;
952
- const parentSpan = options.parentSpan;
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
- const encName = encodeURIComponent(linkName);
961
- httpPath += `/${encName}`;
962
- }
963
- httpPath += '?';
964
- if (linkType) {
965
- httpPath += `type=${linkType}&`;
962
+ httpPath += `dataverse=${linkName}&`;
966
963
  }
967
964
  }
968
- else {
969
- httpPath = `/analytics/link?`;
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
- const res = yield this._http.request({
981
- type: httpexecutor_1.HttpServiceType.Analytics,
982
- method: httpexecutor_1.HttpMethod.Get,
983
- path: httpPath,
984
- parentSpan: parentSpan,
985
- timeout: timeout,
986
- });
987
- if (res.statusCode !== 200) {
988
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
989
- const errText = res.body.toString().toLowerCase();
990
- if (errText.includes('24034')) {
991
- throw new errors_1.DataverseNotFoundError(undefined, errCtx);
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
- const linksData = JSON.parse(res.body.toString());
996
- const links = linksData.map((linkData) => AnalyticsLink._fromHttpData(linkData));
997
- return links;
998
- }), callback);
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;