couchbase 4.2.9 → 4.2.11-rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. package/deps/couchbase-cxx-client/CMakeLists.txt +4 -0
  2. package/deps/couchbase-cxx-client/cmake/CompilerWarnings.cmake +7 -3
  3. package/deps/couchbase-cxx-client/cmake/OpenSSL.cmake +1 -0
  4. package/deps/couchbase-cxx-client/core/bucket.cxx +67 -2
  5. package/deps/couchbase-cxx-client/core/bucket.hxx +2 -1
  6. package/deps/couchbase-cxx-client/core/cluster.cxx +65 -1
  7. package/deps/couchbase-cxx-client/core/impl/bucket.cxx +24 -0
  8. package/deps/couchbase-cxx-client/core/impl/cluster.cxx +73 -0
  9. package/deps/couchbase-cxx-client/core/impl/collection.cxx +2 -2
  10. package/deps/couchbase-cxx-client/core/impl/diagnostics.cxx +294 -0
  11. package/deps/couchbase-cxx-client/core/impl/diagnostics.hxx +39 -0
  12. package/deps/couchbase-cxx-client/core/impl/query_index_manager.cxx +6 -6
  13. package/deps/couchbase-cxx-client/core/impl/scope.cxx +19 -4
  14. package/deps/couchbase-cxx-client/core/impl/search.cxx +75 -2
  15. package/deps/couchbase-cxx-client/core/impl/search.hxx +8 -0
  16. package/deps/couchbase-cxx-client/core/impl/search_index_manager.cxx +261 -18
  17. package/deps/couchbase-cxx-client/core/impl/search_request.cxx +139 -0
  18. package/deps/couchbase-cxx-client/core/impl/vector_query.cxx +42 -0
  19. package/deps/couchbase-cxx-client/core/impl/vector_search.cxx +40 -0
  20. package/deps/couchbase-cxx-client/core/io/http_session.hxx +6 -3
  21. package/deps/couchbase-cxx-client/core/io/http_session_manager.hxx +7 -1
  22. package/deps/couchbase-cxx-client/core/io/mcbp_command.hxx +10 -0
  23. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +48 -33
  24. package/deps/couchbase-cxx-client/core/io/mcbp_session.hxx +2 -0
  25. package/deps/couchbase-cxx-client/core/logger/logger.cxx +1 -1
  26. package/deps/couchbase-cxx-client/core/management/design_document.hxx +1 -1
  27. package/deps/couchbase-cxx-client/core/meta/features.hxx +26 -1
  28. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_all_replicas.hxx +1 -1
  29. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_any_replica.hxx +1 -1
  30. package/deps/couchbase-cxx-client/core/operations/document_query.cxx +8 -3
  31. package/deps/couchbase-cxx-client/core/operations/document_search.cxx +37 -1
  32. package/deps/couchbase-cxx-client/core/operations/document_search.hxx +11 -0
  33. package/deps/couchbase-cxx-client/core/operations/document_view.cxx +3 -0
  34. package/deps/couchbase-cxx-client/core/operations/document_view.hxx +1 -0
  35. package/deps/couchbase-cxx-client/core/operations/management/collection_create.cxx +7 -6
  36. package/deps/couchbase-cxx-client/core/operations/management/collection_create.hxx +1 -1
  37. package/deps/couchbase-cxx-client/core/operations/management/collection_update.cxx +7 -8
  38. package/deps/couchbase-cxx-client/core/operations/management/collection_update.hxx +1 -1
  39. package/deps/couchbase-cxx-client/core/operations/management/error_utils.cxx +3 -0
  40. package/deps/couchbase-cxx-client/core/operations/management/query_index_create.cxx +24 -13
  41. package/deps/couchbase-cxx-client/core/operations/management/query_index_create.hxx +1 -1
  42. package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.cxx +17 -1
  43. package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.hxx +3 -0
  44. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.cxx +21 -1
  45. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.hxx +3 -0
  46. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.cxx +21 -1
  47. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.hxx +3 -0
  48. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.cxx +21 -1
  49. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.hxx +3 -0
  50. package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.cxx +17 -1
  51. package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.hxx +3 -0
  52. package/deps/couchbase-cxx-client/core/operations/management/search_index_get.cxx +17 -1
  53. package/deps/couchbase-cxx-client/core/operations/management/search_index_get.hxx +2 -0
  54. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.cxx +39 -22
  55. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.hxx +3 -0
  56. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.cxx +18 -1
  57. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.hxx +3 -0
  58. package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.cxx +17 -1
  59. package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.hxx +3 -0
  60. package/deps/couchbase-cxx-client/core/origin.cxx +14 -0
  61. package/deps/couchbase-cxx-client/core/origin.hxx +6 -0
  62. package/deps/couchbase-cxx-client/core/protocol/status.cxx +2 -0
  63. package/deps/couchbase-cxx-client/core/protocol/status.hxx +1 -0
  64. package/deps/couchbase-cxx-client/core/topology/capabilities.hxx +70 -1
  65. package/deps/couchbase-cxx-client/core/topology/capabilities_fmt.hxx +30 -2
  66. package/deps/couchbase-cxx-client/core/topology/collections_manifest.hxx +1 -1
  67. package/deps/couchbase-cxx-client/core/topology/collections_manifest_json.hxx +1 -1
  68. package/deps/couchbase-cxx-client/core/topology/configuration.hxx +1 -34
  69. package/deps/couchbase-cxx-client/core/topology/configuration_fmt.hxx +2 -2
  70. package/deps/couchbase-cxx-client/core/topology/configuration_json.hxx +43 -20
  71. package/deps/couchbase-cxx-client/core/transactions/internal/exceptions_internal.hxx +5 -0
  72. package/deps/couchbase-cxx-client/core/transactions/internal/utils.hxx +4 -0
  73. package/deps/couchbase-cxx-client/core/vector_query_combination.hxx +23 -0
  74. package/deps/couchbase-cxx-client/couchbase/bucket.hxx +29 -0
  75. package/deps/couchbase-cxx-client/couchbase/cluster.hxx +110 -0
  76. package/deps/couchbase-cxx-client/couchbase/codec/json_transcoder.hxx +1 -1
  77. package/deps/couchbase-cxx-client/couchbase/codec/raw_binary_transcoder.hxx +2 -1
  78. package/deps/couchbase-cxx-client/couchbase/codec/raw_json_transcoder.hxx +78 -0
  79. package/deps/couchbase-cxx-client/couchbase/codec/raw_string_transcoder.hxx +72 -0
  80. package/deps/couchbase-cxx-client/couchbase/collection_query_index_manager.hxx +80 -11
  81. package/deps/couchbase-cxx-client/couchbase/create_collection_options.hxx +29 -1
  82. package/deps/couchbase-cxx-client/couchbase/diagnostics_options.hxx +75 -0
  83. package/deps/couchbase-cxx-client/couchbase/diagnostics_result.hxx +124 -0
  84. package/deps/couchbase-cxx-client/couchbase/endpoint_diagnostics.hxx +206 -0
  85. package/deps/couchbase-cxx-client/couchbase/endpoint_ping_report.hxx +205 -0
  86. package/deps/couchbase-cxx-client/couchbase/fmt/key_value_status_code.hxx +3 -1
  87. package/deps/couchbase-cxx-client/couchbase/get_options.hxx +1 -6
  88. package/deps/couchbase-cxx-client/couchbase/key_value_status_code.hxx +1 -0
  89. package/deps/couchbase-cxx-client/couchbase/management/collection_spec.hxx +1 -1
  90. package/deps/couchbase-cxx-client/couchbase/ping_options.hxx +93 -0
  91. package/deps/couchbase-cxx-client/couchbase/ping_result.hxx +118 -0
  92. package/deps/couchbase-cxx-client/couchbase/query_index_manager.hxx +6 -8
  93. package/deps/couchbase-cxx-client/couchbase/scope.hxx +24 -8
  94. package/deps/couchbase-cxx-client/couchbase/scope_search_index_manager.hxx +291 -0
  95. package/deps/couchbase-cxx-client/couchbase/search_request.hxx +120 -0
  96. package/deps/couchbase-cxx-client/couchbase/service_type.hxx +58 -0
  97. package/deps/couchbase-cxx-client/couchbase/update_collection_options.hxx +32 -3
  98. package/deps/couchbase-cxx-client/couchbase/vector_query.hxx +99 -0
  99. package/deps/couchbase-cxx-client/couchbase/vector_search.hxx +85 -0
  100. package/deps/couchbase-cxx-client/couchbase/vector_search_options.hxx +76 -0
  101. package/dist/binding.d.ts +33 -2
  102. package/dist/binding.js +4 -1
  103. package/dist/bindingutilities.d.ts +16 -3
  104. package/dist/bindingutilities.js +47 -7
  105. package/dist/cluster.d.ts +12 -1
  106. package/dist/cluster.js +22 -0
  107. package/dist/couchbase.d.ts +2 -0
  108. package/dist/couchbase.js +2 -0
  109. package/dist/queryindexmanager.d.ts +4 -4
  110. package/dist/queryindexmanager.js +7 -7
  111. package/dist/scope.d.ts +21 -0
  112. package/dist/scope.js +34 -0
  113. package/dist/scopesearchindexmanager.d.ts +116 -0
  114. package/dist/scopesearchindexmanager.js +406 -0
  115. package/dist/sdspecs.js +10 -9
  116. package/dist/sdutils.d.ts +1 -0
  117. package/dist/sdutils.js +4 -0
  118. package/dist/searchexecutor.d.ts +5 -3
  119. package/dist/searchexecutor.js +27 -4
  120. package/dist/searchindexmanager.d.ts +58 -3
  121. package/dist/searchindexmanager.js +188 -104
  122. package/dist/searchtypes.d.ts +46 -0
  123. package/dist/searchtypes.js +81 -1
  124. package/dist/vectorsearch.d.ts +99 -0
  125. package/dist/vectorsearch.js +132 -0
  126. package/dist/viewexecutor.js +13 -9
  127. package/dist/viewindexmanager.d.ts +70 -7
  128. package/dist/viewindexmanager.js +236 -103
  129. package/dist/viewtypes.d.ts +26 -0
  130. package/dist/viewtypes.js +17 -1
  131. package/package.json +7 -7
  132. package/src/constants.cpp +12 -0
  133. package/src/jstocbpp_autogen.hpp +113 -13
  134. package/tools/gen-bindings-json.py +2 -0
