couchbase 4.7.0 → 4.7.2

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 (84) hide show
  1. package/CMakeLists.txt +3 -0
  2. package/deps/couchbase-cxx-cache/mozilla-ca-bundle.crt +96 -727
  3. package/deps/couchbase-cxx-cache/mozilla-ca-bundle.sha256 +1 -1
  4. package/deps/couchbase-cxx-client/CMakeLists.txt +3 -1
  5. package/deps/couchbase-cxx-client/README.md +2 -2
  6. package/deps/couchbase-cxx-client/core/error_context/base_error_context.hxx +32 -0
  7. package/deps/couchbase-cxx-client/core/error_context/key_value.cxx +1 -0
  8. package/deps/couchbase-cxx-client/core/error_context/key_value.hxx +23 -0
  9. package/deps/couchbase-cxx-client/core/error_context/key_value_error_context.hxx +35 -0
  10. package/deps/couchbase-cxx-client/core/error_context/subdocument_error_context.hxx +41 -0
  11. package/deps/couchbase-cxx-client/core/impl/binary_collection.cxx +123 -88
  12. package/deps/couchbase-cxx-client/core/impl/collection.cxx +416 -189
  13. package/deps/couchbase-cxx-client/core/impl/error.cxx +29 -4
  14. package/deps/couchbase-cxx-client/core/impl/invoke_with_node_id.hxx +44 -0
  15. package/deps/couchbase-cxx-client/core/impl/node_id.cxx +110 -0
  16. package/deps/couchbase-cxx-client/core/impl/node_id.hxx +40 -0
  17. package/deps/couchbase-cxx-client/core/io/configuration_belongs_to_session.hxx +67 -0
  18. package/deps/couchbase-cxx-client/core/io/http_session_manager.hxx +97 -57
  19. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +7 -16
  20. package/deps/couchbase-cxx-client/core/operations/document_get_all_replicas.hxx +14 -4
  21. package/deps/couchbase-cxx-client/core/operations/document_get_projected.cxx +3 -4
  22. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_all_replicas.hxx +4 -0
  23. package/deps/couchbase-cxx-client/core/operations/document_query.cxx +12 -12
  24. package/deps/couchbase-cxx-client/core/operations/management/collection_create.cxx +11 -11
  25. package/deps/couchbase-cxx-client/core/operations/management/collection_drop.cxx +11 -11
  26. package/deps/couchbase-cxx-client/core/operations/management/collection_update.cxx +11 -11
  27. package/deps/couchbase-cxx-client/core/operations/management/error_utils.cxx +9 -6
  28. package/deps/couchbase-cxx-client/core/operations/management/query_index_create.cxx +5 -4
  29. package/deps/couchbase-cxx-client/core/operations/management/query_index_drop.cxx +7 -6
  30. package/deps/couchbase-cxx-client/core/operations/management/scope_create.cxx +12 -13
  31. package/deps/couchbase-cxx-client/core/operations/management/scope_drop.cxx +8 -9
  32. package/deps/couchbase-cxx-client/core/topology/configuration.cxx +21 -0
  33. package/deps/couchbase-cxx-client/core/topology/configuration.hxx +28 -0
  34. package/deps/couchbase-cxx-client/core/utils/contains_string.cxx +61 -0
  35. package/deps/couchbase-cxx-client/core/utils/contains_string.hxx +26 -0
  36. package/deps/couchbase-cxx-client/couchbase/collection.hxx +73 -0
  37. package/deps/couchbase-cxx-client/couchbase/error.hxx +16 -0
  38. package/deps/couchbase-cxx-client/couchbase/node_id.hxx +123 -0
  39. package/deps/couchbase-cxx-client/couchbase/node_id_for_options.hxx +61 -0
  40. package/deps/couchbase-cxx-client/couchbase/node_ids_options.hxx +62 -0
  41. package/deps/couchbase-cxx-client/couchbase/result.hxx +42 -0
  42. package/dist/analyticsexecutor.d.ts +4 -0
  43. package/dist/analyticsexecutor.js +26 -11
  44. package/dist/analyticsindexmanager.js +2 -2
  45. package/dist/binding.d.ts +12 -2
  46. package/dist/bindingutilities.js +8 -5
  47. package/dist/bucket.d.ts +9 -1
  48. package/dist/bucket.js +21 -0
  49. package/dist/cluster.d.ts +10 -1
  50. package/dist/cluster.js +25 -3
  51. package/dist/collection.d.ts +3 -3
  52. package/dist/collection.js +189 -143
  53. package/dist/diagnosticsexecutor.js +2 -2
  54. package/dist/diagnosticstypes.d.ts +36 -0
  55. package/dist/diagnosticstypes.js +22 -1
  56. package/dist/mutationstate.js +1 -1
  57. package/dist/observability.d.ts +5 -1
  58. package/dist/observability.js +11 -3
  59. package/dist/observabilityhandler.d.ts +19 -0
  60. package/dist/observabilityhandler.js +81 -14
  61. package/dist/observabilitytypes.js +19 -42
  62. package/dist/observabilityutilities.js +1 -1
  63. package/dist/oteltracer.d.ts +5 -0
  64. package/dist/oteltracer.js +7 -0
  65. package/dist/queryexecutor.d.ts +9 -0
  66. package/dist/queryexecutor.js +18 -0
  67. package/dist/queryindexmanager.js +15 -0
  68. package/dist/searchexecutor.d.ts +4 -0
  69. package/dist/searchexecutor.js +30 -15
  70. package/dist/thresholdlogging.d.ts +5 -0
  71. package/dist/thresholdlogging.js +7 -0
  72. package/dist/tracing.d.ts +6 -0
  73. package/dist/transactions.js +29 -6
  74. package/dist/version.d.ts +1 -1
  75. package/dist/version.js +1 -1
  76. package/dist/viewexecutor.d.ts +4 -0
  77. package/dist/viewexecutor.js +30 -15
  78. package/dist/waituntilreadyexecutor.d.ts +37 -0
  79. package/dist/waituntilreadyexecutor.js +156 -0
  80. package/package.json +8 -8
  81. package/scripts/prebuilds.js +13 -0
  82. package/src/binding.cpp +1 -1
  83. package/src/connection.hpp +24 -3
  84. package/src/jstocbpp_errors.hpp +6 -0
