couchbase 4.2.3 → 4.2.5-dev.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. package/CMakeLists.txt +136 -11
  2. package/deps/couchbase-cxx-client/CMakeLists.txt +54 -4
  3. package/deps/couchbase-cxx-client/README.md +1 -0
  4. package/deps/couchbase-cxx-client/bin/create-search-index +164 -0
  5. package/deps/couchbase-cxx-client/bin/init-cluster +55 -10
  6. package/deps/couchbase-cxx-client/bin/run-unit-tests +62 -6
  7. package/deps/couchbase-cxx-client/bin/travel-sample-index-v6.json +184 -0
  8. package/deps/couchbase-cxx-client/bin/travel-sample-index.json +188 -0
  9. package/deps/couchbase-cxx-client/cmake/Documentation.cmake +0 -1
  10. package/deps/couchbase-cxx-client/cmake/OpenSSL.cmake +98 -3
  11. package/deps/couchbase-cxx-client/cmake/Testing.cmake +8 -0
  12. package/deps/couchbase-cxx-client/cmake/build_config.hxx.in +3 -0
  13. package/deps/couchbase-cxx-client/core/bucket.cxx +183 -152
  14. package/deps/couchbase-cxx-client/core/bucket.hxx +17 -4
  15. package/deps/couchbase-cxx-client/core/cluster.hxx +18 -1
  16. package/deps/couchbase-cxx-client/core/cluster_options.hxx +1 -0
  17. package/deps/couchbase-cxx-client/core/error_context/key_value.cxx +2 -1
  18. package/deps/couchbase-cxx-client/core/error_context/key_value.hxx +10 -12
  19. package/deps/couchbase-cxx-client/core/error_context/search.hxx +1 -1
  20. package/deps/couchbase-cxx-client/core/impl/analytics.cxx +1 -0
  21. package/deps/couchbase-cxx-client/core/impl/boolean_field_query.cxx +40 -0
  22. package/deps/couchbase-cxx-client/core/impl/boolean_query.cxx +62 -0
  23. package/deps/couchbase-cxx-client/core/impl/cluster.cxx +1 -0
  24. package/deps/couchbase-cxx-client/core/impl/conjunction_query.cxx +51 -0
  25. package/deps/couchbase-cxx-client/core/impl/date_range.cxx +89 -0
  26. package/deps/couchbase-cxx-client/core/impl/date_range_facet.cxx +54 -0
  27. package/deps/couchbase-cxx-client/core/impl/date_range_facet_result.cxx +64 -0
  28. package/deps/couchbase-cxx-client/core/impl/date_range_query.cxx +125 -0
  29. package/deps/couchbase-cxx-client/core/impl/disjunction_query.cxx +51 -0
  30. package/deps/couchbase-cxx-client/core/impl/encoded_search_facet.hxx +29 -0
  31. package/deps/couchbase-cxx-client/core/impl/encoded_search_query.hxx +29 -0
  32. package/deps/couchbase-cxx-client/core/impl/encoded_search_sort.hxx +29 -0
  33. package/deps/couchbase-cxx-client/core/impl/geo_bounding_box_query.cxx +46 -0
  34. package/deps/couchbase-cxx-client/core/impl/geo_distance_query.cxx +43 -0
  35. package/deps/couchbase-cxx-client/core/impl/geo_polygon_query.cxx +46 -0
  36. package/deps/couchbase-cxx-client/core/impl/internal_date_range_facet_result.cxx +80 -0
  37. package/deps/couchbase-cxx-client/core/impl/internal_date_range_facet_result.hxx +48 -0
  38. package/deps/couchbase-cxx-client/core/impl/internal_numeric_range_facet_result.cxx +80 -0
  39. package/deps/couchbase-cxx-client/core/impl/internal_numeric_range_facet_result.hxx +48 -0
  40. package/deps/couchbase-cxx-client/core/impl/internal_search_error_context.cxx +141 -0
  41. package/deps/couchbase-cxx-client/core/impl/internal_search_error_context.hxx +61 -0
  42. package/deps/couchbase-cxx-client/core/impl/internal_search_meta_data.cxx +60 -0
  43. package/deps/couchbase-cxx-client/core/impl/internal_search_meta_data.hxx +41 -0
  44. package/deps/couchbase-cxx-client/core/impl/internal_search_result.cxx +84 -0
  45. package/deps/couchbase-cxx-client/core/impl/internal_search_result.hxx +43 -0
  46. package/deps/couchbase-cxx-client/core/impl/internal_search_row.cxx +82 -0
  47. package/deps/couchbase-cxx-client/core/impl/internal_search_row.hxx +56 -0
  48. package/deps/couchbase-cxx-client/core/impl/internal_search_row_location.hxx +32 -0
  49. package/deps/couchbase-cxx-client/core/impl/internal_search_row_locations.cxx +137 -0
  50. package/deps/couchbase-cxx-client/core/impl/internal_search_row_locations.hxx +45 -0
  51. package/deps/couchbase-cxx-client/core/impl/internal_term_facet_result.cxx +80 -0
  52. package/deps/couchbase-cxx-client/core/impl/internal_term_facet_result.hxx +48 -0
  53. package/deps/couchbase-cxx-client/core/impl/key_value_error_context.cxx +98 -0
  54. package/deps/couchbase-cxx-client/core/impl/match_all_query.cxx +35 -0
  55. package/deps/couchbase-cxx-client/core/impl/match_none_query.cxx +35 -0
  56. package/deps/couchbase-cxx-client/core/impl/match_phrase_query.cxx +43 -0
  57. package/deps/couchbase-cxx-client/core/impl/match_query.cxx +59 -0
  58. package/deps/couchbase-cxx-client/core/impl/numeric_range.cxx +49 -0
  59. package/deps/couchbase-cxx-client/core/impl/numeric_range_facet.cxx +54 -0
  60. package/deps/couchbase-cxx-client/core/impl/numeric_range_facet_result.cxx +64 -0
  61. package/deps/couchbase-cxx-client/core/impl/numeric_range_query.cxx +56 -0
  62. package/deps/couchbase-cxx-client/core/impl/phrase_query.cxx +42 -0
  63. package/deps/couchbase-cxx-client/core/impl/prefix_query.cxx +40 -0
  64. package/deps/couchbase-cxx-client/core/impl/query_error_context.cxx +75 -0
  65. package/deps/couchbase-cxx-client/core/impl/query_string_query.cxx +37 -0
  66. package/deps/couchbase-cxx-client/core/impl/regexp_query.cxx +40 -0
  67. package/deps/couchbase-cxx-client/core/impl/search.cxx +191 -0
  68. package/deps/couchbase-cxx-client/core/impl/search_error_context.cxx +147 -0
  69. package/deps/couchbase-cxx-client/core/impl/search_meta_data.cxx +46 -0
  70. package/deps/couchbase-cxx-client/core/impl/search_result.cxx +66 -0
  71. package/deps/couchbase-cxx-client/core/impl/search_row.cxx +74 -0
  72. package/deps/couchbase-cxx-client/core/impl/search_row_location.cxx +64 -0
  73. package/deps/couchbase-cxx-client/core/impl/search_row_locations.cxx +66 -0
  74. package/deps/couchbase-cxx-client/core/impl/search_sort_field.cxx +104 -0
  75. package/deps/couchbase-cxx-client/core/impl/search_sort_id.cxx +43 -0
  76. package/deps/couchbase-cxx-client/core/impl/search_sort_score.cxx +43 -0
  77. package/deps/couchbase-cxx-client/core/impl/term_facet.cxx +36 -0
  78. package/deps/couchbase-cxx-client/core/impl/term_facet_result.cxx +64 -0
  79. package/deps/couchbase-cxx-client/core/impl/term_query.cxx +56 -0
  80. package/deps/couchbase-cxx-client/core/impl/term_range_query.cxx +57 -0
  81. package/deps/couchbase-cxx-client/core/impl/wildcard_query.cxx +40 -0
  82. package/deps/couchbase-cxx-client/core/io/mcbp_command.hxx +9 -2
  83. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +54 -37
  84. package/deps/couchbase-cxx-client/core/io/mcbp_session.hxx +4 -3
  85. package/deps/couchbase-cxx-client/core/json_string.hxx +5 -0
  86. package/deps/couchbase-cxx-client/core/meta/version.cxx +18 -4
  87. package/deps/couchbase-cxx-client/core/mozilla_ca_bundle.hxx +39 -0
  88. package/deps/couchbase-cxx-client/core/operations/document_search.cxx +3 -1
  89. package/deps/couchbase-cxx-client/core/operations/document_search.hxx +1 -1
  90. package/deps/couchbase-cxx-client/core/protocol/client_request.hxx +11 -2
  91. package/deps/couchbase-cxx-client/core/protocol/client_response.hxx +1 -0
  92. package/deps/couchbase-cxx-client/core/utils/connection_string.cxx +59 -46
  93. package/deps/couchbase-cxx-client/core/utils/connection_string.hxx +1 -0
  94. package/deps/couchbase-cxx-client/couchbase/analytics_error_context.hxx +1 -1
  95. package/deps/couchbase-cxx-client/couchbase/boolean_field_query.hxx +77 -0
  96. package/deps/couchbase-cxx-client/couchbase/boolean_query.hxx +223 -0
  97. package/deps/couchbase-cxx-client/couchbase/cluster.hxx +39 -0
  98. package/deps/couchbase-cxx-client/couchbase/conjunction_query.hxx +88 -0
  99. package/deps/couchbase-cxx-client/couchbase/date_range.hxx +69 -0
  100. package/deps/couchbase-cxx-client/couchbase/date_range_facet.hxx +56 -0
  101. package/deps/couchbase-cxx-client/couchbase/date_range_facet_result.hxx +55 -0
  102. package/deps/couchbase-cxx-client/couchbase/date_range_query.hxx +265 -0
  103. package/deps/couchbase-cxx-client/couchbase/disjunction_query.hxx +109 -0
  104. package/deps/couchbase-cxx-client/couchbase/doc_id_query.hxx +111 -0
  105. package/deps/couchbase-cxx-client/couchbase/error_context.hxx +17 -8
  106. package/deps/couchbase-cxx-client/couchbase/fmt/analytics_scan_consistency.hxx +52 -0
  107. package/deps/couchbase-cxx-client/{core/topology/error_map_fmt.hxx → couchbase/fmt/key_value_error_map_attribute.hxx} +21 -21
  108. package/deps/couchbase-cxx-client/couchbase/fmt/search_scan_consistency.hxx +49 -0
  109. package/deps/couchbase-cxx-client/couchbase/geo_bounding_box_query.hxx +107 -0
  110. package/deps/couchbase-cxx-client/couchbase/geo_distance_query.hxx +109 -0
  111. package/deps/couchbase-cxx-client/couchbase/geo_point.hxx +32 -0
  112. package/deps/couchbase-cxx-client/couchbase/geo_polygon_query.hxx +85 -0
  113. package/deps/couchbase-cxx-client/couchbase/highlight_style.hxx +45 -0
  114. package/deps/couchbase-cxx-client/couchbase/key_value_error_context.hxx +7 -2
  115. package/deps/couchbase-cxx-client/couchbase/manager_error_context.hxx +1 -1
  116. package/deps/couchbase-cxx-client/couchbase/match_all_query.hxx +43 -0
  117. package/deps/couchbase-cxx-client/couchbase/match_none_query.hxx +43 -0
  118. package/deps/couchbase-cxx-client/couchbase/match_operator.hxx +45 -0
  119. package/deps/couchbase-cxx-client/couchbase/match_phrase_query.hxx +108 -0
  120. package/deps/couchbase-cxx-client/couchbase/match_query.hxx +163 -0
  121. package/deps/couchbase-cxx-client/couchbase/numeric_range.hxx +58 -0
  122. package/deps/couchbase-cxx-client/couchbase/numeric_range_facet.hxx +56 -0
  123. package/deps/couchbase-cxx-client/couchbase/numeric_range_facet_result.hxx +55 -0
  124. package/deps/couchbase-cxx-client/couchbase/numeric_range_query.hxx +143 -0
  125. package/deps/couchbase-cxx-client/couchbase/phrase_query.hxx +93 -0
  126. package/deps/couchbase-cxx-client/couchbase/prefix_query.hxx +82 -0
  127. package/deps/couchbase-cxx-client/couchbase/query_error_context.hxx +3 -1
  128. package/deps/couchbase-cxx-client/couchbase/query_string_query.hxx +72 -0
  129. package/deps/couchbase-cxx-client/couchbase/regexp_query.hxx +82 -0
  130. package/deps/couchbase-cxx-client/couchbase/scope.hxx +39 -0
  131. package/deps/couchbase-cxx-client/couchbase/search_date_range.hxx +68 -0
  132. package/deps/couchbase-cxx-client/couchbase/search_error_context.hxx +138 -0
  133. package/deps/couchbase-cxx-client/couchbase/search_facet.hxx +60 -0
  134. package/deps/couchbase-cxx-client/couchbase/search_facet_result.hxx +50 -0
  135. package/deps/couchbase-cxx-client/couchbase/search_meta_data.hxx +85 -0
  136. package/deps/couchbase-cxx-client/couchbase/search_metrics.hxx +127 -0
  137. package/deps/couchbase-cxx-client/couchbase/search_numeric_range.hxx +69 -0
  138. package/deps/couchbase-cxx-client/couchbase/search_options.hxx +509 -0
  139. package/deps/couchbase-cxx-client/couchbase/search_query.hxx +69 -0
  140. package/deps/couchbase-cxx-client/couchbase/search_result.hxx +77 -0
  141. package/deps/couchbase-cxx-client/couchbase/search_row.hxx +104 -0
  142. package/deps/couchbase-cxx-client/couchbase/search_row_location.hxx +55 -0
  143. package/deps/couchbase-cxx-client/couchbase/search_row_locations.hxx +86 -0
  144. package/deps/couchbase-cxx-client/couchbase/search_scan_consistency.hxx +34 -0
  145. package/deps/couchbase-cxx-client/couchbase/search_sort.hxx +58 -0
  146. package/deps/couchbase-cxx-client/couchbase/search_sort_field.hxx +117 -0
  147. package/deps/couchbase-cxx-client/couchbase/search_sort_field_missing.hxx +26 -0
  148. package/deps/couchbase-cxx-client/couchbase/search_sort_field_mode.hxx +27 -0
  149. package/deps/couchbase-cxx-client/couchbase/search_sort_field_type.hxx +28 -0
  150. package/deps/couchbase-cxx-client/couchbase/search_sort_id.hxx +60 -0
  151. package/deps/couchbase-cxx-client/couchbase/search_sort_score.hxx +60 -0
  152. package/deps/couchbase-cxx-client/couchbase/search_term_range.hxx +51 -0
  153. package/deps/couchbase-cxx-client/couchbase/security_options.hxx +3 -0
  154. package/deps/couchbase-cxx-client/couchbase/subdocument_error_context.hxx +4 -2
  155. package/deps/couchbase-cxx-client/couchbase/term_facet.hxx +48 -0
  156. package/deps/couchbase-cxx-client/couchbase/term_facet_result.hxx +55 -0
  157. package/deps/couchbase-cxx-client/couchbase/term_query.hxx +151 -0
  158. package/deps/couchbase-cxx-client/couchbase/term_range_query.hxx +142 -0
  159. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_options.hxx +1 -1
  160. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_query_options.hxx +2 -1
  161. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_result.hxx +1 -1
  162. package/deps/couchbase-cxx-client/couchbase/transactions.hxx +3 -3
  163. package/deps/couchbase-cxx-client/couchbase/wildcard_query.hxx +83 -0
  164. package/deps/couchbase-cxx-client/docs/Doxyfile.in +1 -1
  165. package/deps/couchbase-cxx-client/docs/cbc-analytics.md +2 -2
  166. package/deps/couchbase-cxx-client/docs/cbc-get.md +3 -2
  167. package/deps/couchbase-cxx-client/docs/cbc-pillowfight.md +7 -2
  168. package/deps/couchbase-cxx-client/docs/cbc-query.md +2 -2
  169. package/deps/couchbase-cxx-client/docs/cbc.md +3 -3
  170. package/deps/couchbase-cxx-client/docs/cli.hxx +5 -5
  171. package/deps/couchbase-cxx-client/docs/mainpage.hxx +42 -5
  172. package/deps/couchbase-cxx-client/test/CMakeLists.txt +1 -0
  173. package/deps/couchbase-cxx-client/test/test_integration_analytics.cxx +28 -6
  174. package/deps/couchbase-cxx-client/test/test_integration_collections.cxx +7 -3
  175. package/deps/couchbase-cxx-client/test/test_integration_connect.cxx +7 -3
  176. package/deps/couchbase-cxx-client/test/test_integration_crud.cxx +13 -3
  177. package/deps/couchbase-cxx-client/test/test_integration_diagnostics.cxx +8 -2
  178. package/deps/couchbase-cxx-client/test/test_integration_durability.cxx +12 -7
  179. package/deps/couchbase-cxx-client/test/test_integration_examples.cxx +283 -11
  180. package/deps/couchbase-cxx-client/test/test_integration_management.cxx +140 -88
  181. package/deps/couchbase-cxx-client/test/test_integration_query.cxx +67 -9
  182. package/deps/couchbase-cxx-client/test/test_integration_range_scan.cxx +12 -12
  183. package/deps/couchbase-cxx-client/test/test_integration_read_replica.cxx +48 -11
  184. package/deps/couchbase-cxx-client/test/test_integration_search.cxx +19 -1
  185. package/deps/couchbase-cxx-client/test/test_integration_subdoc.cxx +60 -9
  186. package/deps/couchbase-cxx-client/test/test_integration_tracer.cxx +3 -0
  187. package/deps/couchbase-cxx-client/test/test_integration_transcoders.cxx +4 -0
  188. package/deps/couchbase-cxx-client/test/test_transaction_examples.cxx +100 -85
  189. package/deps/couchbase-cxx-client/test/test_unit_connection_string.cxx +29 -0
  190. package/deps/couchbase-cxx-client/test/test_unit_search.cxx +427 -0
  191. package/deps/couchbase-cxx-client/test/utils/integration_test_guard.cxx +2 -1
  192. package/deps/couchbase-cxx-client/test/utils/logger.cxx +3 -1
  193. package/deps/couchbase-cxx-client/test/utils/server_version.hxx +31 -15
  194. package/deps/couchbase-cxx-client/test/utils/test_context.cxx +8 -0
  195. package/deps/couchbase-cxx-client/tools/get.cxx +9 -8
  196. package/deps/couchbase-cxx-client/tools/pillowfight.cxx +175 -75
  197. package/deps/couchbase-cxx-client/tools/version.cxx +4 -2
  198. package/dist/binding.d.ts +1 -1
  199. package/dist/binding.js +3 -2
  200. package/package.json +96 -1
  201. package/scripts/createPlatformPackages.js +108 -0
  202. package/scripts/install.js +45 -0
  203. package/scripts/prebuilds.js +249 -0
  204. package/scripts/prune.js +124 -0
  205. package/src/jstocbpp_autogen.hpp +3 -2