@@ -42,6 +42,9 @@ struct search_index_control_ingest_request {
42
42
  std::string index_name;
43
43
  bool pause;
44
44
 
45
+ std::optional<std::string> bucket_name;
46
+ std::optional<std::string> scope_name;
47
+
45
48
  std::optional<std::string> client_context_id{};
46
49
  std::optional<std::chrono::milliseconds> timeout{};
47
50
 
@@ -31,7 +31,15 @@ search_index_control_plan_freeze_request::encode_to(encoded_request_type& encode
31
31
  return errc::common::invalid_argument;
32
32
  }
33
33
  encoded.method = "POST";
34
- encoded.path = fmt::format("/api/index/{}/planFreezeControl/{}", index_name, freeze ? "freeze" : "unfreeze");
34
+ if (bucket_name.has_value() && scope_name.has_value()) {
35
+ encoded.path = fmt::format("/api/bucket/{}/scope/{}/index/{}/planFreezeControl/{}",
36
+ bucket_name.value(),
37
+ scope_name.value(),
38
+ index_name,
39
+ freeze ? "freeze" : "unfreeze");
40
+ } else {
41
+ encoded.path = fmt::format("/api/index/{}/planFreezeControl/{}", index_name, freeze ? "freeze" : "unfreeze");
42
+ }
35
43
  return {};
36
44
  }