@@ -35,6 +35,8 @@
35
35
  #include <couchbase/lookup_in_specs.hxx>
36
36
  #include <couchbase/mutate_in_options.hxx>
37
37
  #include <couchbase/mutate_in_specs.hxx>
38
+ #include <couchbase/node_id_for_options.hxx>
39
+ #include <couchbase/node_ids_options.hxx>
38
40
  #include <couchbase/query_options.hxx>
39
41
  #include <couchbase/remove_options.hxx>
40
42
  #include <couchbase/replace_options.hxx>
@@ -1090,6 +1092,77 @@ public:
1090
1092
  [[nodiscard]] auto scan(const scan_type& scan_type, const scan_options& options = {}) const
1091
1093
  -> std::future<std::pair<error, scan_result>>;
1092
1094
 
1095
+ /**
1096
+ * Resolves a document key to the identity of the cluster node that currently
1097
+ * owns it, using the client-side vBucket map (no network round-trip).
1098
+ *
1099
+ * @param document_id the document id to resolve
1100
+ * @param options options to customize the request
1101
+ * @param handler the handler that receives the result
1102
+ *
1103
+ * @since 1.3.2
1104
+ * @uncommitted
1105
+ */
1106
+ void node_id_for(std::string document_id,
1107
+ const node_id_for_options& options,
1108
+ node_id_for_handler&& handler) const;
1109
+
1110
+ /**
1111
+ * Resolves a document key to the identity of the cluster node that currently
1112
+ * owns it, using the client-side vBucket map (no network round-trip).
1113
+ *
1114
+ * @param document_id the document id to resolve
1115
+ * @param options options to customize the request
1116
+ * @return future carrying the error (if any) and node_id
1117
+ *
1118
+ * @since 1.3.2
1119
+ * @uncommitted
1120
+ */
1121
+ [[nodiscard]] auto node_id_for(std::string document_id,
1122
+ const node_id_for_options& options = {}) const
1123
+ -> std::future<std::pair<error, node_id>>;
1124
+
1125
+ /**
1126
+ * Returns the set of cluster nodes that currently serve key-value
1127
+ * traffic for this collection's bucket, drawn from the client-side
1128
+ * topology snapshot (no network round-trip).
1129
+ *
1130
+ * Each entry corresponds to one cluster node and is the same node_id
1131
+ * the SDK reports on KV results and errors that touched that node, so
1132
+ * the returned set is directly comparable to the keys of any
1133
+ * application-side state that is keyed by node_id (e.g. a per-node
1134
+ * circuit breaker registry). A periodic sweep that diffs the
1135
+ * registry's keys against this set is the canonical way to retire
1136
+ * tracker state for a node that has been removed from the cluster
1137
+ * topology.
1138
+ *
1139
+ * Nodes that do not expose a key-value port for the configured
1140
+ * transport (TLS or plain) are excluded from the returned set, since
1141
+ * they do not serve KV operations and therefore have no meaningful
1142
+ * identity from the SDK's point of view.
1143
+ *
1144
+ * @param options options to customize the request
1145
+ * @param handler the handler that receives the result
1146
+ *
1147
+ * @since 1.3.2
1148
+ * @uncommitted
1149
+ */
1150
+ void node_ids(const node_ids_options& options, node_ids_handler&& handler) const;
1151
+
1152
+ /**
1153
+ * Returns the set of cluster nodes that currently serve key-value
1154
+ * traffic for this collection's bucket, drawn from the client-side
1155
+ * topology snapshot (no network round-trip).
1156
+ *
1157
+ * @param options options to customize the request
1158
+ * @return future carrying the error (if any) and the set of node_ids
1159
+ *
1160
+ * @since 1.3.2
1161
+ * @uncommitted
1162
+ */
1163
+ [[nodiscard]] auto node_ids(const node_ids_options& options = {}) const
1164
+ -> std::future<std::pair<error, std::vector<node_id>>>;
1165
+
1093
1166
  [[nodiscard]] auto query_indexes() const -> collection_query_index_manager;
