couchbase 4.2.3 → 4.2.5-dev.1

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 (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,62 @@
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
+ #include "encoded_search_query.hxx"
19
+
20
+ #include <couchbase/boolean_query.hxx>
21
+
22
+ #include <couchbase/error_codes.hxx>
23
+
24
+ namespace couchbase
25
+ {
26
+ auto
27
+ boolean_query::encode() const -> encoded_search_query
28
+ {
29
+ if (!must_ && !should_ && !must_not_) {
30
+ return { errc::common::invalid_argument };
31
+ }
32
+
33
+ encoded_search_query built;
34
+ built.query = tao::json::empty_object;
35
+ if (boost_) {
36
+ built.query["boost"] = boost_.value();
37
+ }
38
+ if (must_) {
39
+ auto encoded = must_->encode();
40
+ if (encoded.ec) {
41
+ return { encoded.ec };
42
+ }
43
+ built.query["must"] = encoded.query;
44
+ }
45
+ if (must_not_) {
46
+ auto encoded = must_not_->encode();
47
+ if (encoded.ec) {
48
+ return { encoded.ec };
49
+ }
50
+ built.query["must_not"] = encoded.query;
51
+ }
52
+ if (should_) {
53
+ auto encoded = should_->encode();
54
+ if (encoded.ec) {
55
+ return { encoded.ec };
56
+ }
57
+ built.query["should"] = encoded.query;
58
+ }
59
+
60
+ return built;
61
+ }
62
+ } // namespace couchbase
@@ -90,6 +90,7 @@ options_to_origin(const std::string& connection_string, const couchbase::cluster
90
90
  user_options.tls_verify = core::tls_verify_mode::peer;
91
91
  break;
92
92
  }
93
+ user_options.disable_mozilla_ca_certificates = opts.security.disable_mozilla_ca_certificates;
93
94
  }
94
95
 