37
45
 
@@ -66,6 +74,18 @@ search_index_control_plan_freeze_request::make_response(error_context::http&& ct
66
74
  response.ctx.ec = errc::common::index_not_found;
67
75
  return response;
68
76
  }
77
+ } else if (encoded.status_code == 404) {
78
+ tao::json::value payload{};
79
+ try {
80
+ payload = utils::json::parse(encoded.body.data());
81
+ } catch (const tao::pegtl::parse_error&) {
82
+ response.ctx.ec = errc::common::parsing_failure;
83
+ return response;
84
+ }
85
+ response.status = payload.at("status").get_string();
86
+ response.error = payload.at("error").get_string();
87
+ response.ctx.ec = errc::common::feature_not_available;
88
+ return response;
69
89
  }
70
90
  response.ctx.ec = extract_common_error_code(encoded.status_code, encoded.body.data());
71
91
  }
@@ -44,6 +44,9 @@ struct search_index_control_plan_freeze_request {
44
44
  std::string index_name;
45
45
  bool freeze;
46
46
 
47
+ std::optional<std::string> bucket_name;
48
+ std::optional<std::string> scope_name;
49
+
47
50
  std::optional<std::string> client_context_id{};
48
51
  std::optional<std::chrono::milliseconds> timeout{};
49
52
 
@@ -31,7 +31,15 @@ search_index_control_query_request::encode_to(encoded_request_type& encoded, htt
31
31
  return errc::common::invalid_argument;
32
32
  }
33
33
  encoded.method = "POST";
34
- encoded.path = fmt::format("/api/index/{}/queryControl/{}", index_name, allow ? "allow" : "disallow");
34
+ if (bucket_name.has_value() && scope_name.has_value()) {
35
+ encoded.path = fmt::format("/api/bucket/{}/scope/{}/index/{}/queryControl/{}",
36
+ bucket_name.value(),
37
+ scope_name.value(),
38
+ index_name,
39
+ allow ? "allow" : "disallow");
40
+ } else {
41
+ encoded.path = fmt::format("/api/index/{}/queryControl/{}", index_name, allow ? "allow" : "disallow");
42
+ }
35
43
  return {};
36
44
  }
37
45
 
@@ -66,6 +74,18 @@ search_index_control_query_request::make_response(error_context::http&& ctx, con
66
74
  response.ctx.ec = errc::common::index_not_found;
67
75
  return response;
68
76
  }
77
+ } else if (encoded.status_code == 404) {
78
+ tao::json::value payload{};
79
+ try {
80
+ payload = utils::json::parse(encoded.body.data());
81
+ } catch (const tao::pegtl::parse_error&) {
82
+ response.ctx.ec = errc::common::parsing_failure;
83
+ return response;
84
+ }
85
+ response.status = payload.at("status").get_string();
86
+ response.error = payload.at("error").get_string();
87
+ response.ctx.ec = errc::common::feature_not_available;
88
+ return response;
69
89
  }