1094
1167
 
1095
1168
  private:
@@ -18,6 +18,7 @@
18
18
  #pragma once
19
19
 
20
20
  #include <couchbase/error_context.hxx>
21
+ #include <couchbase/node_id.hxx>
21
22
 
22
23
  #include <memory>
23
24
  #include <optional>
@@ -32,12 +33,26 @@ public:
32
33
  error() = default;
33
34
  error(std::error_code ec, std::string message = {}, error_context ctx = {});
34
35
  error(std::error_code ec, std::string message, error_context ctx, error cause);
36
+ error(std::error_code ec, std::string message, error_context ctx, couchbase::node_id node_id);
35
37
 
36
38
  [[nodiscard]] auto ec() const -> std::error_code;
37
39
  [[nodiscard]] auto message() const -> const std::string&;
38
40
  [[nodiscard]] auto ctx() const -> const error_context&;
39
41
  [[nodiscard]] auto cause() const -> std::optional<error>;
40
42
 
43
+ /**
44
+ * Returns the identity of the cluster node where the error occurred.
45
+ *
46
+ * The returned node_id is default-constructed (falsy) when the node
47
+ * could not be determined (e.g. for non-KV errors).
48
+ *
49
+ * @return identity of the node that returned the error
50
+ *
51
+ * @since 1.3.2
52
+ * @uncommitted
53
+ */
54
+ [[nodiscard]] auto node_id() const -> const couchbase::node_id&;
55
+
41
56
  explicit operator bool() const;
42
57
  auto operator==(const error& other) const -> bool;
43
58
 
@@ -46,6 +61,7 @@ private:
46
61
  std::string message_{};
47
62
  error_context ctx_{};
