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
@@ -0,0 +1,47 @@
1
+ /*
2
+ * Copyright 2021-Present Couchbase, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ #pragma once
17
+
18
+ #include <cstdint>
19
+
20
+ namespace couchbase::transactions
21
+ {
22
+ /**
23
+ * Strategy to deal with potential read skews while reading multiple documents.
24
+ *
25
+ * Essentially when a transaction reads document X and then Y, and another
26
+ * transaction commits a change to Y inbetween those reads - read skew has
27
+ * occurred.
28
+ */
29
+ enum class transaction_get_multi_mode : std::uint8_t {
30
+ /**
31
+ * Some time-bounded effort will be made to detect and avoid read skew.
32
+ */
33
+ prioritise_latency,
34
+
35
+ /**
36
+ * No read skew detection should be attempted. Once the documents are fetched, they will be
37
+ * returned immediately.
38
+ */
39
+ disable_read_skew_detection,
40
+
41
+ /**
42
+ * Great effort will be made to detect and avoid read skew.
43
+ */
44
+ prioritise_read_skew_detection,
45
+ };
46
+
47
+ } // namespace couchbase::transactions
@@ -0,0 +1,44 @@
1
+ /*
2
+ * Copyright 2021-Present Couchbase, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ #pragma once
17
+
18
+ #include <couchbase/transactions/transaction_get_multi_mode.hxx>
19
+
20
+ namespace couchbase
21
+ {
22
+ namespace core::transactions
23
+ {
24
+ class attempt_context_impl;
25
+ } // namespace core::transactions
26
+
27
+ namespace transactions
28
+ {
29
+ class transaction_get_multi_options
30
+ {
31
+ public:
32
+ auto mode(transaction_get_multi_mode mode) -> transaction_get_multi_options&
33
+ {
34
+ mode_ = mode;
35
+ return *this;
36
+ }
37
+
38
+ private:
39
+ friend class core::transactions::attempt_context_impl;
40
+
41
+ transaction_get_multi_mode mode_{ transaction_get_multi_mode::prioritise_latency };
42
+ };
43
+ } // namespace transactions
44
+ } // namespace couchbase
@@ -0,0 +1,46 @@
1
+ /*
2
+ * Copyright 2021-Present Couchbase, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ #pragma once
17
+
18
+ #include <cstdint>
19
+
20
+ namespace couchbase::transactions
21
+ {
22
+ /**
23
+ * Strategy to deal with potential read skews while reading multiple documents.
24
+ *
25
+ * Essentially when a transaction reads document X and then Y, and another
26
+ * transaction commits a change to Y inbetween those reads - read skew has
27
+ * occurred.
28
+ */
29
+ enum class transaction_get_multi_replicas_from_preferred_server_group_mode : std::uint8_t {
30
+ /**
31
+ * Some time-bounded effort will be made to detect and avoid read skew.
32
+ */
33
+ prioritise_latency,
34
+
35
+ /**
36
+ * No read skew detection should be attempted. Once the documents are fetched, they will be
37
+ * returned immediately.
38
+ */
39
+ disable_read_skew_detection,
40
+
41
+ /**
42
+ * Great effort will be made to detect and avoid read skew.
43
+ */
44
+ prioritise_read_skew_detection,
45
+ };
46
+ } // namespace couchbase::transactions
@@ -0,0 +1,48 @@
1
+ /*
2
+ * Copyright 2021-Present Couchbase, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ #pragma once
17
+
18
+ #include <couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_mode.hxx>
19
+
20
+ namespace couchbase
21
+ {
22
+ namespace core::transactions
23
+ {
24
+ class attempt_context_impl;
25
+ } // namespace core::transactions
26
+
27
+ namespace transactions
28
+ {
29
+ class transaction_get_multi_replicas_from_preferred_server_group_options
30
+ {
31
+ public:
32
+ auto mode(transaction_get_multi_replicas_from_preferred_server_group_mode mode)
33
+ -> transaction_get_multi_replicas_from_preferred_server_group_options&
34
+ {
35
+ mode_ = mode;
36
+ return *this;
37
+ }
38
+
39
+ private:
40
+ friend class core::transactions::attempt_context_impl;
41
+
42
+ transaction_get_multi_replicas_from_preferred_server_group_mode mode_{
43
+ transaction_get_multi_replicas_from_preferred_server_group_mode::prioritise_latency
44
+ };
45
+ };
46
+
47
+ } // namespace transactions
48
+ } // namespace couchbase
@@ -0,0 +1,109 @@
1
+ /*
2
+ * Copyright 2021-Present Couchbase, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ #pragma once
17
+
18
+ #include "couchbase/error_codes.hxx"
19
+ #include <couchbase/codec/default_json_transcoder.hxx>
20
+
21
+ #include <optional>
22
+ #include <stdexcept>
23
+ #include <system_error>
24
+ #include <vector>
25
+
26
+ namespace couchbase
27
+ {
28
+ namespace core::transactions
29
+ {
30
+ class attempt_context_impl;
31
+ } // namespace core::transactions
32
+
33
+ namespace transactions
34
+ {
35
+ class transaction_get_multi_replicas_from_preferred_server_group_result
36
+ {
37
+ public:
38
+ transaction_get_multi_replicas_from_preferred_server_group_result(
39
+ const transaction_get_multi_replicas_from_preferred_server_group_result&) = default;
40
+ ~transaction_get_multi_replicas_from_preferred_server_group_result() = default;
41
+ transaction_get_multi_replicas_from_preferred_server_group_result(
42
+ transaction_get_multi_replicas_from_preferred_server_group_result&&) = default;
43
+ auto operator=(const transaction_get_multi_replicas_from_preferred_server_group_result&)
44
+ -> transaction_get_multi_replicas_from_preferred_server_group_result& = default;
45
+ auto operator=(transaction_get_multi_replicas_from_preferred_server_group_result&&)
46
+ -> transaction_get_multi_replicas_from_preferred_server_group_result& = default;
47
+
48
+ /**
49
+ * Content of the document.
50
+ *
51
+ * @return content of the document.
52
+ */
53
+ template<typename Document,
54
+ typename Transcoder = codec::default_json_transcoder,
55
+ std::enable_if_t<!codec::is_transcoder_v<Document>, bool> = true,
56
+ std::enable_if_t<codec::is_transcoder_v<Transcoder>, bool> = true>
57
+ [[nodiscard]] auto content_as(std::size_t spec_index) const -> Document
58
+ {
59
+ if (spec_index >= content_.size()) {
60
+ throw std::invalid_argument("spec index " + std::to_string(spec_index) + " is not valid");
61
+ }
62
+ if (const auto& content = content_[spec_index]; content.has_value()) {
63
+ return Transcoder::template decode<Document>(content.value());
64
+ }
65
+ throw std::system_error(errc::key_value::document_not_found,
66
+ "document was not found for index " + std::to_string(spec_index));
67
+ }
68
+
69
+ /**
70
+ * Content of the document.
71
+ *
72
+ * @return content of the document.
73
+ */
74
+ template<typename Transcoder, std::enable_if_t<codec::is_transcoder_v<Transcoder>, bool> = true>
75
+ [[nodiscard]] auto content_as(std::size_t spec_index) const -> typename Transcoder::document_type
76
+ {
77
+ if (spec_index >= content_.size()) {
78
+ throw std::invalid_argument("spec index " + std::to_string(spec_index) + " is not valid");
79
+ }
80
+ if (const auto& content = content_[spec_index]; content.has_value()) {
81
+ return Transcoder::decode(content.value());
82
+ }
83
+ throw std::system_error(errc::key_value::document_not_found,
84
+ "document was not found for index " + std::to_string(spec_index));
85
+ }
86
+
87
+ /**
88
+ * Check if spec returned any content
89
+ *
90
+ * @return the id of this document.
91
+ */
92
+ [[nodiscard]] auto exists(std::size_t spec_index) const -> bool
93
+ {
94
+ return spec_index >= content_.size() && content_[spec_index].has_value();
95
+ }
96
+
97
+ private:
98
+ friend core::transactions::attempt_context_impl;
99
+
100
+ explicit transaction_get_multi_replicas_from_preferred_server_group_result(
101
+ std::vector<std::optional<codec::encoded_value>> content)
102
+ : content_{ std::move(content) }
103
+ {
104
+ }
105
+
106
+ std::vector<std::optional<codec::encoded_value>> content_;
107
+ };
108
+ } // namespace transactions
109
+ } // namespace couchbase
@@ -0,0 +1,47 @@
1
+ /*
2
+ * Copyright 2021-Present Couchbase, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ #pragma once
17
+
18
+ #include <string>
19
+
20
+ namespace couchbase
21
+ {
22
+ class collection;
23
+ namespace core::transactions
24
+ {
25
+ class attempt_context_impl;
26
+ } // namespace core::transactions
27
+
28
+ namespace transactions
29
+ {
30
+ class transaction_get_multi_replicas_from_preferred_server_group_spec
31
+ {
32
+ public:
33
+ transaction_get_multi_replicas_from_preferred_server_group_spec(
34
+ const couchbase::collection& collection,
35
+ std::string id);
36
+
37
+ private:
38
+ friend class core::transactions::attempt_context_impl;
39
+
40
+ std::string bucket_;
41
+ std::string scope_;
42
+ std::string collection_;
43
+ std::string id_;
44
+ };
45
+
46
+ } // namespace transactions
47
+ } // namespace couchbase
@@ -0,0 +1,102 @@
1
+ /*
2
+ * Copyright 2021-Present Couchbase, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ #pragma once
17
+
18
+ #include <couchbase/codec/default_json_transcoder.hxx>
19
+
20
+ #include <optional>
21
+ #include <vector>
22
+
23
+ namespace couchbase
24
+ {
25
+ namespace core::transactions
26
+ {
27
+ class attempt_context_impl;
28
+ } // namespace core::transactions
29
+
30
+ namespace transactions
31
+ {
32
+ class transaction_get_multi_result
33
+ {
34
+ public:
35
+ transaction_get_multi_result() = default;
36
+ ~transaction_get_multi_result() = default;
37
+ transaction_get_multi_result(const transaction_get_multi_result&) = default;
38
+ transaction_get_multi_result(transaction_get_multi_result&&) = default;
39
+ auto operator=(const transaction_get_multi_result&) -> transaction_get_multi_result& = default;
40
+ auto operator=(transaction_get_multi_result&&) -> transaction_get_multi_result& = default;
41
+
42
+ /**
43
+ * Content of the document.
44
+ *
45
+ * @return content of the document.
46
+ */
47
+ template<typename Document,
48
+ typename Transcoder = codec::default_json_transcoder,
49
+ std::enable_if_t<!codec::is_transcoder_v<Document>, bool> = true,
50
+ std::enable_if_t<codec::is_transcoder_v<Transcoder>, bool> = true>
51
+ [[nodiscard]] auto content_as(std::size_t spec_index) const -> Document
52
+ {
53
+ if (spec_index >= content_.size()) {
54
+ throw std::invalid_argument("spec index " + std::to_string(spec_index) + " is not valid");
55
+ }
56
+ if (const auto& content = content_[spec_index]; content.has_value()) {
57
+ return Transcoder::template decode<Document>(content.value());
58
+ }
59
+ throw std::system_error(errc::key_value::document_not_found,
60
+ "document was not found for index " + std::to_string(spec_index));
61
+ }
62
+
63
+ /**
64
+ * Content of the document.
65
+ *
66
+ * @return content of the document.
67
+ */
68
+ template<typename Transcoder, std::enable_if_t<codec::is_transcoder_v<Transcoder>, bool> = true>
69
+ [[nodiscard]] auto content_as(std::size_t spec_index) const -> typename Transcoder::document_type
70
+ {
71
+ if (spec_index >= content_.size()) {
72
+ throw std::invalid_argument("spec index " + std::to_string(spec_index) + " is not valid");
73
+ }
74
+ if (const auto& content = content_[spec_index]; content.has_value()) {
75
+ return Transcoder::decode(content_[spec_index]);
76
+ }
77
+ throw std::system_error(errc::key_value::document_not_found,
78
+ "document was not found for index " + std::to_string(spec_index));
79
+ }
80
+
81
+ /**
82
+ * Check if spec returned any content
83
+ *
84
+ * @return the id of this document.
85
+ */
86
+ [[nodiscard]] auto exists(std::size_t spec_index) const -> bool
87
+ {
88
+ return spec_index >= content_.size() && content_[spec_index].has_value();
89
+ }
90
+
91
+ private:
92
+ friend core::transactions::attempt_context_impl;
93
+
94
+ explicit transaction_get_multi_result(std::vector<std::optional<codec::encoded_value>> content)
95
+ : content_{ std::move(content) }
96
+ {
97
+ }
98
+
99
+ std::vector<std::optional<codec::encoded_value>> content_;
100
+ };
101
+ } // namespace transactions
102
+ } // namespace couchbase
@@ -0,0 +1,45 @@
1
+ /*
2
+ * Copyright 2021-Present Couchbase, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ #pragma once
17
+
18
+ #include <string>
19
+
20
+ namespace couchbase
21
+ {
22
+ class collection;
23
+ namespace core::transactions
24
+ {
25
+ class attempt_context_impl;
26
+ } // namespace core::transactions
27
+
28
+ namespace transactions
29
+ {
30
+ class transaction_get_multi_spec
31
+ {
32
+ public:
33
+ transaction_get_multi_spec(const couchbase::collection& collection, std::string id);
34
+
35
+ private:
36
+ friend class core::transactions::attempt_context_impl;
37
+
38
+ std::string bucket_;
39
+ std::string scope_;
40
+ std::string collection_;
41
+ std::string id_;
42
+ };
43
+
44
+ } // namespace transactions
45
+ } // namespace couchbase
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { Cluster } from './cluster';
3
4
  import { CppManagementAnalyticsCouchbaseRemoteLink, CppManagementAnalyticsS3ExternalLink, CppManagementAnalyticsAzureBlobExternalLink } from './binding';
4
5
  import { NodeCallback } from './utilities';
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { Collection } from './collection';
3
4
  import { CounterResult, MutationResult } from './crudoptypes';
4
5
  import { DurabilityLevel } from './generaltypes';