70
90
  response.ctx.ec = extract_common_error_code(encoded.status_code, encoded.body.data());
71
91
  }
@@ -42,6 +42,9 @@ struct search_index_control_query_request {
42
42
  std::string index_name;
43
43
  bool allow;
44
44
 
45
+ std::optional<std::string> bucket_name;
46
+ std::optional<std::string> scope_name;
47
+
45
48
  std::optional<std::string> client_context_id{};
46
49
  std::optional<std::chrono::milliseconds> timeout{};
47
50
 
@@ -31,7 +31,11 @@ search_index_drop_request::encode_to(encoded_request_type& encoded, http_context
31
31
  return errc::common::invalid_argument;
32
32
  }
33
33
  encoded.method = "DELETE";
34
- encoded.path = fmt::format("/api/index/{}", index_name);
34
+ if (bucket_name.has_value() && scope_name.has_value()) {
35
+ encoded.path = fmt::format("/api/bucket/{}/scope/{}/index/{}", bucket_name.value(), scope_name.value(), index_name);
36
+ } else {
37
+ encoded.path = fmt::format("/api/index/{}", index_name);
38
+ }
35
39
  return {};
36
40
  }
37
41
  search_index_drop_response
@@ -65,6 +69,18 @@ search_index_drop_request::make_response(error_context::http&& ctx, const encode
65
69
  response.ctx.ec = errc::common::index_not_found;
66
70
  return response;
67
71
  }
72
+ } else if (encoded.status_code == 404) {
73
+ tao::json::value payload{};
74
+ try {
75
+ payload = utils::json::parse(encoded.body.data());
76
+ } catch (const tao::pegtl::parse_error&) {
77
+ response.ctx.ec = errc::common::parsing_failure;
78
+ return response;
79
+ }
80
+ response.status = payload.at("status").get_string();
81
+ response.error = payload.at("error").get_string();
82
+ response.ctx.ec = errc::common::feature_not_available;
83
+ return response;
68
84
  }
69
85
  response.ctx.ec = extract_common_error_code(encoded.status_code, encoded.body.data());
70
86
  }
@@ -41,6 +41,9 @@ struct search_index_drop_request {
41
41
 
42
42
  std::string index_name;
43
43
 
44
+ std::optional<std::string> bucket_name;
45
+ std::optional<std::string> scope_name;
46
+
44
47
  std::optional<std::string> client_context_id{};
45
48
  std::optional<std::chrono::milliseconds> timeout{};
46
49
 
@@ -32,7 +32,11 @@ search_index_get_request::encode_to(encoded_request_type& encoded, http_context&
32
32
  return errc::common::invalid_argument;
33
33
  }
34
34
  encoded.method = "GET";
35
- encoded.path = fmt::format("/api/index/{}", index_name);
35
+ if (bucket_name.has_value() && scope_name.has_value()) {
36
+ encoded.path = fmt::format("/api/bucket/{}/scope/{}/index/{}", bucket_name.value(), scope_name.value(), index_name);
37
+ } else {
38
+ encoded.path = fmt::format("/api/index/{}", index_name);
39
+ }
36
40
  return {};
37
41
  }
38
42
 
@@ -68,6 +72,18 @@ search_index_get_request::make_response(error_context::http&& ctx, const encoded
68
72
  response.ctx.ec = errc::common::index_not_found;
69
73
  return response;
70
74
  }
75
+ } else if (encoded.status_code == 404) {
76
+ tao::json::value payload{};
77
+ try {
78
+ payload = utils::json::parse(encoded.body.data());
79
+ } catch (const tao::pegtl::parse_error&) {
80
+ response.ctx.ec = errc::common::parsing_failure;
81
+ return response;
82
+ }
83
+ response.status = payload.at("status").get_string();
84
+ response.error = payload.at("error").get_string();
85
+ response.ctx.ec = errc::common::feature_not_available;
86
+ return response;
71
87
  }
72
88
  response.ctx.ec = extract_common_error_code(encoded.status_code, encoded.body.data());
73
89
  }