48
63
  std::shared_ptr<error> cause_{};
64
+ couchbase::node_id node_id_{};
49
65
  };
50
66
 
51
67
  } // namespace couchbase
@@ -0,0 +1,123 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2024-Present Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #pragma once
19
+
20
+ #include <cstdint>
21
+ #include <functional>
22
+ #include <string>
23
+
24
+ namespace couchbase
25
+ {
26
+
27
+ /**
28
+ * Uniquely identifies a cluster node.
29
+ *
30
+ * On Couchbase Server 8.0.1+ the identifier is the server-assigned node UUID.
31
+ * On older releases, a stable opaque token is derived from the node's hostname
32
+ * and management port.
33
+ *
34
+ * The type is equality-comparable, ordered, and hashable.
35
+ *
36
+ * @since 1.3.2
37
+ * @uncommitted
38
+ */
39
+ class node_id
40
+ {
41
+ public:
42
+ /**
43
+ * Creates an empty (invalid) node_id.
44
+ *
45
+ * @since 1.3.2
46
+ * @uncommitted
47
+ */
48
+ node_id() = default;
49
+
50
+ /**
51
+ * User-facing identifier string.
52
+ *
53
+ * Returns node_uuid when the server provides one, otherwise a stable
54
+ * hex-encoded hash derived from hostname and management port.
55
+ *
56
+ * @return opaque identifier string (empty for default-constructed instances)
57
+ *
58
+ * @since 1.3.2
59
+ * @uncommitted
60
+ */
61
+ [[nodiscard]] auto id() const -> const std::string&;
62
+
63
+ /**
64
+ * The server-assigned node UUID (empty on servers before 8.0.1).
65
+ *
66
+ * @since 1.3.2
67
+ * @uncommitted
68
+ */
69
+ [[nodiscard]] auto node_uuid() const -> const std::string&;
70
+
71
+ /**
72
+ * The hostname of the node.
73
+ *
74
+ * @since 1.3.2
75
+ * @uncommitted
76
+ */
77
+ [[nodiscard]] auto hostname() const -> const std::string&;
78
+
79
+ /**
80
+ * The port of the node's key-value service.
81
+ *
82
+ * This reflects the port actually used by the client: the TLS port when the
83
+ * cluster connection is TLS-enabled, otherwise the plain port.
84
+ *
85
+ * @since 1.3.2
86
+ * @uncommitted
87
+ */
88
+ [[nodiscard]] auto port() const -> std::uint16_t;
89
+
90
+ /**
91
+ * Returns true when the node_id was properly initialized (not default-constructed).
92
+ *
93
+ * @since 1.3.2
94
+ * @uncommitted
95
+ */
96
+ explicit operator bool() const;
97
+
98
+ auto operator==(const node_id& other) const -> bool;
99
+ auto operator!=(const node_id& other) const -> bool;
100
+ auto operator<(const node_id& other) const -> bool;
101
+
102
+ private:
103
+ friend class internal_node_id;
104
+
105
+ node_id(std::string node_uuid, std::string hostname, std::uint16_t port);
106
+
107
+ std::string node_uuid_{};
108
+ std::string hostname_{};
109
+ std::uint16_t port_{ 0 };
110
+ // Computed once at construction: node_uuid_ if non-empty, otherwise a
111
+ // deterministic hex-encoded CRC32 hash of "hostname:port".
112
+ std::string id_{};
113
+ };
114
+
115
+ } // namespace couchbase
116
+
117
+ template<>
118
+ struct std::hash<couchbase::node_id> {
119
+ auto operator()(const couchbase::node_id& nid) const noexcept -> std::size_t
120
+ {
121
+ return std::hash<std::string>{}(nid.id());
122
+ }
123
+ };
@@ -0,0 +1,61 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2024-Present Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #pragma once
19
+
20
+ #include <couchbase/common_options.hxx>
21
+ #include <couchbase/error.hxx>
22
+ #include <couchbase/node_id.hxx>
23
+
24
+ #include <functional>
25
+
26
+ namespace couchbase
27
+ {
28
+
29
+ /**
30
+ * Options for @ref collection#node_id_for().
31
+ *
32
+ * @since 1.3.2
33
+ * @uncommitted
34
+ */
35
+ struct node_id_for_options : public common_options<node_id_for_options> {
36
+ /**
37
+ * Immutable value object representing consistent options.
38
+ *
39
+ * @since 1.3.2
40
+ * @internal
41
+ */
42
+ struct built : public common_options<node_id_for_options>::built {
43
+ };
44
+
45
+ /**
46
+ * Validates options and returns them as an immutable value.
47
+ *
48
+ * @return consistent options as an immutable value
49
+ *
50
+ * @since 1.3.2
51
+ * @internal
52
+ */
53
+ [[nodiscard]] auto build() const -> built
54
+ {
55
+ return { build_common_options() };
56
+ }
57
+ };
58
+
59
+ using node_id_for_handler = std::function<void(error, node_id)>;
60
+
61
+ } // namespace couchbase
@@ -0,0 +1,62 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2024-Present Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #pragma once
19
+
20
+ #include <couchbase/common_options.hxx>
21
+ #include <couchbase/error.hxx>
22
+ #include <couchbase/node_id.hxx>
23
+
24
+ #include <functional>
25
+ #include <vector>
26
+
27
+ namespace couchbase
28
+ {
29
+
30
+ /**
31
+ * Options for @ref collection#node_ids().
32
+ *
33
+ * @since 1.3.2
34
+ * @uncommitted
35
+ */
36
+ struct node_ids_options : public common_options<node_ids_options> {
37
+ /**
38
+ * Immutable value object representing consistent options.
39
+ *
40
+ * @since 1.3.2
41
+ * @internal
42
+ */
43
+ struct built : public common_options<node_ids_options>::built {
44
+ };
45
+
46
+ /**
47
+ * Validates options and returns them as an immutable value.
48
+ *
49
+ * @return consistent options as an immutable value
50
+ *
51
+ * @since 1.3.2
52
+ * @internal
53
+ */
54
+ [[nodiscard]] auto build() const -> built
55
+ {
56
+ return { build_common_options() };
57
+ }
58
+ };
59
+
60
+ using node_ids_handler = std::function<void(error, std::vector<node_id>)>;
61
+
62
+ } // namespace couchbase
@@ -18,6 +18,9 @@
18
18
  #pragma once
