couchbase 4.4.6-dev.1 → 4.5.0

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 (139) hide show
  1. package/deps/couchbase-cxx-cache/mozilla-ca-bundle.crt +3 -165
  2. package/deps/couchbase-cxx-cache/mozilla-ca-bundle.sha256 +1 -1
  3. package/deps/couchbase-cxx-client/CMakeLists.txt +12 -1
  4. package/deps/couchbase-cxx-client/README.md +2 -2
  5. package/deps/couchbase-cxx-client/cmake/Profiler.cmake +15 -0
  6. package/deps/couchbase-cxx-client/core/app_telemetry_address.cxx +55 -0
  7. package/deps/couchbase-cxx-client/core/app_telemetry_address.hxx +39 -0
  8. package/deps/couchbase-cxx-client/core/app_telemetry_meter.cxx +753 -0
  9. package/deps/couchbase-cxx-client/core/app_telemetry_meter.hxx +198 -0
  10. package/deps/couchbase-cxx-client/core/app_telemetry_reporter.cxx +895 -0
  11. package/deps/couchbase-cxx-client/core/app_telemetry_reporter.hxx +59 -0
  12. package/deps/couchbase-cxx-client/core/bucket.cxx +77 -35
  13. package/deps/couchbase-cxx-client/core/bucket.hxx +17 -10
  14. package/deps/couchbase-cxx-client/core/cluster.cxx +54 -16
  15. package/deps/couchbase-cxx-client/core/cluster_credentials.cxx +27 -0
  16. package/deps/couchbase-cxx-client/core/cluster_credentials.hxx +36 -0
  17. package/deps/couchbase-cxx-client/core/cluster_options.hxx +12 -0
  18. package/deps/couchbase-cxx-client/core/collections_component.cxx +7 -5
  19. package/deps/couchbase-cxx-client/core/http_component.cxx +6 -0
  20. package/deps/couchbase-cxx-client/core/impl/bucket_manager.cxx +2 -0
  21. package/deps/couchbase-cxx-client/core/impl/cluster.cxx +9 -0
  22. package/deps/couchbase-cxx-client/core/impl/collection.cxx +2 -0
  23. package/deps/couchbase-cxx-client/core/impl/error.cxx +1 -0
  24. package/deps/couchbase-cxx-client/core/impl/logger.cxx +51 -0
  25. package/deps/couchbase-cxx-client/core/impl/replica_utils.cxx +1 -1
  26. package/deps/couchbase-cxx-client/core/impl/transaction_get_multi_replicas_from_preferred_server_group_spec.cxx +32 -0
  27. package/deps/couchbase-cxx-client/core/impl/transaction_get_multi_spec.cxx +30 -0
  28. package/deps/couchbase-cxx-client/core/impl/transaction_op_error_category.cxx +2 -0
  29. package/deps/couchbase-cxx-client/core/io/config_tracker.cxx +6 -6
  30. package/deps/couchbase-cxx-client/core/io/http_command.hxx +35 -11
  31. package/deps/couchbase-cxx-client/core/io/http_session.cxx +10 -0
  32. package/deps/couchbase-cxx-client/core/io/http_session.hxx +4 -0
  33. package/deps/couchbase-cxx-client/core/io/http_session_manager.hxx +83 -34
  34. package/deps/couchbase-cxx-client/core/io/mcbp_command.hxx +41 -2
  35. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +52 -19
  36. package/deps/couchbase-cxx-client/core/io/mcbp_session.hxx +3 -0
  37. package/deps/couchbase-cxx-client/core/logger/logger.cxx +46 -0
  38. package/deps/couchbase-cxx-client/core/logger/logger.hxx +41 -1
  39. package/deps/couchbase-cxx-client/core/management/bucket_settings.hxx +1 -0
  40. package/deps/couchbase-cxx-client/core/management/bucket_settings_json.hxx +4 -0
  41. package/deps/couchbase-cxx-client/core/meta/features.hxx +32 -0
  42. package/deps/couchbase-cxx-client/core/operations/document_analytics.cxx +9 -9
  43. package/deps/couchbase-cxx-client/core/operations/document_get_all_replicas.hxx +10 -2
  44. package/deps/couchbase-cxx-client/core/operations/document_lookup_in.cxx +4 -0
  45. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_all_replicas.hxx +14 -2
  46. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_any_replica.hxx +4 -0
  47. package/deps/couchbase-cxx-client/core/operations/document_mutate_in.cxx +4 -0
  48. package/deps/couchbase-cxx-client/core/operations/document_mutate_in.hxx +1 -0
  49. package/deps/couchbase-cxx-client/core/operations/document_query.cxx +12 -10
  50. package/deps/couchbase-cxx-client/core/operations/http_noop.cxx +1 -0
  51. package/deps/couchbase-cxx-client/core/operations/management/bucket_create.cxx +3 -0
  52. package/deps/couchbase-cxx-client/core/operations/management/bucket_update.cxx +3 -0
  53. package/deps/couchbase-cxx-client/core/origin.cxx +0 -5
  54. package/deps/couchbase-cxx-client/core/origin.hxx +2 -11
  55. package/deps/couchbase-cxx-client/core/platform/random.cc +6 -3
  56. package/deps/couchbase-cxx-client/core/platform/random.h +2 -2
  57. package/deps/couchbase-cxx-client/core/protocol/cmd_mutate_in.hxx +9 -0
  58. package/deps/couchbase-cxx-client/core/timeout_defaults.hxx +4 -0
  59. package/deps/couchbase-cxx-client/core/topology/configuration.cxx +10 -13
  60. package/deps/couchbase-cxx-client/core/topology/configuration.hxx +14 -15
  61. package/deps/couchbase-cxx-client/core/topology/configuration_json.hxx +6 -0
  62. package/deps/couchbase-cxx-client/core/transactions/async_attempt_context.hxx +22 -2
  63. package/deps/couchbase-cxx-client/core/transactions/attempt_context.hxx +25 -7
  64. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.cxx +688 -238
  65. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.hxx +91 -12
  66. package/deps/couchbase-cxx-client/core/transactions/exceptions.cxx +5 -0
  67. package/deps/couchbase-cxx-client/core/transactions/exceptions.hxx +20 -0
  68. package/deps/couchbase-cxx-client/core/transactions/exceptions_fmt.hxx +3 -0
  69. package/deps/couchbase-cxx-client/core/transactions/forward_compat.cxx +71 -6
  70. package/deps/couchbase-cxx-client/core/transactions/forward_compat.hxx +45 -59
  71. package/deps/couchbase-cxx-client/core/transactions/get_multi_orchestrator.cxx +616 -0
  72. package/deps/couchbase-cxx-client/core/transactions/get_multi_orchestrator.hxx +61 -0
  73. package/deps/couchbase-cxx-client/core/transactions/internal/doc_record.cxx +8 -0
  74. package/deps/couchbase-cxx-client/core/transactions/internal/doc_record.hxx +16 -5
  75. package/deps/couchbase-cxx-client/core/transactions/internal/exceptions_internal.hxx +12 -0
  76. package/deps/couchbase-cxx-client/core/transactions/internal/transaction_context.hxx +13 -0
  77. package/deps/couchbase-cxx-client/core/transactions/internal/transaction_fields.hxx +1 -0
  78. package/deps/couchbase-cxx-client/core/transactions/staged_mutation.cxx +277 -96
  79. package/deps/couchbase-cxx-client/core/transactions/staged_mutation.hxx +28 -76
  80. package/deps/couchbase-cxx-client/core/transactions/transaction_context.cxx +33 -0
  81. package/deps/couchbase-cxx-client/core/transactions/transaction_get_multi_mode.hxx +28 -0
  82. package/deps/couchbase-cxx-client/core/transactions/transaction_get_multi_replicas_from_preferred_server_group_mode.hxx +27 -0
  83. package/deps/couchbase-cxx-client/core/transactions/transaction_get_multi_replicas_from_preferred_server_group_result.hxx +71 -0
  84. package/deps/couchbase-cxx-client/core/transactions/transaction_get_multi_result.hxx +66 -0
  85. package/deps/couchbase-cxx-client/core/transactions/transaction_links.hxx +10 -0
  86. package/deps/couchbase-cxx-client/core/transactions/transactions.cxx +8 -3
  87. package/deps/couchbase-cxx-client/core/utils/connection_string.cxx +4 -0
  88. package/deps/couchbase-cxx-client/core/utils/url_codec.cxx +26 -0
  89. package/deps/couchbase-cxx-client/core/utils/url_codec.hxx +11 -0
  90. package/deps/couchbase-cxx-client/core/websocket_codec.cxx +647 -0
  91. package/deps/couchbase-cxx-client/core/websocket_codec.hxx +77 -0
  92. package/deps/couchbase-cxx-client/couchbase/analytics_options.hxx +70 -6
  93. package/deps/couchbase-cxx-client/couchbase/application_telemetry_options.hxx +124 -0
  94. package/deps/couchbase-cxx-client/couchbase/cluster_options.hxx +17 -0
  95. package/deps/couchbase-cxx-client/couchbase/error_codes.hxx +1 -0
  96. package/deps/couchbase-cxx-client/couchbase/logger.hxx +16 -0
  97. package/deps/couchbase-cxx-client/couchbase/management/bucket_settings.hxx +1 -0
  98. package/deps/couchbase-cxx-client/couchbase/query_options.hxx +70 -6
  99. package/deps/couchbase-cxx-client/couchbase/transactions/async_attempt_context.hxx +29 -5
  100. package/deps/couchbase-cxx-client/couchbase/transactions/attempt_context.hxx +24 -7
  101. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_get_multi_mode.hxx +47 -0
  102. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_get_multi_options.hxx +44 -0
  103. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_mode.hxx +46 -0
  104. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_options.hxx +48 -0
  105. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_result.hxx +109 -0
  106. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_spec.hxx +47 -0
  107. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_get_multi_result.hxx +102 -0
  108. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_get_multi_spec.hxx +45 -0
  109. package/dist/analyticsindexmanager.d.ts +1 -0
  110. package/dist/binarycollection.d.ts +1 -0
  111. package/dist/binding.d.ts +85 -38
  112. package/dist/binding.js +14 -7
  113. package/dist/bindingutilities.d.ts +16 -4
  114. package/dist/bindingutilities.js +248 -43
  115. package/dist/cluster.d.ts +39 -0
  116. package/dist/cluster.js +21 -3
  117. package/dist/collection.d.ts +20 -1
  118. package/dist/collection.js +13 -0
  119. package/dist/errorcontexts.d.ts +24 -0
  120. package/dist/errorcontexts.js +12 -6
  121. package/dist/generaltypes.d.ts +16 -0
  122. package/dist/generaltypes.js +18 -1
  123. package/dist/httpexecutor.d.ts +1 -2
  124. package/dist/httpexecutor.js +0 -9
  125. package/dist/streamablepromises.d.ts +25 -7
  126. package/dist/streamablepromises.js +32 -7
  127. package/dist/transactions.d.ts +239 -1
  128. package/dist/transactions.js +318 -1
  129. package/dist/transcoders.d.ts +1 -0
  130. package/dist/utilities.d.ts +1 -0
  131. package/package.json +24 -24
  132. package/src/connection.cpp +34 -4
  133. package/src/constants.cpp +124 -0
  134. package/src/jstocbpp_autogen.hpp +22 -8
  135. package/src/jstocbpp_transactions.hpp +83 -7
  136. package/src/transaction.cpp +101 -0
  137. package/src/transaction.hpp +5 -0
  138. package/tools/gen-bindings-js.js +2 -1
  139. package/tools/gen-bindings-json.py +28 -3