@@ -0,0 +1,111 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2023-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/search_query.hxx>
21
+
22
+ #include <string>
23
+ #include <vector>
24
+
25
+ namespace couchbase
26
+ {
27
+ /**
28
+ * A doc_id query is a query that directly matches the documents whose ID have been provided. It can be combined within a conjunction_query
29
+ * to restrict matches on the set of documents.
30
+ *
31
+ * @since 1.0.0
32
+ * @committed
33
+ */
34
+ class doc_id_query : public search_query
35
+ {
36
+ public:
37
+ doc_id_query() = default;
38
+
39
+ /**
40
+ * Create a new doc_id query.
41
+ *
42
+ * @param ids the list of document IDs to be restricted against.
43
+ *
44
+ * @since 1.0.0
45
+ * @committed
46
+ */
47
+ explicit doc_id_query(std::vector<std::string> ids)
48
+ : ids_{ std::move(ids) }
49
+ {
50
+ }
51
+
52
+ /**
53
+ * Create a new doc_id query.
54
+ *
55
+ * @param ids the list of document IDs to be restricted against.
56
+ *
57
+ * @since 1.0.0
58
+ * @committed
59
+ */
60
+ doc_id_query(std::initializer_list<std::string> ids)
61
+ {
62
+ ids_.reserve(ids.size());
63
+ doc_ids(ids);
64
+ }
65
+
66
+ /**
67
+ * Add IDs to the query.
68
+ *
69
+ * @param ids the list of document identifiers to add
70
+ *
71
+ * @return this query for chaining purposes.
72
+ *
73
+ * @since 1.0.0
74
+ * @committed
75
+ */
76
+ auto doc_ids(const std::vector<std::string>& ids) -> doc_id_query&
77
+ {
78
+ for (const auto& id : ids) {
79
+ ids_.push_back(id);
80
+ }
81
+ return *this;
82
+ }
83
+
84
+ /**
85
+ * Add ID to the query.
86
+ *
87
+ * @param id the document identifier to add
88
+ *
89
+ * @return this query for chaining purposes.
90
+ *
91
+ * @since 1.0.0
92
+ * @committed
93
+ */
94
+ auto doc_id(const std::string& id) -> doc_id_query&
95
+ {
96
+ ids_.push_back(id);
97
+ return *this;
98
+ }
99
+
100
+ /**
101
+ * @return encoded representation of the query.
102
+ *
103
+ * @since 1.0.0
104
+ * @internal
105
+ */
106
+ [[nodiscard]] auto encode() const -> encoded_search_query override;
107
+
108
+ private:
109
+ std::vector<std::string> ids_{};
110
+ };
111
+ } // namespace couchbase
@@ -43,6 +43,7 @@ class error_context
43
43
  * @committed