19
19
 
20
20
  #include <couchbase/cas.hxx>
21
+ #include <couchbase/node_id.hxx>
22
+
23
+ #include <utility>
21
24
 
22
25
  namespace couchbase
23
26
  {
@@ -48,6 +51,19 @@ public:
48
51
  {
49
52
  }
50
53
 
54
+ /**
55
+ * @param cas
56
+ * @param node_id identity of the node that served the request
57
+ *
58
+ * @since 1.3.2
59
+ * @uncommitted
60
+ */
61
+ result(couchbase::cas cas, couchbase::node_id node_id)
62
+ : cas_(cas)
63
+ , node_id_(std::move(node_id))
64
+ {
65
+ }
66
+
51
67
  /**
52
68
  * @return
53
69
  *
@@ -59,8 +75,34 @@ public:
59
75
  return cas_;
60
76
  }
61
77
 
78
+ /**
79
+ * Returns the identity of the cluster node that served this request.
80
+ *
81
+ * The returned node_id is default-constructed (falsy) when the node
82
+ * could not be determined.
83
+ *
84
+ * @return identity of the serving node
85
+ *
86
+ * @since 1.3.2
87
+ * @uncommitted
88
+ */
89
+ [[nodiscard]] auto node_id() const -> const couchbase::node_id&
90
+ {
91
+ return node_id_;
92
+ }
93
+
94
+ /**
95
+ * @since 1.3.2
96
+ * @internal
97
+ */
98
+ void node_id(couchbase::node_id id)
99
+ {
100
+ node_id_ = std::move(id);
101
+ }
102
+
62
103
  private:
63
104
  couchbase::cas cas_{ 0U };
105
+ couchbase::node_id node_id_{};
64
106
  };