95
96
  if (opts.dns.nameserver) {
@@ -0,0 +1,51 @@
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
+ #include "encoded_search_query.hxx"
19
+
20
+ #include <couchbase/conjunction_query.hxx>
21
+
22
+ #include <couchbase/error_codes.hxx>
23
+
24
+ namespace couchbase
25
+ {
26
+ auto
27
+ conjunction_query::encode() const -> encoded_search_query
28
+ {
29
+ if (conjuncts_.empty()) {
30
+ return { errc::common::invalid_argument };
31
+ }
32
+
33
+ encoded_search_query built;
34
+ built.query = tao::json::empty_object;
35
+ if (boost_) {
36
+ built.query["boost"] = boost_.value();
37
+ }
38
+
39
+ tao::json::value conjuncts = tao::json::empty_array;
40
+ for (const auto& conjunct : conjuncts_) {
41
+ auto encoded = conjunct->encode();
42
+ if (encoded.ec) {
43
+ return { encoded.ec };
44
+ }
45
+ conjuncts.push_back(encoded.query);
46
+ }
47
+ built.query["conjuncts"] = conjuncts;
48
+
49
+ return built;
50
+ }
51
+ } // namespace couchbase
@@ -0,0 +1,89 @@
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
+ #include <couchbase/date_range.hxx>
19
+
20
+ #include <fmt/chrono.h>
21
+
22
+ namespace couchbase
23
+ {
24
+ static constexpr const char* iso_8601_format = "{:%Y-%m-%dT%H:%M:%S%z}";
25
+
26
+ date_range::date_range(std::string name, std::string start, std::string end)
27
+ : name_{ std::move(name) }
28
+ , start_{ std::move(start) }
29
+ , end_{ std::move(end) }
30
+ {
31
+ }
32
+
33
+ date_range::date_range(std::string name, std::chrono::system_clock::time_point start, std::chrono::system_clock::time_point end)
34
+ : name_{ std::move(name) }
35
+ , start_{ fmt::format(iso_8601_format, start) }
36
+ , end_{ fmt::format(iso_8601_format, end) }
37
+ {
38
+ }
39
+
40
+ date_range::date_range(std::string name, std::tm start, std::tm end)
41
+ : name_{ std::move(name) }
42
+ , start_{ fmt::format(iso_8601_format, start) }
43
+ , end_{ fmt::format(iso_8601_format, end) }
44
+ {
45
+ }
46
+
47
+ date_range::date_range(std::string name, std::optional<std::string> start, std::optional<std::string> end)
48
+ : name_{ std::move(name) }
49
+ , start_{ std::move(start) }
50
+ , end_{ std::move(end) }
51
+ {
52
+ }
53
+
54
+ date_range
55
+ date_range::with_start(std::string name, std::string start)
56
+ {
57
+ return { std::move(name), std::move(start), {} };
58
+ }
59
+
60
+ date_range
61
+ date_range::with_start(std::string name, std::chrono::system_clock::time_point start)
62
+ {
63
+ return { std::move(name), fmt::format(iso_8601_format, start), {} };
64
+ }
65
+
66
+ date_range
67
+ date_range::with_start(std::string name, std::tm start)
68
+ {
69
+ return { std::move(name), fmt::format(iso_8601_format, start), {} };
70
+ }
71
+
72
+ date_range
73
+ date_range::with_end(std::string name, std::string end)
74
+ {
75
+ return { std::move(name), {}, std::move(end) };
76
+ }
77
+
78
+ date_range
79
+ date_range::with_end(std::string name, std::chrono::system_clock::time_point end)
80
+ {
81
+ return { std::move(name), {}, fmt::format(iso_8601_format, end) };
82
+ }
83
+
84
+ date_range
85
+ date_range::with_end(std::string name, std::tm end)
86
+ {
87
+ return { std::move(name), {}, fmt::format(iso_8601_format, end) };
88
+ }
89
+ } // namespace couchbase
@@ -0,0 +1,54 @@
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
+ #include "encoded_search_facet.hxx"
19
+
20
+ #include <couchbase/date_range_facet.hxx>
21
+ #include <couchbase/error_codes.hxx>
22
+
23
+ namespace couchbase
24
+ {
25
+ auto
26
+ date_range_facet::encode() const -> encoded_search_facet
27
+ {
28
+ encoded_search_facet built;
29
+ built.facet = {
30
+ { "field", field_ },
31
+ };
32
+ if (size_) {
33
+ built.facet["size"] = size_.value();
34
+ }
35
+ if (ranges_.empty()) {
36
+ return { errc::common::invalid_argument };
37
+ }
38
+ tao::json::value ranges = tao::json::empty_array;
39
+ for (const auto& range : ranges_) {
40
+ tao::json::value entry = {
41
+ { "field", range.name() },
42
+ };
43
+ if (const auto& start = range.start(); start.has_value()) {
44
+ entry["start"] = start.value();
45
+ }
46
+ if (const auto& end = range.end(); end.has_value()) {
47
+ entry["end"] = end.value();
48
+ }
49
+ ranges.emplace_back(entry);
50
+ }
51
+ built.facet["date_ranges"] = ranges;
52
+ return built;
53
+ }
54
+ } // namespace couchbase
@@ -0,0 +1,64 @@
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
+ #include "internal_date_range_facet_result.hxx"
19
+
20
+ #include <couchbase/date_range_facet_result.hxx>
21
+
22
+ namespace couchbase
23
+ {
24
+ date_range_facet_result::date_range_facet_result(internal_date_range_facet_result internal)
25
+ : internal_{ std::make_unique<internal_date_range_facet_result>(std::move(internal)) }
26
+ {
27
+ }
28
+
29
+ auto
30
+ date_range_facet_result::name() const -> const std::string&
31
+ {
32
+ return internal_->name();
33
+ }
34
+
35
+ auto
36
+ date_range_facet_result::field() const -> const std::string&
37
+ {
38
+ return internal_->field();
39
+ }
40
+
41
+ auto
42
+ date_range_facet_result::total() const -> std::uint64_t
43
+ {
44
+ return internal_->total();
45
+ }
46
+
47
+ auto
48
+ date_range_facet_result::missing() const -> std::uint64_t
49
+ {
50
+ return internal_->missing();
51
+ }
52
+
53
+ auto
54
+ date_range_facet_result::other() const -> std::uint64_t
55
+ {
56
+ return internal_->other();
57
+ }
58
+
59
+ auto
60
+ date_range_facet_result::date_ranges() const -> const std::vector<search_date_range>&
61
+ {
62
+ return internal_->date_ranges();
63
+ }
64
+ } // namespace couchbase
@@ -0,0 +1,125 @@
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
+ #include "encoded_search_query.hxx"
19
+
20
+ #include <couchbase/date_range_query.hxx>
21
+
22
+ #include <couchbase/error_codes.hxx>
23
+
24
+ #include <fmt/chrono.h>
25
+
26
+ namespace couchbase
27
+ {
28
+
29
+ static constexpr const char* iso_8601_format = "{:%Y-%m-%dT%H:%M:%S%z}";
30
+
31
+ auto
32
+ date_range_query::start(std::chrono::system_clock::time_point value) -> date_range_query&
33
+ {
34
+ start_ = fmt::format(iso_8601_format, value);
35
+ return *this;
36
+ }
37
+
38
+ auto
39
+ date_range_query::start(std::tm value) -> date_range_query&
40
+ {
41
+ start_ = fmt::format(iso_8601_format, value);
42
+ return *this;
43
+ }
44
+
45
+ auto
46
+ date_range_query::start(std::chrono::system_clock::time_point value, bool inclusive) -> date_range_query&
47
+ {
48
+ start_ = fmt::format(iso_8601_format, value);
49
+ inclusive_start_ = inclusive;
50
+ return *this;
51
+ }
52
+
53
+ auto
54
+ date_range_query::start(std::tm value, bool inclusive) -> date_range_query&
55
+ {
56
+ start_ = fmt::format(iso_8601_format, value);
57
+ inclusive_start_ = inclusive;
58
+ return *this;
59
+ }
60
+
61
+ auto
62
+ date_range_query::end(std::chrono::system_clock::time_point value) -> date_range_query&
63
+ {
64
+
65
+ end_ = fmt::format(iso_8601_format, value);
66
+ return *this;
67
+ }
68
+
69
+ auto
70
+ date_range_query::end(std::tm value) -> date_range_query&
71
+ {
72
+ end_ = fmt::format(iso_8601_format, value);
73
+ return *this;
74
+ }
75
+
76
+ auto
77
+ date_range_query::end(std::chrono::system_clock::time_point value, bool inclusive) -> date_range_query&
78
+ {
79
+ end_ = fmt::format(iso_8601_format, value);
80
+ inclusive_end_ = inclusive;
81
+ return *this;
82
+ }
83
+
84
+ auto
85
+ date_range_query::end(std::tm value, bool inclusive) -> date_range_query&
86
+ {
87
+ end_ = fmt::format(iso_8601_format, value);
88
+ inclusive_end_ = inclusive;
89
+ return *this;
90
+ }
91
+
92
+ auto
93
+ date_range_query::encode() const -> encoded_search_query
94
+ {
95
+ if ((!start_ || start_->empty()) && (!end_ || end_->empty())) {
96
+ return { errc::common::invalid_argument };
97
+ }
98
+
99
+ encoded_search_query built;
100
+ built.query = tao::json::empty_object;
101
+ if (boost_) {
102
+ built.query["boost"] = boost_.value();
103
+ }
104
+ if (field_) {
105
+ built.query["field"] = field_.value();
106
+ }
107
+ if (start_) {
108
+ built.query["start"] = start_.value();
109
+ if (inclusive_start_.has_value()) {
110
+ built.query["inclusive_start"] = inclusive_start_.value();
111
+ }
112
+ }
113
+ if (end_) {
114
+ built.query["end"] = end_.value();
115
+ if (inclusive_end_.has_value()) {
116
+ built.query["inclusive_end"] = inclusive_end_.value();
117
+ }
118
+ }
119
+ if (date_time_parser_) {
120
+ built.query["datetime_parser"] = date_time_parser_.value();
121
+ }
122
+
123
+ return built;
124
+ }
125
+ } // namespace couchbase
@@ -0,0 +1,51 @@
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
+ #include "encoded_search_query.hxx"
19
+
20
+ #include <couchbase/disjunction_query.hxx>
21
+
22
+ #include <couchbase/error_codes.hxx>
23
+
24
+ namespace couchbase
25
+ {
26
+ auto
27
+ disjunction_query::encode() const -> encoded_search_query
28
+ {
29
+ if (disjuncts_.empty()) {
30
+ return { errc::common::invalid_argument };
31
+ }
32
+
33
+ encoded_search_query built;
34
+ built.query = tao::json::empty_object;
35
+ if (boost_) {
36
+ built.query["boost"] = boost_.value();
37
+ }
38
+
39
+ tao::json::value disjuncts = tao::json::empty_array;
40
+ for (const auto& disjunct : disjuncts_) {
41
+ auto encoded = disjunct->encode();
42
+ if (encoded.ec) {
43
+ return { encoded.ec };
44
+ }
45
+ disjuncts.push_back(encoded.query);
46
+ }
47
+ built.query["disjuncts"] = disjuncts;
48
+
49
+ return built;
50
+ }
51
+ } // namespace couchbase
@@ -0,0 +1,29 @@
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 <tao/json/value.hpp>
21
+
22
+ namespace couchbase
23
+ {
24
+ struct encoded_search_facet {
25
+ std::error_code ec{};
26
+ tao::json::value facet{};
27
+ };
28
+
29
+ } // namespace couchbase
@@ -0,0 +1,29 @@
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 <tao/json/value.hpp>
21
+
22
+ namespace couchbase
23
+ {
24
+ struct encoded_search_query {
25
+ std::error_code ec{};
26
+ tao::json::value query{};
27
+ };
28
+
29
+ } // namespace couchbase
@@ -0,0 +1,29 @@
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 <tao/json/value.hpp>
21
+
22
+ namespace couchbase
23
+ {
24
+ struct encoded_search_sort {
25
+ std::error_code ec{};
26
+ tao::json::value sort{};
27
+ };
28
+
29
+ } // namespace couchbase
@@ -0,0 +1,46 @@
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
+ #include "encoded_search_query.hxx"
19
+
20
+ #include <couchbase/geo_bounding_box_query.hxx>
21
+
22
+ namespace couchbase
23
+ {
24
+ auto
25
+ geo_bounding_box_query::encode() const -> encoded_search_query
26
+ {
27
+ encoded_search_query built;
28
+ built.query = tao::json::empty_object;
29
+ if (boost_) {
30
+ built.query["boost"] = boost_.value();
31
+ }
32
+ if (field_) {
33
+ built.query["field"] = field_.value();
34
+ }
35
+ built.query["top_left"] = {
36
+ { "lat", top_left_.latitude },
37
+ { "lon", top_left_.longitude },
38
+ };
39
+ built.query["bottom_right"] = {
40
+ { "lat", bottom_right_.latitude },
41
+ { "lon", bottom_right_.longitude },
42
+ };
43
+
44
+ return built;
45
+ }
46
+ } // namespace couchbase
@@ -0,0 +1,43 @@
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
+ #include "encoded_search_query.hxx"
19
+
20
+ #include <couchbase/geo_distance_query.hxx>
21
+
22
+ namespace couchbase
23
+ {
24
+ auto
25
+ geo_distance_query::encode() const -> encoded_search_query
26
+ {
27
+ encoded_search_query built;
28
+ built.query = tao::json::empty_object;
29
+ if (boost_) {
30
+ built.query["boost"] = boost_.value();
31
+ }
32
+ if (field_) {
33
+ built.query["field"] = field_.value();
34
+ }
35
+ built.query["distance"] = distance_;
36
+ built.query["location"] = {
37
+ { "lat", location_.latitude },
38
+ { "lon", location_.longitude },
39
+ };
40
+
41
+ return built;
42
+ }
43
+ } // namespace couchbase