@@ -42,6 +42,8 @@ struct search_index_get_request {
42
42
  static const inline service_type type = service_type::search;
43
43
 
44
44
  std::string index_name;
45
+ std::optional<std::string> bucket_name;
46
+ std::optional<std::string> scope_name;
45
47
 
46
48
  std::optional<std::string> client_context_id{};
47
49
  std::optional<std::chrono::milliseconds> timeout{};
@@ -21,13 +21,19 @@
21
21
  #include "core/utils/json.hxx"
22
22
  #include "error_utils.hxx"
23
23
 
24
+ #include <fmt/core.h>
25
+
24
26
  namespace couchbase::core::operations::management
25
27
  {
26
28
  std::error_code
27
29
  search_index_get_all_request::encode_to(encoded_request_type& encoded, http_context& /* context */) const
28
30
  {
29
31
  encoded.method = "GET";
30
- encoded.path = "/api/index";
32
+ if (bucket_name.has_value() && scope_name.has_value()) {
33
+ encoded.path = fmt::format("/api/bucket/{}/scope/{}/index", bucket_name.value(), scope_name.value());
34
+ } else {
35
+ encoded.path = "/api/index";
36
+ }
31
37
  return {};
32
38
  }
33
39
 
@@ -36,30 +42,41 @@ search_index_get_all_request::make_response(error_context::http&& ctx, const enc
36
42
  {
37
43
  search_index_get_all_response response{ std::move(ctx) };
38
44
  if (!response.ctx.ec) {
39
- if (encoded.status_code != 200) {
40
- response.ctx.ec = extract_common_error_code(encoded.status_code, encoded.body.data());
41
- return response;
42
- }
43
- tao::json::value payload{};
44
- try {
45
- payload = utils::json::parse(encoded.body.data());
46
- } catch (const tao::pegtl::parse_error&) {
47
- response.ctx.ec = errc::common::parsing_failure;
48
- return response;
49
- }
50
- response.status = payload.at("status").get_string();
51
- if (response.status != "ok") {
52
- return response;
53
- }
54
- if (const auto* indexDefs = payload.find("indexDefs"); indexDefs != nullptr && indexDefs->is_object()) {
55
- if (const auto* impl_ver = indexDefs->find("implVersion"); impl_ver != nullptr && impl_ver->is_string()) {
56
- response.impl_version = impl_ver->get_string();
45
+ if (encoded.status_code == 200) {
46
+ tao::json::value payload{};
47
+ try {
48
+ payload = utils::json::parse(encoded.body.data());
49
+ } catch (const tao::pegtl::parse_error&) {
50
+ response.ctx.ec = errc::common::parsing_failure;
51
+ return response;
52
+ }
53
+ response.status = payload.at("status").get_string();
54
+ if (response.status != "ok") {
55
+ return response;
57
56
  }
58
- const auto* indexes = indexDefs->find("indexDefs");
59
- for (const auto& [name, index] : indexes->get_object()) {
60
- response.indexes.emplace_back(index.as<couchbase::core::management::search::index>());
57
+ if (const auto* indexDefs = payload.find("indexDefs"); indexDefs != nullptr && indexDefs->is_object()) {
58
+ if (const auto* impl_ver = indexDefs->find("implVersion"); impl_ver != nullptr && impl_ver->is_string()) {
59
+ response.impl_version = impl_ver->get_string();
60
+ }
61
+ const auto* indexes = indexDefs->find("indexDefs");
62
+ for (const auto& [name, index] : indexes->get_object()) {
63
+ response.indexes.emplace_back(index.as<couchbase::core::management::search::index>());
64
+ }
65
+ return response;
61
66
  }
67
+ } else if (encoded.status_code == 404) {
68
+ tao::json::value payload{};
69
+ try {
70
+ payload = utils::json::parse(encoded.body.data());
71
+ } catch (const tao::pegtl::parse_error&) {
72
+ response.ctx.ec = errc::common::parsing_failure;
73
+ return response;
74
+ }
75
+ response.status = payload.at("status").get_string();
76
+ response.ctx.ec = errc::common::feature_not_available;
77
+ return response;
62
78
  }
79
+ response.ctx.ec = extract_common_error_code(encoded.status_code, encoded.body.data());
63
80
  }
64
81
  return response;
65
82
  }
@@ -41,6 +41,9 @@ struct search_index_get_all_request {
41
41
 
42
42
  static const inline service_type type = service_type::search;
43
43
 
44
+ std::optional<std::string> bucket_name;
45
+ std::optional<std::string> scope_name;
46
+
44
47
  std::optional<std::string> client_context_id{};
45
48
  std::optional<std::chrono::milliseconds> timeout{};
46
49
 
@@ -28,7 +28,11 @@ std::error_code
28
28
  search_index_get_documents_count_request::encode_to(encoded_request_type& encoded, http_context& /* context */) const
29
29
  {
30
30
  encoded.method = "GET";
31
- encoded.path = fmt::format("/api/index/{}/count", index_name);
31
+ if (bucket_name.has_value() && scope_name.has_value()) {
32
+ encoded.path = fmt::format("/api/bucket/{}/scope/{}/index/{}/count", bucket_name.value(), scope_name.value(), index_name);
33
+ } else {
34
+ encoded.path = fmt::format("/api/index/{}/count", index_name);
35
+ }
32
36
  return {};
33
37
  }
34
38
 
@@ -52,6 +56,19 @@ search_index_get_documents_count_request::make_response(error_context::http&& ct
52
56
  return response;
53
57
  }
54
58
  } break;
59
+ case 404: {
60
+ tao::json::value payload{};
61
+ try {
62
+ payload = utils::json::parse(encoded.body.data());
63
+ } catch (const tao::pegtl::parse_error&) {
64
+ response.ctx.ec = errc::common::parsing_failure;
65
+ return response;
66
+ }
67
+ response.status = payload.at("status").get_string();
68
+ response.error = payload.at("error").get_string();
69
+ response.ctx.ec = errc::common::feature_not_available;
70
+ return response;
71
+ }
55
72
  case 400:
56
73
  case 500: {
57
74
  tao::json::value payload{};
@@ -42,6 +42,9 @@ struct search_index_get_documents_count_request {
42
42
 
43
43
  std::string index_name;
44
44
 
45
+ std::optional<std::string> bucket_name;
46
+ std::optional<std::string> scope_name;
47
+
45
48
  std::optional<std::string> client_context_id{};
46
49
  std::optional<std::chrono::milliseconds> timeout{};
47
50
 
@@ -34,7 +34,11 @@ search_index_upsert_request::encode_to(encoded_request_type& encoded, http_conte
34
34
  encoded.method = "PUT";
35
35
  encoded.headers["cache-control"] = "no-cache";
36
36
  encoded.headers["content-type"] = "application/json";
37
- encoded.path = fmt::format("/api/index/{}", index.name);
37
+ if (bucket_name.has_value() && scope_name.has_value()) {
38
+ encoded.path = fmt::format("/api/bucket/{}/scope/{}/index/{}", bucket_name.value(), scope_name.value(), index.name);
39
+ } else {
40
+ encoded.path = fmt::format("/api/index/{}", index.name);
41
+ }
38
42
  tao::json::value body{
39
43
  { "name", index.name },
40
44
  { "type", index.type },
@@ -108,6 +112,18 @@ search_index_upsert_request::make_response(error_context::http&& ctx, const enco
108
112
  response.ctx.ec = errc::common::quota_limited;
109
113
  return response;
110
114
  }
115
+ } else if (encoded.status_code == 404) {
116
+ tao::json::value payload{};
117
+ try {
118
+ payload = utils::json::parse(encoded.body.data());
119
+ } catch (const tao::pegtl::parse_error&) {
120
+ response.ctx.ec = errc::common::parsing_failure;
121
+ return response;
122
+ }
123
+ response.status = payload.at("status").get_string();
124
+ response.error = payload.at("error").get_string();
125
+ response.ctx.ec = errc::common::feature_not_available;
126
+ return response;
111
127
  }
112
128
  response.ctx.ec = extract_common_error_code(encoded.status_code, encoded.body.data());
113
129
  }
@@ -44,6 +44,9 @@ struct search_index_upsert_request {
44
44
 
45
45
  couchbase::core::management::search::index index;
46
46
 
47
+ std::optional<std::string> bucket_name;
48
+ std::optional<std::string> scope_name;
49
+
47
50
  std::optional<std::string> client_context_id{};
48
51
  std::optional<std::chrono::milliseconds> timeout{};
49
52
 
@@ -18,6 +18,7 @@
18
18
  #include "origin.hxx"
19
19
 
20
20
  #include "core/utils/connection_string.hxx"
21
+ #include "topology/configuration.hxx"
21
22
 
22
23
  #include <fmt/chrono.h>
23
24
  #include <fmt/core.h>
@@ -281,6 +282,19 @@ couchbase::core::origin::origin(const couchbase::core::origin& other)
281
282
  , next_node_(nodes_.begin())
282
283
  {
283
284
  }
285
+
286
+ couchbase::core::origin::origin(const origin& other, const topology::configuration& config)
287
+ : origin(other)
288
+ {
289
+ nodes_.clear();
290
+ for (const auto& node : config.nodes) {
291
+ if (auto port = options_.enable_tls ? node.services_tls.key_value : node.services_plain.key_value; port.has_value()) {
292
+ nodes_.emplace_back(node.hostname, std::to_string(port.value()));
293
+ }
294
+ }
295
+ next_node_ = nodes_.begin();
296
+ }
297
+
284
298
  couchbase::core::origin::origin(couchbase::core::cluster_credentials auth,
285
299
  const std::string& hostname,
286
300
  std::uint16_t port,
@@ -40,6 +40,11 @@ struct cluster_credentials {
40
40
  [[nodiscard]] bool uses_certificate() const;
41
41
  };
42
42
 
43
+ namespace topology
44
+ {
45
+ struct configuration;
46
+ }
47
+
43
48
  struct origin {
44
49
  using node_entry = std::pair<std::string, std::string>;
45
50
  using node_list = std::vector<node_entry>;
@@ -49,6 +54,7 @@ struct origin {
49
54
 
50
55
  origin(origin&& other) = default;
51
56
  origin(const origin& other);
57
+ origin(const origin& other, const topology::configuration& config);
52
58
  origin(cluster_credentials auth, const std::string& hostname, std::uint16_t port, cluster_options options);
53
59
  origin(cluster_credentials auth, const std::string& hostname, const std::string& port, cluster_options options);
54
60
  origin(cluster_credentials auth, const utils::connection_string& connstr);
@@ -202,6 +202,8 @@ map_status_code(protocol::client_opcode opcode, std::uint16_t status)
202
202
 
203
203
  case key_value_status_code::unknown:
204
204
  break;
205
+ case key_value_status_code::config_only:
206
+ break;
205
207
  }
206
208
  return errc::network::protocol_error;
207
209
  }
@@ -103,6 +103,7 @@ is_valid_status(std::uint16_t code)
103
103
  case key_value_status_code::range_scan_more:
104
104
  case key_value_status_code::range_scan_complete:
105
105
  case key_value_status_code::range_scan_vb_uuid_not_equal:
106
+ case key_value_status_code::config_only:
106
107
  return true;
107
108
  case key_value_status_code::unknown:
108
109
  return false;
@@ -17,6 +17,8 @@
17
17
 
18
18
  #pragma once
19
19
 
20
+ #include <set>
21
+
20
22
  namespace couchbase::core
21
23
  {
22
24
  enum class bucket_capability {
@@ -32,8 +34,15 @@ enum class bucket_capability {
32
34
  durable_write,
33
35
  tombstoned_user_xattrs,
34
36
  range_scan,
35
- replica_read,
36
37
  non_deduped_history,
38
+ subdoc_replace_body_with_xattr,
39
+ subdoc_document_macro_support,
40
+ subdoc_revive_document,
41
+ dcp_ignore_purged_tombstones,
42
+ preserve_expiry,
43
+ query_system_collection,
44
+ mobile_system_collection,
45
+ subdoc_replica_read,
37
46
  };
38
47
 
39
48
  enum class cluster_capability {
@@ -43,5 +52,65 @@ enum class cluster_capability {
43
52
  n1ql_inline_functions,
44
53
  n1ql_enhanced_prepared_statements,
45
54
  n1ql_read_from_replica,
55
+ search_vector_search,
56
+ search_scoped_search_index,
57
+ };
58
+
59
+ struct configuration_capabilities {
60
+ std::set<bucket_capability> bucket{};
61
+ std::set<cluster_capability> cluster{};
62
+
63
+ [[nodiscard]] bool has_cluster_capability(cluster_capability cap) const
64
+ {
65
+ return cluster.find(cap) != cluster.end();
66
+ }
67
+
68
+ [[nodiscard]] bool has_bucket_capability(bucket_capability cap) const
69
+ {
70
+ return bucket.find(cap) != bucket.end();
71
+ }
72
+
73
+ [[nodiscard]] bool supports_enhanced_prepared_statements() const
74
+ {
75
+ return has_cluster_capability(cluster_capability::n1ql_enhanced_prepared_statements);
76
+ }
77
+
78
+ [[nodiscard]] bool supports_read_from_replica() const
79
+ {
80
+ return has_cluster_capability(cluster_capability::n1ql_read_from_replica);
81
+ }
82
+
83
+ [[nodiscard]] bool supports_range_scan() const
84
+ {
85
+ return has_bucket_capability(bucket_capability::range_scan);
86
+ }
87
+
88
+ [[nodiscard]] bool ephemeral() const
89
+ {
90
+ // Use bucket capabilities to identify if couchapi is missing (then its ephemeral). If its null then
91
+ // we are running an old version of couchbase which doesn't have ephemeral buckets at all.
92
+ return has_bucket_capability(bucket_capability::couchapi);
93
+ }
94
+
95
+ [[nodiscard]] bool supports_subdoc_read_replica() const
96
+ {
97
+ return has_bucket_capability(bucket_capability::subdoc_replica_read);
98
+ }
99
+
100
+ [[nodiscard]] bool supports_non_deduped_history() const
101
+ {
102
+ return has_bucket_capability(bucket_capability::non_deduped_history);
103
+ }
104
+
105
+ [[nodiscard]] bool supports_scoped_search_indexes() const
106
+ {
107
+ return has_cluster_capability(cluster_capability::search_scoped_search_index);
108
+ }
109
+
110
+ [[nodiscard]] bool supports_vector_search() const
111
+ {
112
+ return has_cluster_capability(cluster_capability::search_vector_search);
113
+ }
46
114
  };
115
+
47
116
  } // namespace couchbase::core
@@ -70,12 +70,33 @@ struct fmt::formatter<couchbase::core::bucket_capability> {
70
70
  case couchbase::core::bucket_capability::range_scan:
71
71
  name = "range_scan";
72
72
  break;
73
- case couchbase::core::bucket_capability::replica_read:
74
- name = "replica_read";
73
+ case couchbase::core::bucket_capability::subdoc_replica_read:
74
+ name = "subdoc_replica_read";
75
75
  break;
76
76
  case couchbase::core::bucket_capability::non_deduped_history:
77
77
  name = "non_deduped_history";
78
78
  break;
79
+ case couchbase::core::bucket_capability::subdoc_replace_body_with_xattr:
80
+ name = "subdoc_replace_body_with_xattr";
81
+ break;
82
+ case couchbase::core::bucket_capability::subdoc_document_macro_support:
83
+ name = "subdoc_document_macro_support";
84
+ break;
85
+ case couchbase::core::bucket_capability::subdoc_revive_document:
86
+ name = "subdoc_revive_document";
87
+ break;
88
+ case couchbase::core::bucket_capability::dcp_ignore_purged_tombstones:
89
+ name = "dcp_ignore_purged_tombstones";
90
+ break;
91
+ case couchbase::core::bucket_capability::preserve_expiry:
92
+ name = "preserve_expiry";
93
+ break;
94
+ case couchbase::core::bucket_capability::query_system_collection:
95
+ name = "query_system_collection";
96
+ break;
97
+ case couchbase::core::bucket_capability::mobile_system_collection:
98
+ name = "mobile_system_collection";
99
+ break;
79
100
  }
80
101
  return format_to(ctx.out(), "{}", name);
81
102
  }
@@ -111,6 +132,13 @@ struct fmt::formatter<couchbase::core::cluster_capability> {
111
132
  break;
112
133
  case couchbase::core::cluster_capability::n1ql_read_from_replica:
113
134
  name = "n1ql_read_from_replica";
135
+ break;
136
+ case couchbase::core::cluster_capability::search_vector_search:
137
+ name = "search_vector_search";
138
+ break;
139
+ case couchbase::core::cluster_capability::search_scoped_search_index:
140
+ name = "search_scoped_search_index";
141
+ break;
114
142
  }
115
143
  return format_to(ctx.out(), "{}", name);
116
144
  }
@@ -28,7 +28,7 @@ struct collections_manifest {
28
28
  struct collection {
29
29
  std::uint64_t uid;
30
30
  std::string name;
31
- std::uint32_t max_expiry{ 0 };
31
+ std::int32_t max_expiry{ 0 };
32
32
  std::optional<bool> history{};
33
33
  };
34
34
 
@@ -41,7 +41,7 @@ struct traits<couchbase::core::topology::collections_manifest> {
41
41
  collection.uid = std::stoull(c.at("uid").get_string(), nullptr, 16);
42
42
  collection.name = c.at("name").get_string();
43
43
  if (const auto* max_ttl = c.find("maxTTL"); max_ttl != nullptr) {
44
- collection.max_expiry = max_ttl->template as<std::uint32_t>();
44
+ collection.max_expiry = max_ttl->template as<std::int32_t>();
45
45
  }
46
46
  if (const auto* history = c.find("history"); history != nullptr) {
47
47
  collection.history = history->template as<std::optional<bool>>();
@@ -89,8 +89,7 @@ struct configuration {
89
89
  std::optional<std::string> bucket{};
90
90
  std::optional<vbucket_map> vbmap{};
91
91
  std::optional<std::uint64_t> collections_manifest_uid{};
92
- std::set<bucket_capability> bucket_capabilities{};
93
- std::set<cluster_capability> cluster_capabilities{};
92
+ configuration_capabilities capabilities{};
94
93
  node_locator_type node_locator{ node_locator_type::unknown };
95
94
  bool force{ false };
96
95
 
@@ -111,38 +110,6 @@ struct configuration {
111
110
 
112
111
  [[nodiscard]] std::string rev_str() const;
113
112
 
114
- [[nodiscard]] bool supports_enhanced_prepared_statements() const
115
- {
116
- return cluster_capabilities.find(cluster_capability::n1ql_enhanced_prepared_statements) != cluster_capabilities.end();
117
- }
118
-
119
- [[nodiscard]] bool supports_read_from_replica() const
120
- {
121
- return cluster_capabilities.find(cluster_capability::n1ql_read_from_replica) != cluster_capabilities.end();
122
- }
123
-
124
- [[nodiscard]] bool supports_range_scan() const
125
- {
126
- return bucket_capabilities.find(bucket_capability::range_scan) != bucket_capabilities.end();
127
- }
128
-
129
- [[nodiscard]] bool ephemeral() const
130
- {
131
- // Use bucket capabilities to identify if couchapi is missing (then its ephemeral). If its null then
132
- // we are running an old version of couchbase which doesn't have ephemeral buckets at all.
133
- return bucket_capabilities.count(couchbase::core::bucket_capability::couchapi) == 0;
134
- }
135
-
136
- [[nodiscard]] bool supports_subdoc_read_replica() const
137
- {
138
- return bucket_capabilities.find(bucket_capability::replica_read) != bucket_capabilities.end();
139
- }
140
-
141
- [[nodiscard]] bool supports_non_deduped_history() const
142
- {
143
- return bucket_capabilities.find(bucket_capability::non_deduped_history) != bucket_capabilities.end();
144
- }
145
-
146
113
  [[nodiscard]] std::size_t index_for_this_node() const;
147
114
  [[nodiscard]] bool has_node(const std::string& network,
148
115
  service_type type,