65
107
 
66
108
  } // namespace couchbase
@@ -17,6 +17,10 @@ export declare class AnalyticsExecutor {
17
17
  * @internal
18
18
  */
19
19
  get observabilityInstruments(): ObservabilityInstruments;
20
+ /**
21
+ * @internal
22
+ */
23
+ static _endWithError<TRow>(emitter: StreamableRowPromise<AnalyticsResult<TRow>, TRow, AnalyticsMetaData>, err: Error, obsReqHandler?: ObservableRequestHandler): void;
20
24
  /**
21
25
  * @internal
22
26
  */
@@ -7,8 +7,8 @@ const bindingutilities_1 = require("./bindingutilities");
7
7
  const observability_1 = require("./observability");
8
8
  const observabilityhandler_1 = require("./observabilityhandler");
9
9
  const observabilitytypes_1 = require("./observabilitytypes");
10
+ const queryexecutor_1 = require("./queryexecutor");
10
11
  const streamablepromises_1 = require("./streamablepromises");
11
- const utilities_1 = require("./utilities");
12
12
  /**
13
13
  * @internal
14
14
  */
@@ -25,20 +25,26 @@ class AnalyticsExecutor {
25
25
  get observabilityInstruments() {
26
26
  return this._cluster.observabilityInstruments;
27
27
  }
28
+ /**
29
+ * @internal
30
+ */
31
+ static _endWithError(emitter, err, obsReqHandler) {
32
+ obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(err);
33
+ emitter.emit('error', err);
34
+ emitter.emit('end');
35
+ }
28
36
  /**
29
37
  * @internal
30
38
  */
31
39
  static _processAnalyticsResponse(emitter, err, resp, obsReqHandler) {
32
40
  if (err) {
33
- obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.endWithError(err);
34
- emitter.emit('error', err);
35
- emitter.emit('end');
41
+ AnalyticsExecutor._endWithError(emitter, err, obsReqHandler);
36
42
  return;
37
43
  }
38
- resp.rows.forEach((row) => {
39
- emitter.emit('row', JSON.parse(row));
40
- });
41
- {
44
+ try {
45
+ resp.rows.forEach((row) => {
46
+ emitter.emit('row', JSON.parse(row));
47
+ });
42
48
  const metaData = resp.meta;
43
49
  let warnings;
44
50
  if (metaData.warnings) {
@@ -72,6 +78,10 @@ class AnalyticsExecutor {
72
78
  });
73
79
  emitter.emit('meta', meta);
74
80
  }
81
+ catch (err) {
82
+ AnalyticsExecutor._endWithError(emitter, err, obsReqHandler);
83
+ return;
84
+ }
75
85
  obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.end();
76
86
  emitter.emit('end');
77
87
  }
@@ -85,9 +95,14 @@ class AnalyticsExecutor {
85
95
  meta: meta,
86
96
  });
87
97
  });