44
44
  */
45
45
  error_context() = default;
46
+ virtual ~error_context() = default;
46
47
 
47
48
  /**
48
49
  * Creates and initializes error context with given parameters.
@@ -56,12 +57,14 @@ class error_context
56
57
  * @since 1.0.0
57
58
  * @internal
58
59
  */
59
- error_context(std::error_code ec,
60
+ error_context(std::string operation_id,
61
+ std::error_code ec,
60
62
  std::optional<std::string> last_dispatched_to,
61
63
  std::optional<std::string> last_dispatched_from,
62
64
  std::size_t retry_attempts,
63
65
  std::set<retry_reason> retry_reasons)
64
- : ec_{ ec }
66
+ : operation_id_{ std::move(operation_id) }
67
+ , ec_{ ec }
65
68
  , last_dispatched_to_{ std::move(last_dispatched_to) }
66
69
  , last_dispatched_from_{ std::move(last_dispatched_from) }
67
70
  , retry_attempts_{ retry_attempts }
@@ -69,6 +72,11 @@ class error_context
69
72
  {
70
73
  }
71
74
 
75
+ [[nodiscard]] virtual auto operation_id() const -> const std::string&
76
+ {
77
+ return operation_id_;
78
+ }
79
+
72
80
  /**
73
81
  * Returns status of the operation.
74
82
  *
@@ -79,7 +87,7 @@ class error_context
79
87
  * @since 1.0.0
80
88
  * @committed
81
89
  */
82
- [[nodiscard]] auto ec() const -> std::error_code
90
+ [[nodiscard]] virtual auto ec() const -> std::error_code
83
91
  {
84
92
  return ec_;
85
93
  }
@@ -105,7 +113,7 @@ class error_context
105
113
  * @since 1.0.0
106
114
  * @committed
107
115
  */
108
- [[nodiscard]] auto last_dispatched_to() const -> const std::optional<std::string>&
116
+ [[nodiscard]] virtual auto last_dispatched_to() const -> const std::optional<std::string>&
109
117
  {
110
118
  return last_dispatched_to_;
111
119
  }
@@ -118,7 +126,7 @@ class error_context
118
126
  * @since 1.0.0
119
127
  * @committed
120
128
  */
121
- [[nodiscard]] auto last_dispatched_from() const -> const std::optional<std::string>&
129
+ [[nodiscard]] virtual auto last_dispatched_from() const -> const std::optional<std::string>&
122
130
  {
123
131
  return last_dispatched_from_;
124
132
  }
@@ -131,7 +139,7 @@ class error_context
131
139
  * @since 1.0.0
132
140
  * @committed
133
141
  */
134
- [[nodiscard]] auto retry_attempts() const -> std::size_t
142
+ [[nodiscard]] virtual auto retry_attempts() const -> std::size_t
135
143
  {
136
144
  return retry_attempts_;
137
145
  }
@@ -144,7 +152,7 @@ class error_context
144
152
  * @since 1.0.0
145
153
  * @committed
146
154
  */
147
- [[nodiscard]] auto retry_reasons() const -> const std::set<retry_reason>&
155
+ [[nodiscard]] virtual auto retry_reasons() const -> const std::set<retry_reason>&
148
156
  {
149
157
  return retry_reasons_;
150
158
  }
@@ -158,12 +166,13 @@ class error_context
158
166
  * @since 1.0.0
159
167
  * @uncommitted
160
168
  */
161
- [[nodiscard]] auto retried_because_of(retry_reason reason) const -> bool
169
+ [[nodiscard]] virtual auto retried_because_of(retry_reason reason) const -> bool
162
170
  {
163
171
  return retry_reasons_.count(reason) > 0;
164
172
  }
165
173
 
166
174
  private:
175
+ std::string operation_id_{};
167
176
  std::error_code ec_{};
168
177
  std::optional<std::string> last_dispatched_to_{};
169
178
  std::optional<std::string> last_dispatched_from_{};
@@ -0,0 +1,52 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2020-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/analytics_scan_consistency.hxx>
21
+
22
+ #include <fmt/core.h>
23
+
24
+ /**
25
+ * Helper for fmtlib to format @ref couchbase::analytics_scan_consistency objects.
26
+ *
27
+ * @since 1.0.0
28
+ * @committed
29
+ */
30
+ template<>
31
+ struct fmt::formatter<couchbase::analytics_scan_consistency> {
32
+ template<typename ParseContext>
33
+ constexpr auto parse(ParseContext& ctx)
34
+ {
35
+ return ctx.begin();
36
+ }
37
+
38
+ template<typename FormatContext>
39
+ auto format(couchbase::analytics_scan_consistency mode, FormatContext& ctx) const
40
+ {
41
+ string_view name = "unknown";
42
+ switch (mode) {
43
+ case couchbase::analytics_scan_consistency::not_bounded:
44
+ name = "not_bounded";
45
+ break;
46
+ case couchbase::analytics_scan_consistency::request_plus:
47
+ name = "request_plus";
48
+ break;
49
+ }
50
+ return format_to(ctx.out(), "{}", name);
51
+ }
52
+ };
@@ -17,12 +17,12 @@
17
17
 
18
18
  #pragma once
19
19
 
20
- #include "error_map.hxx"
20
+ #include <couchbase/key_value_error_map_attribute.hxx>
21
21
 
22
22
  #include <fmt/core.h>
23
23
 
24
24
  template<>
25
- struct fmt::formatter<couchbase::api::key_value_error_map_attribute> {
25
+ struct fmt::formatter<couchbase::key_value_error_map_attribute> {
26
26
  template<typename ParseContext>
27
27
  constexpr auto parse(ParseContext& ctx)
28
28
  {
@@ -30,62 +30,62 @@ struct fmt::formatter<couchbase::api::key_value_error_map_attribute> {
30
30
  }
31
31
 
32
32
  template<typename FormatContext>
33
- auto format(couchbase::api::key_value_error_map_attribute attr, FormatContext& ctx) const
33
+ auto format(couchbase::key_value_error_map_attribute attr, FormatContext& ctx) const
34
34
  {
35
35
  string_view name = "unknown";
36
36
  switch (attr) {
37
- case couchbase::api::key_value_error_map_attribute::success:
37
+ case couchbase::key_value_error_map_attribute::success:
38
38
  name = "success";
39
39
  break;
40
- case couchbase::api::key_value_error_map_attribute::item_only:
40
+ case couchbase::key_value_error_map_attribute::item_only:
41
41
  name = "item-only";
42
42
  break;
43
- case couchbase::api::key_value_error_map_attribute::invalid_input:
43
+ case couchbase::key_value_error_map_attribute::invalid_input:
44
44
  name = "invalid-input";
45
45
  break;
46
- case couchbase::api::key_value_error_map_attribute::fetch_config:
46
+ case couchbase::key_value_error_map_attribute::fetch_config:
47
47
  name = "fetch-config";
48
48
  break;
49
- case couchbase::api::key_value_error_map_attribute::conn_state_invalidated:
49
+ case couchbase::key_value_error_map_attribute::conn_state_invalidated:
50
50
  name = "conn-state-invalidated";
51
51
  break;
52
- case couchbase::api::key_value_error_map_attribute::auth:
52
+ case couchbase::key_value_error_map_attribute::auth:
53
53
  name = "auth";
54
54
  break;
55
- case couchbase::api::key_value_error_map_attribute::special_handling:
55
+ case couchbase::key_value_error_map_attribute::special_handling:
56
56
  name = "special-handling";
57
57
  break;
58
- case couchbase::api::key_value_error_map_attribute::support:
58
+ case couchbase::key_value_error_map_attribute::support:
59
59
  name = "support";
60
60
  break;
61
- case couchbase::api::key_value_error_map_attribute::temp:
61
+ case couchbase::key_value_error_map_attribute::temp:
62
62
  name = "temp";
63
63
  break;
64
- case couchbase::api::key_value_error_map_attribute::internal:
64
+ case couchbase::key_value_error_map_attribute::internal:
65
65
  name = "internal";
66
66
  break;
67
- case couchbase::api::key_value_error_map_attribute::retry_now:
67
+ case couchbase::key_value_error_map_attribute::retry_now:
68
68
  name = "retry-now";
69
69
  break;
70
- case couchbase::api::key_value_error_map_attribute::retry_later:
70
+ case couchbase::key_value_error_map_attribute::retry_later:
71
71
  name = "retry-later";
72
72
  break;
73
- case couchbase::api::key_value_error_map_attribute::subdoc:
73
+ case couchbase::key_value_error_map_attribute::subdoc:
74
74
  name = "subdoc";
75
75
  break;
76
- case couchbase::api::key_value_error_map_attribute::dcp:
76
+ case couchbase::key_value_error_map_attribute::dcp:
77
77
  name = "dcp";
78
78
  break;
79
- case couchbase::api::key_value_error_map_attribute::auto_retry:
79
+ case couchbase::key_value_error_map_attribute::auto_retry:
80
80
  name = "auto-retry";
81
81
  break;
82
- case couchbase::api::key_value_error_map_attribute::item_locked:
82
+ case couchbase::key_value_error_map_attribute::item_locked:
83
83
  name = "item-locked";
84
84
  break;
85
- case couchbase::api::key_value_error_map_attribute::item_deleted:
85
+ case couchbase::key_value_error_map_attribute::item_deleted:
86
86
  name = "item-deleted";
87
87
  break;
88
- case couchbase::api::key_value_error_map_attribute::rate_limit:
88
+ case couchbase::key_value_error_map_attribute::rate_limit:
89
89
  name = "rate-limit";
90
90
  break;
91
91
  }
@@ -0,0 +1,49 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2020-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/search_scan_consistency.hxx>
21
+
22
+ #include <fmt/core.h>
23
+
24
+ /**
25
+ * Helper for fmtlib to format @ref couchbase::search_scan_consistency objects.
26
+ *
27
+ * @since 1.0.0
28
+ * @committed
29
+ */
30
+ template<>
31
+ struct fmt::formatter<couchbase::search_scan_consistency> {
32
+ template<typename ParseContext>
33
+ constexpr auto parse(ParseContext& ctx)
34
+ {
35
+ return ctx.begin();
36
+ }
37
+
38
+ template<typename FormatContext>
39
+ auto format(couchbase::search_scan_consistency mode, FormatContext& ctx) const
40
+ {
41
+ string_view name = "unknown";
42
+ switch (mode) {
43
+ case couchbase::search_scan_consistency::not_bounded:
44
+ name = "not_bounded";
45
+ break;
46
+ }
47
+ return format_to(ctx.out(), "{}", name);
48
+ }
49
+ };
@@ -0,0 +1,107 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2023-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/geo_point.hxx>
21
+ #include <couchbase/search_query.hxx>
22
+
23
+ #include <optional>
24
+ #include <string>
25
+
26
+ namespace couchbase
27
+ {
28
+ /**
29
+ * This query finds all @ref geo_point indexed matches within a given area (identified by the list of @ref geo_point coordinates). Each of
30
+ * the pairs is taken to indicate one corner of a polygon. Documents are returned if they reference a location within the area of the
31
+ * polygon.
32
+ *
33
+ * The following query-body uses an array of @ref geo_point to specify the latitude and longitude of each of the corners of a polygon, known
34
+ * as polygon points. Here, the last-specified entry is identical to the initial, thus explicitly closing the box. However, specifying an
35
+ * explicit closure in this way is optional: the closure will be inferred by the Couchbase Server if not explicitly specified.
36
+ * @snippet test_unit_search.cxx search-geo-bounding-box
37
+ *
38
+ * @see https://docs.couchbase.com/server/current/fts/fts-supported-queries-geo-bounded-rectangle.html server documentation
39
+ *
40
+ * @since 1.0.0
41
+ * @committed
42
+ */
43
+ class geo_bounding_box_query : public search_query
44
+ {
45
+ public:
46
+ /**
47
+ * Create a new geo bounding box query.
48
+ *
49
+ * @param top_left the top left coordinates signify the bounding box area
50
+ * @param bottom_right the bottom right coordinates signify the bounding box area
51
+ *
52
+ * @since 1.0.0
53
+ * @committed
54
+ */
55
+ geo_bounding_box_query(geo_point top_left, geo_point bottom_right)
56
+ : top_left_{ top_left }
57
+ , bottom_right_{ bottom_right }
58
+ {
59
+ }
60
+
61
+ /**
62
+ * Create a new geo distance query.
63
+ *
64
+ * @param top_left_latitude latitude of the top left coordinate
65
+ * @param top_left_longitude longitude of the top left coordinate
66
+ * @param bottom_right_latitude latitude of the bottom right coordinate
67
+ * @param bottom_right_longitude latitude of the bottom right coordinate
68
+ *
69
+ * @since 1.0.0
70
+ * @committed
71
+ */
72
+ geo_bounding_box_query(double top_left_latitude, double top_left_longitude, double bottom_right_latitude, double bottom_right_longitude)
73
+ : top_left_{ geo_point{ top_left_latitude, top_left_longitude } }
74
+ , bottom_right_{ geo_point{ bottom_right_latitude, bottom_right_longitude } }
75
+ {
76
+ }
77
+
78
+ /**
79
+ * If a field is specified, only terms in that field will be matched.
80
+ *
81
+ * @param field_name name of the field to be matched
82
+ *
83
+ * @return this query for chaining purposes.
84
+ *
85
+ * @since 1.0.0
86
+ * @committed
87
+ */
88
+ auto field(std::string field_name) -> geo_bounding_box_query&
89
+ {
90
+ field_ = std::move(field_name);
91
+ return *this;
92
+ }
93
+
94
+ /**
95
+ * @return encoded representation of the query.
96
+ *
97
+ * @since 1.0.0
98
+ * @internal
99
+ */
100
+ [[nodiscard]] auto encode() const -> encoded_search_query override;
101
+
102
+ private:
103
+ geo_point top_left_;
104
+ geo_point bottom_right_;
105
+ std::optional<std::string> field_{};
106
+ };
107
+ } // namespace couchbase
@@ -0,0 +1,109 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2023-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/geo_point.hxx>
21
+ #include <couchbase/search_query.hxx>
22
+
23
+ #include <optional>
24
+ #include <string>
25
+
26
+ namespace couchbase
27
+ {
28
+ /**
29
+ * This query finds all matches from a given location as @ref geo_point within the given distance. Both the point and the distance are
30
+ * required.
31
+ *
32
+ * The following query specifies a longitude of `-2.235143` and a latitude of `53.482358`. The target-field `geo` is specified, as is a
33
+ * distance of `100 miles`: this is the radius within which target-locations must reside for their documents to be returned.
34
+ * @snippet test_unit_search.cxx search-geo-distance
35
+ *
36
+ * @see https://docs.couchbase.com/server/current/fts/fts-supported-queries-geo-point-distance.html server documentation
37
+ *
38
+ * @since 1.0.0
39
+ * @committed
40
+ */
41
+ class geo_distance_query : public search_query
42
+ {
43
+ public:
44
+ /**
45
+ * Create a new geo distance query.
46
+ *
47
+ * @param location the location represents a point from which the distance is measured.
48
+ * @param distance the distance describes how far from the location the radius should be matched. For example, `"11km"`,
49
+ * `"11kilometers"`, `"3nm"`, `"3nauticalmiles"`, `"17mi"`, `"17miles"`, `"19m"`, `"19meters"`.
50
+ *
51
+ * @see https://github.com/blevesearch/bleve/blob/ae28975038cb25655da968e3f043210749ba382b/geo/geo_dist.go#L29-L37 list of distance
52
+ * units.
53
+ *
54
+ * @since 1.0.0
55
+ * @committed
56
+ */
57
+ geo_distance_query(geo_point location, std::string distance)
58
+ : location_{ location }
59
+ , distance_{ std::move(distance) }
60
+ {
61
+ }
62
+
63
+ /**
64
+ * Create a new geo distance query.
65
+ *
66
+ * @param latitude the location latitude
67
+ * @param longitude the location longitude
68
+ * @param distance the distance describes how far from the location the radius should be matched. For example, `"11km"`,
69
+ * `"11kilometers"`, `"3nm"`, `"3nauticalmiles"`, `"17mi"`, `"17miles"`, `"19m"`, `"19meters"`.
70
+ *
71
+ * @since 1.0.0
72
+ * @committed
73
+ */
74
+ geo_distance_query(double latitude, double longitude, std::string distance)
75
+ : location_{ geo_point{ latitude, longitude } }
76
+ , distance_{ std::move(distance) }
77
+ {
78
+ }
79
+
80
+ /**
81
+ * If a field is specified, only terms in that field will be matched.
82
+ *
83
+ * @param field_name name of the field to be matched
84
+ *
85
+ * @return this query for chaining purposes.
86
+ *
87
+ * @since 1.0.0
88
+ * @committed
89
+ */
90
+ auto field(std::string field_name) -> geo_distance_query&
91
+ {
92
+ field_ = std::move(field_name);
93
+ return *this;
94
+ }
95
+
96
+ /**
97
+ * @return encoded representation of the query.
98
+ *
99
+ * @since 1.0.0
100
+ * @internal
101
+ */
102
+ [[nodiscard]] auto encode() const -> encoded_search_query override;
103
+
104
+ private:
105
+ geo_point location_;
106
+ std::string distance_;
107
+ std::optional<std::string> field_{};
108
+ };
109
+ } // namespace couchbase
@@ -0,0 +1,32 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2023-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
+ namespace couchbase
21
+ {
22
+ /**
23
+ * Tuple representing geographical point.
24
+ *
25
+ * @since 1.0.0
26
+ * @committed
27
+ */
28
+ struct geo_point {
29
+ double latitude{ 0 };
30
+ double longitude{ 0 };
31
+ };
32
+ } // namespace couchbase