@@ -327,6 +327,7 @@ class Collection {
327
327
  this._conn.getAllReplicas({
328
328
  id: this._cppDocId(key),
329
329
  timeout: timeout,
330
+ read_preference: (0, bindingutilities_1.readPreferenceToCpp)(options.readPreference),
330
331
  }, (cppErr, resp) => {
331
332
  const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
332
333
  if (err) {
@@ -356,6 +357,7 @@ class Collection {
356
357
  this._conn.getAnyReplica({
357
358
  id: this._cppDocId(key),
358
359
  timeout: timeout,
360
+ read_preference: (0, bindingutilities_1.readPreferenceToCpp)(options.readPreference),
359
361
  }, (cppErr, resp) => {
360
362
  const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
361
363
  if (err) {
@@ -930,6 +932,9 @@ class Collection {
930
932
  if (!options) {
931
933
  options = {};
932
934
  }
935
+ if (specs.length === 0) {
936
+ throw new errors_1.InvalidArgumentError(new Error('At least one lookup spec must be provided.'));
937
+ }
933
938
  const cppSpecs = [];
934
939
  for (let i = 0; i < specs.length; ++i) {
935
940
  cppSpecs.push({
@@ -989,6 +994,9 @@ class Collection {
989
994
  if (!options) {
990
995
  options = {};
991
996
  }
997
+ if (specs.length === 0) {
998
+ throw new errors_1.InvalidArgumentError(new Error('At least one lookup spec must be provided.'));
999
+ }
992
1000
  const emitter = new streamablepromises_1.StreamableReplicasPromise((replicas) => replicas);
993
1001
  const cppSpecs = [];
994
1002
  for (let i = 0; i < specs.length; ++i) {
@@ -1005,6 +1013,7 @@ class Collection {
1005
1013
  id: this._cppDocId(key),
1006
1014
  specs: cppSpecs,
1007
1015
  timeout: timeout,
1016
+ read_preference: (0, bindingutilities_1.readPreferenceToCpp)(options.readPreference),
1008
1017
  }, (cppErr, resp) => {
1009
1018
  const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
1010
1019
  if (err) {
@@ -1044,6 +1053,7 @@ class Collection {
1044
1053
  id: this._cppDocId(key),
1045
1054
  specs: cppSpecs,
1046
1055
  timeout: timeout,
1056
+ read_preference: (0, bindingutilities_1.readPreferenceToCpp)(options.readPreference),
1047
1057
  }, (cppErr, resp) => {
1048
1058
  const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
1049
1059
  if (err) {
@@ -1128,6 +1138,9 @@ class Collection {
1128
1138
  if (!options) {
1129
1139
  options = {};
1130
1140
  }
1141
+ if (specs.length === 0) {
1142
+ throw new errors_1.InvalidArgumentError(new Error('At least one lookup spec must be provided.'));
1143
+ }
1131
1144
  const cppSpecs = [];
1132
1145
  for (let i = 0; i < specs.length; ++i) {
1133
1146
  cppSpecs.push({
@@ -1,10 +1,33 @@
1
1
  import { Cas } from './utilities';
2
+ /**
3
+ * Specific error context types.
4
+ *
5
+ * @category Error Handling
6
+ */
7
+ type ErrorContextTypes = KeyValueErrorContext | ViewErrorContext | QueryErrorContext | SearchErrorContext | AnalyticsErrorContext | HttpErrorContext;
2
8
  /**
3
9
  * Generic base class for all known error context types.
4
10
  *
5
11
  * @category Error Handling
6
12
  */
7
13
  export declare class ErrorContext {
14
+ /**
15
+ * The host and port that the request was last sent to.
16
+ */
17
+ last_dispatched_to: string;
18
+ /**
19
+ * The host and port that the request was last sent from.
20
+ */
21
+ last_dispatched_from: string;
22
+ /**
23
+ * The number of times the operation has been retried.
24
+ */
25
+ retry_attempts: number;
26
+ /**
27
+ * A list of the reasons for retrying the operation.
28
+ */
29
+ retry_reasons: string[];
30
+ constructor(data: ErrorContextTypes);
8
31
  }
9
32
  /**
10
33
  * The error context information for a key-value operation.
@@ -206,3 +229,4 @@ export declare class HttpErrorContext extends ErrorContext {
206
229
  */
207
230
  constructor(data: HttpErrorContext);
208
231
  }
232
+ export {};
@@ -7,6 +7,12 @@ exports.HttpErrorContext = exports.AnalyticsErrorContext = exports.SearchErrorCo
7
7
  * @category Error Handling
8
8
  */
9
9
  class ErrorContext {
10
+ constructor(data) {
11
+ this.last_dispatched_to = data.last_dispatched_to || '';
12
+ this.last_dispatched_from = data.last_dispatched_from || '';
13
+ this.retry_attempts = data.retry_attempts || 0;
14
+ this.retry_reasons = data.retry_reasons || [];
15
+ }
10
16
  }
11
17
  exports.ErrorContext = ErrorContext;
12
18
  /**
@@ -19,7 +25,7 @@ class KeyValueErrorContext extends ErrorContext {
19
25
  * @internal
20
26
  */
21
27
  constructor(data) {
22
- super();
28
+ super(data);
23
29
  this.status_code = data.status_code;
24
30
  this.opaque = data.opaque;
25
31
  this.cas = data.cas;
@@ -42,7 +48,7 @@ class ViewErrorContext extends ErrorContext {
42
48
  * @internal
43
49
  */
44
50
  constructor(data) {
45
- super();
51
+ super(data);
46
52
  this.design_document = data.design_document;
47
53
  this.view = data.view;
48
54
  this.parameters = data.parameters;
@@ -61,7 +67,7 @@ class QueryErrorContext extends ErrorContext {
61
67
  * @internal
62
68
  */
63
69
  constructor(data) {
64
- super();
70
+ super(data);
65
71
  this.statement = data.statement;
66
72
  this.client_context_id = data.client_context_id;
67
73
  this.parameters = data.parameters;
@@ -80,7 +86,7 @@ class SearchErrorContext extends ErrorContext {
80
86
  * @internal
81
87
  */
82
88
  constructor(data) {
83
- super();
89
+ super(data);
84
90
  this.index_name = data.index_name;
85
91
  this.query = data.query;
86
92
  this.parameters = data.parameters;
@@ -99,7 +105,7 @@ class AnalyticsErrorContext extends ErrorContext {
99
105
  * @internal
100
106
  */
101
107
  constructor(data) {
102
- super();
108
+ super(data);
103
109
  this.statement = data.statement;
104
110
  this.client_context_id = data.client_context_id;
105
111
  this.parameters = data.parameters;
@@ -118,7 +124,7 @@ class HttpErrorContext extends ErrorContext {
118
124
  * @internal
119
125
  */
120
126
  constructor(data) {
121
- super();
127
+ super(data);
122
128
  this.method = data.method;
123
129
  this.request_path = data.request_path;
124
130
  this.response_code = data.response_code;
@@ -78,3 +78,19 @@ export declare enum StoreSemantics {
78
78
  */
79
79
  Insert = 2
80
80
  }
81
+ /**
82
+ * Represents the various scan consistency options that are available when
83
+ * querying against the query service.
84
+ */
85
+ export declare enum ReadPreference {
86
+ /**
87
+ * Indicates that filtering for replica set should not be enforced.
88
+ */
89
+ NoPreference = "no_preference",
90
+ /**
91
+ * Indicates that any nodes that do not belong to local group selected during
92
+ * cluster instantiation using the `ConnectOptions.preferredServerGroup` option
93
+ * should be excluded.
94
+ */
95
+ SelectedServerGroup = "selected_server_group"
96
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StoreSemantics = exports.DurabilityLevel = exports.ServiceType = void 0;
3
+ exports.ReadPreference = exports.StoreSemantics = exports.DurabilityLevel = exports.ServiceType = void 0;
4
4
  /**
5
5
  * Represents the various service types available.
6
6
  */
@@ -84,3 +84,20 @@ var StoreSemantics;
84
84
  */
85
85
  StoreSemantics[StoreSemantics["Insert"] = 2] = "Insert";
86
86
  })(StoreSemantics || (exports.StoreSemantics = StoreSemantics = {}));
87
+ /**
88
+ * Represents the various scan consistency options that are available when
89
+ * querying against the query service.
90
+ */
91
+ var ReadPreference;
92
+ (function (ReadPreference) {
93
+ /**
94
+ * Indicates that filtering for replica set should not be enforced.
95
+ */
96
+ ReadPreference["NoPreference"] = "no_preference";
97
+ /**
98
+ * Indicates that any nodes that do not belong to local group selected during
99
+ * cluster instantiation using the `ConnectOptions.preferredServerGroup` option
100
+ * should be excluded.
101
+ */
102
+ ReadPreference["SelectedServerGroup"] = "selected_server_group";
103
+ })(ReadPreference || (exports.ReadPreference = ReadPreference = {}));
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
+ /// <reference types="node" />
3
4
  import { CppConnection } from './binding';
4
- import { HttpErrorContext } from './errorcontexts';
5
5
  import * as events from 'events';
6
6
  /**
7
7
  * @internal
@@ -59,5 +59,4 @@ export declare class HttpExecutor {
59
59
  */
60
60
  streamRequest(options: HttpRequestOptions): events.EventEmitter;
61
61
  request(options: HttpRequestOptions): Promise<HttpResponse>;
62
- static errorContextFromResponse(resp: HttpResponse): HttpErrorContext;
63
62
  }
@@ -30,7 +30,6 @@ exports.HttpExecutor = exports.HttpMethod = exports.HttpServiceType = void 0;
30
30
  /* eslint jsdoc/require-jsdoc: off */
31
31
  const binding_1 = __importDefault(require("./binding"));
32
32
  const bindingutilities_1 = require("./bindingutilities");
33
- const errorcontexts_1 = require("./errorcontexts");
34
33
  const events = __importStar(require("events"));
35
34
  /**
36
35
  * @internal
@@ -170,13 +169,5 @@ class HttpExecutor {
170
169
  });
171
170
  });
172
171
  }
173
- static errorContextFromResponse(resp) {
174
- return new errorcontexts_1.HttpErrorContext({
175
- method: resp.requestOptions.method,
176
- request_path: resp.requestOptions.path,
177
- response_code: resp.statusCode,
178
- response_body: resp.body.toString(),
179
- });
180
- }
181
172
  }
182
173
  exports.HttpExecutor = HttpExecutor;
@@ -3,42 +3,60 @@ import EventEmitter from 'events';
3
3
  /**
4
4
  * @internal
5
5
  */
6
- type PromisifyFunc<T> = (emitter: StreamablePromise<T>, resolve: (result: T) => void, reject: (err: Error) => void) => void;
6
+ type ListenerFunc = (...args: any[]) => void;
7
+ /**
8
+ * @internal
9
+ */
10
+ interface PromisifyEmitter {
11
+ on(eventName: string | symbol, listener: ListenerFunc): void;
12
+ }
13
+ /**
14
+ * @internal
15
+ */
16
+ type PromisifyFunc<T> = (emitter: PromisifyEmitter, resolve: (result: T) => void, reject: (err: Error) => void) => void;
7
17
  /**
8
18
  * @internal
9
19
  */
10
20
  export declare class StreamablePromise<T> extends EventEmitter implements Promise<T> {
11
21
  private _promise;
12
- private _promiseifyFn;
22
+ private _promiseOns;
13
23
  /**
14
24
  * @internal
15
25
  */
16
26
  constructor(promisefyFn: PromisifyFunc<T>);
17
27
  private get promise();
28
+ private _depromisify;
18
29
  then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
19
30
  catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
20
31
  finally(onfinally?: (() => void) | undefined | null): Promise<T>;
32
+ addListener(eventName: string | symbol, listener: ListenerFunc): this;
33
+ on(eventName: string | symbol, listener: ListenerFunc): this;
21
34
  /**
22
35
  * @internal
23
36
  */
24
37
  get [Symbol.toStringTag](): string;
25
38
  }
26
39
  /**
27
- * Provides the ability to be used as both a promise, or an event emitter. Enabling
28
- * an application to easily retrieve all results using async/await, while also enabling
40
+ * Provides the ability to be used as either a promise or an event emitter. Enabling
41
+ * an application to easily retrieve all results using async/await or enabling
29
42
  * streaming of results by listening for the row and meta events.
30
43
  */
31
44
  export declare class StreamableRowPromise<T, TRow, TMeta> extends StreamablePromise<T> {
32
45
  constructor(fn: (rows: TRow[], meta: TMeta) => T);
33
46
  }
34
47
  /**
35
- * Provides the ability to be used as both a promise, or an event emitter. Enabling
36
- * an application to easily retrieve all results using async/await, while also enabling
37
- * streaming of results by listening for the replica event.
48
+ * Provides the ability to be used as either a promise or an event emitter. Enabling
49
+ * an application to easily retrieve all replicas using async/await or enabling
50
+ * streaming of replicas by listening for the replica event.
38
51
  */
39
52
  export declare class StreamableReplicasPromise<T, TRep> extends StreamablePromise<T> {
40
53
  constructor(fn: (replicas: TRep[]) => T);
41
54
  }
55
+ /**
56
+ * Provides the ability to be used as either a promise or an event emitter. Enabling
57
+ * an application to easily retrieve all scan results using async/await or enabling
58
+ * streaming of scan results by listening for the result event.
59
+ */
42
60
  export declare class StreamableScanPromise<T, TRes> extends StreamablePromise<T> {
43
61
  private _cancelRequested;
44
62
  constructor(fn: (results: TRes[]) => T);
@@ -16,14 +16,26 @@ class StreamablePromise extends events_1.default {
16
16
  constructor(promisefyFn) {
17
17
  super();
18
18
  this._promise = null;
19
- this._promiseifyFn = promisefyFn;
19
+ this._promiseOns = [];
20
+ this._promise = new Promise((resolve, reject) => {
21
+ promisefyFn({
22
+ on: (eventName, listener) => {
23
+ this._promiseOns.push([eventName, listener]);
24
+ super.on(eventName, listener);
25
+ },
26
+ }, resolve, reject);
27
+ });
20
28
  }
21
29
  get promise() {
22
30
  if (!this._promise) {
23
- this._promise = new Promise((resolve, reject) => this._promiseifyFn(this, resolve, reject));
31
+ throw new Error('Cannot await a promise that is already registered for events');
24
32
  }
25
33
  return this._promise;
26
34
  }
35
+ _depromisify() {
36
+ this._promiseOns.forEach((e) => this.off(...e));
37
+ this._promise = null;
38
+ }
27
39
  then(onfulfilled, onrejected) {
28
40
  return this.promise.then(onfulfilled, onrejected);
29
41
  }
@@ -33,6 +45,14 @@ class StreamablePromise extends events_1.default {
33
45
  finally(onfinally) {
34
46
  return this.promise.finally(onfinally);
35
47
  }
48
+ addListener(eventName, listener) {
49
+ this._depromisify();
50
+ return super.on(eventName, listener);
51
+ }
52
+ on(eventName, listener) {
53
+ this._depromisify();
54
+ return super.on(eventName, listener);
55
+ }
36
56
  /**
37
57
  * @internal
38
58
  */
@@ -42,8 +62,8 @@ class StreamablePromise extends events_1.default {
42
62
  }
43
63
  exports.StreamablePromise = StreamablePromise;
44
64
  /**
45
- * Provides the ability to be used as both a promise, or an event emitter. Enabling
46
- * an application to easily retrieve all results using async/await, while also enabling
65
+ * Provides the ability to be used as either a promise or an event emitter. Enabling
66
+ * an application to easily retrieve all results using async/await or enabling
47
67
  * streaming of results by listening for the row and meta events.
48
68
  */
49
69
  class StreamableRowPromise extends StreamablePromise {
@@ -66,9 +86,9 @@ class StreamableRowPromise extends StreamablePromise {
66
86
  }
67
87
  exports.StreamableRowPromise = StreamableRowPromise;
68
88
  /**
69
- * Provides the ability to be used as both a promise, or an event emitter. Enabling
70
- * an application to easily retrieve all results using async/await, while also enabling
71
- * streaming of results by listening for the replica event.
89
+ * Provides the ability to be used as either a promise or an event emitter. Enabling
90
+ * an application to easily retrieve all replicas using async/await or enabling
91
+ * streaming of replicas by listening for the replica event.
72
92
  */
73
93
  class StreamableReplicasPromise extends StreamablePromise {
74
94
  constructor(fn) {
@@ -87,6 +107,11 @@ class StreamableReplicasPromise extends StreamablePromise {
87
107
  }
88
108
  }
89
109
  exports.StreamableReplicasPromise = StreamableReplicasPromise;
110
+ /**
111
+ * Provides the ability to be used as either a promise or an event emitter. Enabling
112
+ * an application to easily retrieve all scan results using async/await or enabling
113
+ * streaming of scan results by listening for the result event.
114
+ */
90
115
  class StreamableScanPromise extends StreamablePromise {
91
116
  constructor(fn) {
92
117
  super((emitter, resolve, reject) => {
@@ -1,4 +1,4 @@
1
- import { CppTransactions, CppTransaction, CppTransactionLinks, CppTransactionGetMetaData } from './binding';
1
+ import { CppDocumentId, CppTransactions, CppTransaction, CppTransactionLinks, CppTransactionGetMetaData } from './binding';
2
2
  import { Cluster } from './cluster';
3
3
  import { Collection } from './collection';
4
4
  import { DurabilityLevel } from './generaltypes';
@@ -49,6 +49,44 @@ export interface TransactionKeyspace {
49
49
  */
50
50
  collection?: string;
51
51
  }
52
+ /**
53
+ * Represents the mode of the Transactional GetMulti operation.
54
+ *
55
+ * @category Transactions
56
+ */
57
+ export declare enum TransactionGetMultiMode {
58
+ /**
59
+ * Indicates that the Transactional GetMulti op should prioritise latency.
60
+ */
61
+ PrioritiseLatency = "prioritise_latency",
62
+ /**
63
+ * Indicates that the Transactional GetMulti op should disable read skew detection.
64
+ */
65
+ DisableReadSkewDetection = "disable_read_skew_detection",
66
+ /**
67
+ * Indicates that the Transactional GetMulti op should prioritise read skew detection.
68
+ */
69
+ PrioritiseReadSkewDetection = "prioritise_read_skew_detection"
70
+ }
71
+ /**
72
+ * Represents the mode of the Transactional GetMultiReplicasFromPreferredServerGroup operation.
73
+ *
74
+ * @category Transactions
75
+ */
76
+ export declare enum TransactionGetMultiReplicasFromPreferredServerGroupMode {
77
+ /**
78
+ * Indicates that the Transactional GetMultiReplicasFromPreferredServerGroup op should prioritise latency.
79
+ */
80
+ PrioritiseLatency = "prioritise_latency",
81
+ /**
82
+ * Indicates that the Transactional GetMultiReplicasFromPreferredServerGroup op should disable read skew detection.
83
+ */
84
+ DisableReadSkewDetection = "disable_read_skew_detection",
85
+ /**
86
+ * Indicates that the Transactional GetMultiReplicasFromPreferredServerGroup op should prioritise read skew detection.
87
+ */
88
+ PrioritiseReadSkewDetection = "prioritise_read_skew_detection"
89
+ }
52
90
  /**
53
91
  * Specifies the configuration options for Transactions cleanup.
54
92
  *
@@ -127,6 +165,54 @@ export interface TransactionOptions {
127
165
  */
128
166
  timeout?: number;
129
167
  }
168
+ /**
169
+ * Represents the path to a document.
170
+ *
171
+ * @category Transactions
172
+ */
173
+ export declare class TransactionGetMultiSpec {
174
+ constructor(collection: Collection, id: string, transcoder?: Transcoder);
175
+ /**
176
+ * The Collection where the document belongs.
177
+ */
178
+ collection: Collection;
179
+ /**
180
+ * The id (or key) of the document.
181
+ */
182
+ id: string;
183
+ /**
184
+ * The Transcoder to encode/decode the document.
185
+ */
186
+ transcoder?: Transcoder;
187
+ /**
188
+ * @internal
189
+ */
190
+ _toCppDocumentId(): CppDocumentId;
191
+ }
192
+ /**
193
+ * Represents the path to a document.
194
+ *
195
+ * @category Transactions
196
+ */
197
+ export declare class TransactionGetMultiReplicasFromPreferredServerGroupSpec {
198
+ constructor(collection: Collection, id: string, transcoder?: Transcoder);
199
+ /**
200
+ * The Collection where the document belongs.
201
+ */
202
+ collection: Collection;
203
+ /**
204
+ * The id (or key) of the document.
205
+ */
206
+ id: string;
207
+ /**
208
+ * The Transcoder to encode/decode the document.
209
+ */
210
+ transcoder?: Transcoder;
211
+ /**
212
+ * @internal
213
+ */
214
+ _toCppDocumentId(): CppDocumentId;
215
+ }
130
216
  /**
131
217
  * Contains the results of a Transaction.
132
218
  *
@@ -181,6 +267,109 @@ export declare class TransactionGetResult {
181
267
  */
182
268
  _metadata: CppTransactionGetMetaData;
183
269
  }
270
+ /**
271
+ * Contains the results of a specific sub-operation within a transactional GetMulti operation.
272
+ *
273
+ * @category Transactions
274
+ */
275
+ export declare class TransactionGetMultiResultEntry {
276
+ /**
277
+ * The error, if any, which occured when attempting to perform this sub-operation.
278
+ */
279
+ error: Error | null;
280
+ /**
281
+ * The value returned by the sub-operation.
282
+ */
283
+ value?: any;
284
+ /**
285
+ * @internal
286
+ */
287
+ constructor(data: {
288
+ value?: any;
289
+ error?: Error;
290
+ });
291
+ }
292
+ /**
293
+ * Contains the results of a transactional GetMulti operation.
294
+ *
295
+ * @category Transactions
296
+ */
297
+ export declare class TransactionGetMultiResult {
298
+ /**
299
+ * @internal
300
+ */
301
+ constructor(data: {
302
+ content: TransactionGetMultiResultEntry[];
303
+ });
304
+ /**
305
+ * The content of the document.
306
+ */
307
+ content: TransactionGetMultiResultEntry[];
308
+ /**
309
+ * Indicates whether the document at the specified index exists.
310
+ *
311
+ * @param index The result index to check.
312
+ */
313
+ exists(index: number): boolean;
314
+ /**
315
+ * Provides the content at the specified index, if it exists.
316
+ *
317
+ * @param index The result index to check.
318
+ */
319
+ contentAt(index: number): any;
320
+ }
321
+ /**
322
+ * Contains the results of a specific sub-operation within
323
+ * a transactional GetMultiReplicasFromPreferredServerGroup operation.
324
+ *
325
+ * @category Transactions
326
+ */
327
+ export declare class TransactionGetMultiReplicasFromPreferredServerGroupResultEntry {
328
+ /**
329
+ * The error, if any, which occured when attempting to access the document.
330
+ */
331
+ error: Error | null;
332
+ /**
333
+ * The value of the document.
334
+ */
335
+ value?: any;
336
+ /**
337
+ * @internal
338
+ */
339
+ constructor(data: {
340
+ value?: any;
341
+ error?: Error;
342
+ });
343
+ }
344
+ /**
345
+ * Contains the results of a transactional GetMultiReplicasFromPreferredServerGroup operation.
346
+ *
347
+ * @category Transactions
348
+ */
349
+ export declare class TransactionGetMultiReplicasFromPreferredServerGroupResult {
350
+ /**
351
+ * @internal
352
+ */
353
+ constructor(data: {
354
+ content: TransactionGetMultiReplicasFromPreferredServerGroupResultEntry[];
355
+ });
356
+ /**
357
+ * The content of the document.
358
+ */
359
+ content: TransactionGetMultiReplicasFromPreferredServerGroupResultEntry[];
360
+ /**
361
+ * Indicates whether the document at the specified index exists.
362
+ *
363
+ * @param index The result index to check.
364
+ */
365
+ exists(index: number): boolean;
366
+ /**
367
+ * Provides the content at the specified index, if it exists.
368
+ *
369
+ * @param index The result index to check.
370
+ */
371
+ contentAt(index: number): any;
372
+ }
184
373
  /**
185
374
  * Contains the results of a transactional Query operation.
186
375
  *
@@ -286,6 +475,33 @@ export interface TransactionGetOptions {
286
475
  */
287
476
  transcoder?: Transcoder;
288
477
  }
478
+ /**
479
+ * @category Transactions
480
+ */
481
+ export interface TransactionGetReplicaFromPreferredServerGroupOptions {
482
+ /**
483
+ * Specifies an explicit transcoder to use for this specific operation.
484
+ */
485
+ transcoder?: Transcoder;
486
+ }
487
+ /**
488
+ * @category Transactions
489
+ */
490
+ export interface TransactionGetMultiOptions {
491
+ /**
492
+ * Specifies a mode to use for this specific operation.
493
+ */
494
+ mode?: TransactionGetMultiMode;
495
+ }
496
+ /**
497
+ * @category Transactions
498
+ */
499
+ export interface TransactionGetMultiReplicasFromPreferredServerGroupOptions {
500
+ /**
501
+ * Specifies a mode to use for this specific operation.
502
+ */
503
+ mode?: TransactionGetMultiReplicasFromPreferredServerGroupMode;
504
+ }
289
505
  /**
290
506
  * @category Transactions
291
507
  */
@@ -332,6 +548,28 @@ export declare class TransactionAttemptContext {
332
548
  * @param options Optional parameters for this operation.
333
549
  */
334
550
  get(collection: Collection, key: string, options?: TransactionGetOptions): Promise<TransactionGetResult>;
551
+ /**
552
+ * Retrieves the value of a document from the collection.
553
+ *
554
+ * @param collection The collection the document lives in.
555
+ * @param key The document key to retrieve.
556
+ * @param options Optional parameters for this operation.
557
+ */
558
+ getReplicaFromPreferredServerGroup(collection: Collection, key: string, options?: TransactionGetReplicaFromPreferredServerGroupOptions): Promise<TransactionGetResult>;
559
+ /**
560
+ * Retrieves the documents specified in the list of specs.
561
+ *
562
+ * @param specs The documents to retrieve.
563
+ * @param options Optional parameters for this operation.
564
+ */
565
+ getMultiReplicasFromPreferredServerGroup(specs: TransactionGetMultiReplicasFromPreferredServerGroupSpec[], options?: TransactionGetMultiReplicasFromPreferredServerGroupOptions): Promise<TransactionGetMultiReplicasFromPreferredServerGroupResult>;
566
+ /**
567
+ * Retrieves the documents specified in the list of specs.
568
+ *
569
+ * @param specs The documents to retrieve.
570
+ * @param options Optional parameters for this operation.
571
+ */
572
+ getMulti(specs: TransactionGetMultiSpec[], options?: TransactionGetMultiOptions): Promise<TransactionGetMultiResult>;
335
573
  /**
336
574
  * Inserts a new document to the collection, failing if the document already exists.
337
575
  *