88
- utilities_1.PromiseHelper.wrapAsync(async () => {
89
- const [err, resp] = await queryPromise;
90
- AnalyticsExecutor._processAnalyticsResponse(emitter, err, resp, obsReqHandler);
98
+ queryPromise.then(([err, resp]) => {
99
+ queryexecutor_1.QueryExecutor._rethrowListenerErrors(() => {
100
+ AnalyticsExecutor._processAnalyticsResponse(emitter, err, resp, obsReqHandler);
101
+ });
102
+ }, (err) => {
103
+ queryexecutor_1.QueryExecutor._rethrowListenerErrors(() => {
104
+ AnalyticsExecutor._endWithError(emitter, err, obsReqHandler);
105
+ });
91
106
  });
92
107
  return emitter;
93
108
  }
@@ -759,7 +759,7 @@ class AnalyticsIndexManager {
759
759
  */
760
760
  async _connectLink(options, callback) {
761
761
  if (options instanceof Function) {
762
- callback = arguments[1];
762
+ callback = arguments[0];
763
763
  options = undefined;
764
764
  }
765
765
  if (!options) {
@@ -836,7 +836,7 @@ class AnalyticsIndexManager {
836
836
  */
837
837
  async _disconnectLink(options, callback) {
838
838
  if (options instanceof Function) {
839
- callback = arguments[1];
839
+ callback = arguments[0];
840
840
  options = undefined;
841
841
  }
842
842
  if (!options) {
package/dist/binding.d.ts CHANGED
@@ -2712,7 +2712,10 @@ export interface CppEnhancedErrorInfo {
2712
2712
  }
2713
2713
  export interface CppKeyValueError extends CppErrorBase {
2714
2714
  ctxtype: 'key_value';
2715
- id: CppDocumentId;
2715
+ id: string;
2716
+ bucket: string;
2717
+ scope: string;
2718
+ collection: string;
2716
2719
  opaque: number;
2717
2720
  cas: CppCas;
2718
2721
  status_code: CppKeyValueStatusCode;
@@ -2722,6 +2725,12 @@ export interface CppKeyValueError extends CppErrorBase {
2722
2725
  retry_attempts: number;
2723
2726
  retry_reasons: CppRetryReason[];
2724
2727
  }
2728
+ export interface CppSubdocError extends Omit<CppKeyValueError, 'ctxtype'> {
2729
+ ctxtype: 'subdocument';
2730
+ first_error_path: string;
2731
+ first_error_index: number;
2732
+ deleted: boolean;
2733
+ }
2725
2734
  export interface CppViewError extends CppErrorBase {
2726
2735
  ctxtype: 'view';
2727
2736
  client_context_id: string;
@@ -2825,7 +2834,7 @@ export interface CppTransactionOpErrorContext {
2825
2834
  code: CppErrc;
2826
2835
  cause: CppKeyValueError | CppQueryError | undefined;
2827
2836
  }
2828
- export type CppError = CppGenericError | CppKeyValueError | CppViewError | CppQueryError | CppSearchError | CppAnalyticsError | CppHttpError | CppTxnOperationFailed | CppTxnOpException | CppTxnError;
2837
+ export type CppError = CppGenericError | CppKeyValueError | CppSubdocError | CppViewError | CppQueryError | CppSearchError | CppAnalyticsError | CppHttpError | CppTxnOperationFailed | CppTxnOpException | CppTxnError;
2829
2838
  export interface CppConnection extends CppConnectionAutogen {
2830
2839
  connect(connStr: string, credentials: CppClusterCredentials, dnsOptions: CppDnsConfig | null, appTelemetryOptions: CppAppTelemetryConfig | null, enableTracing: boolean, orphanReporterOptions: CppOrphanReporterConfig | null, callback: (err: CppError | null) => void): void;
2831
2840
  updateCredentials(credentials: CppClusterCredentials): CppError | null;
@@ -2854,6 +2863,7 @@ export interface CppConnection extends CppConnectionAutogen {
2854
2863
  report_id?: string;
2855
2864
  bucket_name?: string;
2856
2865
  services?: CppServiceType[];
2866
+ timeout?: number;
2857
2867
  }, callback: (err: CppError | null, result: {
2858
2868
  version: number;
2859
2869
  id: string;
@@ -573,6 +573,7 @@ exports.pingStateFromCpp = pingStateFromCpp;
573
573
  * @internal
574
574
  */
575
575
  function contextFromCpp(err) {
576
+ var _a, _b, _c, _d;
576
577
  if (!err) {
577
578
  return null;
578
579
  }
@@ -581,15 +582,17 @@ function contextFromCpp(err) {
581
582
  retry_reasons = err.retry_reasons.map(retryReasonFromCpp);
582
583
  }
583
584
  let context = null;
584
- if (err.ctxtype === 'key_value') {
585
+ // A subdocument error context is a key-value error context in the core, and
586
+ // adds only fields this context type does not carry, so both map here.
587
+ if (err.ctxtype === 'key_value' || err.ctxtype === 'subdocument') {
585
588
  context = new errctxs.KeyValueErrorContext({
586
589
  status_code: err.status_code,
587
590
  opaque: err.opaque,
588
591
  cas: err.cas,
589
- key: err.id ? err.id.key : '',
590
- bucket: err.id ? err.id.bucket : '',
591
- collection: err.id ? err.id.collection : '',
592
- scope: err.id ? err.id.scope : '',
592
+ key: (_a = err.id) !== null && _a !== void 0 ? _a : '',
593
+ bucket: (_b = err.bucket) !== null && _b !== void 0 ? _b : '',
594
+ collection: (_c = err.collection) !== null && _c !== void 0 ? _c : '',
595
+ scope: (_d = err.scope) !== null && _d !== void 0 ? _d : '',
593
596
  context: err.enhanced_error_info ? err.enhanced_error_info.context : '',
594
597
  ref: err.enhanced_error_info ? err.enhanced_error_info.reference : '',
595
598
  last_dispatched_from: err.last_dispatched_from
package/dist/bucket.d.ts CHANGED
@@ -2,7 +2,7 @@ import { CppConnection } from './binding';
2
2
  import { Cluster } from './cluster';
3
3
  import { Collection } from './collection';
4
4
  import { CollectionManager } from './collectionmanager';
5
- import { PingOptions, PingResult } from './diagnosticstypes';
5
+ import { PingOptions, PingResult, WaitUntilReadyOptions } from './diagnosticstypes';
6
6
  import { Scope } from './scope';
7
7
  import { StreamableRowPromise } from './streamablepromises';
8
8
  import { Transcoder } from './transcoders';
@@ -96,4 +96,12 @@ export declare class Bucket {
96
96
  * @param callback A node-style callback to be invoked after execution.
97
97
  */
98
98
  ping(options?: PingOptions, callback?: NodeCallback<PingResult>): Promise<PingResult>;
99
+ /**
100
+ * Waits until the bucket reaches the desired state or the timeout elapses.
101
+ *
102
+ * @param timeout The time in milliseconds to wait for the bucket to become ready.
103
+ * @param options Optional parameters.
104
+ * @param callback A callback to be invoked after execution.
105
+ */
106
+ waitUntilReady(timeout: number, options?: WaitUntilReadyOptions, callback?: NodeCallback<void>): Promise<void>;
99
107
  }
package/dist/bucket.js CHANGED
@@ -4,6 +4,7 @@ exports.Bucket = void 0;
4
4
  const collection_1 = require("./collection");
5
5
  const collectionmanager_1 = require("./collectionmanager");
6
6
  const diagnosticsexecutor_1 = require("./diagnosticsexecutor");
7
+ const waituntilreadyexecutor_1 = require("./waituntilreadyexecutor");
7
8
  const scope_1 = require("./scope");
8
9
  const utilities_1 = require("./utilities");
9
10
  const viewexecutor_1 = require("./viewexecutor");
@@ -142,5 +143,25 @@ class Bucket {
142
143
  bucket: this.name,
143
144
  }), callback);
144
145
  }
146
+ /**
147
+ * Waits until the bucket reaches the desired state or the timeout elapses.
148
+ *
149
+ * @param timeout The time in milliseconds to wait for the bucket to become ready.
150
+ * @param options Optional parameters.
151
+ * @param callback A callback to be invoked after execution.
152
+ */
153
+ waitUntilReady(timeout, options, callback) {
154
+ if (options instanceof Function) {
155
+ callback = arguments[1];
156
+ options = undefined;
157
+ }
158
+ if (!options) {
159
+ options = {};
160
+ }
161
+ const exec = new waituntilreadyexecutor_1.WaitUntilReadyExecutor(this._cluster, this.name);
162
+ const timeout_ = timeout;
163
+ const options_ = options;
164
+ return utilities_1.PromiseHelper.wrapAsync(() => exec.waitUntilReady(timeout_, options_), callback);
165
+ }
145
166
  }
146
167
  exports.Bucket = Bucket;