couchbase 4.4.2 → 4.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (252) hide show
  1. package/BUILDING.md +182 -0
  2. package/CMakeLists.txt +13 -0
  3. package/CONTRIBUTING.md +1 -1
  4. package/README.md +4 -2
  5. package/deps/couchbase-cxx-cache/boringssl/e31ea00c1ea52052d2d78d44006cc88c80fa24a9/boringssl/src/BUILDING.md +206 -0
  6. package/deps/couchbase-cxx-client/CMakeLists.txt +18 -13
  7. package/deps/couchbase-cxx-client/README.md +2 -2
  8. package/deps/couchbase-cxx-client/cmake/APKBUILD.in +54 -0
  9. package/deps/couchbase-cxx-client/cmake/CompilerWarnings.cmake +0 -5
  10. package/deps/couchbase-cxx-client/cmake/Packaging.cmake +177 -10
  11. package/deps/couchbase-cxx-client/cmake/RPath.cmake +10 -0
  12. package/deps/couchbase-cxx-client/cmake/Testing.cmake +1 -1
  13. package/deps/couchbase-cxx-client/cmake/VersionInfo.cmake +28 -2
  14. package/deps/couchbase-cxx-client/cmake/build_version.hxx.in +1 -0
  15. package/deps/couchbase-cxx-client/cmake/couchbase-cxx-client.spec.in +45 -6
  16. package/deps/couchbase-cxx-client/cmake/couchbase_cxx_client.pc.in +2 -2
  17. package/deps/couchbase-cxx-client/cmake/debian/changelog.in +5 -0
  18. package/deps/couchbase-cxx-client/cmake/debian/compat +1 -0
  19. package/deps/couchbase-cxx-client/cmake/debian/control +40 -0
  20. package/deps/couchbase-cxx-client/cmake/debian/rules +41 -0
  21. package/deps/couchbase-cxx-client/cmake/debian/source/format +1 -0
  22. package/deps/couchbase-cxx-client/core/agent_group.cxx +8 -0
  23. package/deps/couchbase-cxx-client/core/agent_group.hxx +4 -0
  24. package/deps/couchbase-cxx-client/core/bucket.cxx +16 -20
  25. package/deps/couchbase-cxx-client/core/bucket.hxx +12 -12
  26. package/deps/couchbase-cxx-client/core/cluster.cxx +44 -52
  27. package/deps/couchbase-cxx-client/core/cluster_agent.cxx +8 -0
  28. package/deps/couchbase-cxx-client/core/cluster_agent.hxx +4 -0
  29. package/deps/couchbase-cxx-client/core/collections_component.cxx +2 -2
  30. package/deps/couchbase-cxx-client/core/columnar/agent.cxx +2 -2
  31. package/deps/couchbase-cxx-client/core/columnar/agent.hxx +1 -1
  32. package/deps/couchbase-cxx-client/core/columnar/management_component.cxx +3 -3
  33. package/deps/couchbase-cxx-client/core/columnar/query_component.cxx +103 -45
  34. package/deps/couchbase-cxx-client/core/columnar/query_component.hxx +1 -0
  35. package/deps/couchbase-cxx-client/core/free_form_http_request.hxx +8 -0
  36. package/deps/couchbase-cxx-client/core/http_component.cxx +55 -24
  37. package/deps/couchbase-cxx-client/core/http_component.hxx +4 -0
  38. package/deps/couchbase-cxx-client/core/impl/analytics.cxx +1 -0
  39. package/deps/couchbase-cxx-client/core/impl/analytics_index_manager.cxx +15 -15
  40. package/deps/couchbase-cxx-client/core/impl/bootstrap_error.hxx +10 -2
  41. package/deps/couchbase-cxx-client/core/impl/bucket.cxx +1 -1
  42. package/deps/couchbase-cxx-client/core/impl/bucket_manager.cxx +6 -6
  43. package/deps/couchbase-cxx-client/core/impl/cluster.cxx +36 -40
  44. package/deps/couchbase-cxx-client/core/impl/collection.cxx +29 -5
  45. package/deps/couchbase-cxx-client/core/impl/collection_manager.cxx +5 -5
  46. package/deps/couchbase-cxx-client/core/impl/error.cxx +24 -3
  47. package/deps/couchbase-cxx-client/core/impl/get_replica.hxx +2 -0
  48. package/deps/couchbase-cxx-client/core/impl/lookup_in_replica.hxx +2 -0
  49. package/deps/couchbase-cxx-client/core/impl/observe_poll.cxx +13 -5
  50. package/deps/couchbase-cxx-client/core/impl/observe_poll.hxx +1 -3
  51. package/deps/couchbase-cxx-client/core/impl/observe_seqno.hxx +2 -0
  52. package/deps/couchbase-cxx-client/core/impl/query.cxx +1 -0
  53. package/deps/couchbase-cxx-client/core/impl/query_index_manager.cxx +6 -6
  54. package/deps/couchbase-cxx-client/core/impl/scan_result.cxx +1 -1
  55. package/deps/couchbase-cxx-client/core/impl/search.cxx +2 -0
  56. package/deps/couchbase-cxx-client/core/impl/search_index_manager.cxx +12 -12
  57. package/deps/couchbase-cxx-client/core/io/http_command.hxx +31 -20
  58. package/deps/couchbase-cxx-client/core/io/http_session.cxx +5 -0
  59. package/deps/couchbase-cxx-client/core/io/http_session.hxx +17 -4
  60. package/deps/couchbase-cxx-client/core/io/http_session_manager.hxx +97 -49
  61. package/deps/couchbase-cxx-client/core/io/mcbp_command.hxx +15 -14
  62. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +48 -33
  63. package/deps/couchbase-cxx-client/core/io/streams.cxx +256 -0
  64. package/deps/couchbase-cxx-client/core/io/streams.hxx +31 -155
  65. package/deps/couchbase-cxx-client/core/logger/configuration.hxx +5 -0
  66. package/deps/couchbase-cxx-client/core/logger/custom_rotating_file_sink.cxx +2 -3
  67. package/deps/couchbase-cxx-client/core/logger/logger.cxx +39 -7
  68. package/deps/couchbase-cxx-client/core/logger/logger.hxx +7 -0
  69. package/deps/couchbase-cxx-client/core/meta/features.hxx +11 -0
  70. package/deps/couchbase-cxx-client/core/meta/version.cxx +47 -6
  71. package/deps/couchbase-cxx-client/core/metrics/meter_wrapper.cxx +188 -0
  72. package/deps/couchbase-cxx-client/core/metrics/meter_wrapper.hxx +73 -0
  73. package/deps/couchbase-cxx-client/core/operations/document_analytics.cxx +23 -17
  74. package/deps/couchbase-cxx-client/core/operations/document_analytics.hxx +1 -0
  75. package/deps/couchbase-cxx-client/core/operations/document_append.hxx +2 -0
  76. package/deps/couchbase-cxx-client/core/operations/document_decrement.hxx +2 -0
  77. package/deps/couchbase-cxx-client/core/operations/document_exists.hxx +2 -0
  78. package/deps/couchbase-cxx-client/core/operations/document_get.hxx +2 -0
  79. package/deps/couchbase-cxx-client/core/operations/document_get_all_replicas.hxx +2 -0
  80. package/deps/couchbase-cxx-client/core/operations/document_get_and_lock.hxx +2 -0
  81. package/deps/couchbase-cxx-client/core/operations/document_get_and_touch.hxx +2 -0
  82. package/deps/couchbase-cxx-client/core/operations/document_get_any_replica.hxx +2 -0
  83. package/deps/couchbase-cxx-client/core/operations/document_get_projected.hxx +2 -0
  84. package/deps/couchbase-cxx-client/core/operations/document_increment.hxx +2 -0
  85. package/deps/couchbase-cxx-client/core/operations/document_insert.hxx +2 -0
  86. package/deps/couchbase-cxx-client/core/operations/document_lookup_in.hxx +2 -0
  87. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_all_replicas.hxx +2 -0
  88. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_any_replica.hxx +2 -0
  89. package/deps/couchbase-cxx-client/core/operations/document_mutate_in.hxx +2 -0
  90. package/deps/couchbase-cxx-client/core/operations/document_prepend.hxx +2 -0
  91. package/deps/couchbase-cxx-client/core/operations/document_query.hxx +1 -0
  92. package/deps/couchbase-cxx-client/core/operations/document_remove.hxx +2 -0
  93. package/deps/couchbase-cxx-client/core/operations/document_replace.hxx +2 -0
  94. package/deps/couchbase-cxx-client/core/operations/document_search.hxx +1 -0
  95. package/deps/couchbase-cxx-client/core/operations/document_touch.hxx +2 -0
  96. package/deps/couchbase-cxx-client/core/operations/document_unlock.hxx +2 -0
  97. package/deps/couchbase-cxx-client/core/operations/document_upsert.hxx +2 -0
  98. package/deps/couchbase-cxx-client/core/operations/document_view.hxx +1 -0
  99. package/deps/couchbase-cxx-client/core/operations/http_noop.hxx +2 -0
  100. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_create.hxx +1 -0
  101. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_drop.hxx +1 -0
  102. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_get_all.hxx +1 -0
  103. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataverse_create.hxx +1 -0
  104. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataverse_drop.hxx +1 -0
  105. package/deps/couchbase-cxx-client/core/operations/management/analytics_get_pending_mutations.hxx +2 -0
  106. package/deps/couchbase-cxx-client/core/operations/management/analytics_index_create.hxx +1 -0
  107. package/deps/couchbase-cxx-client/core/operations/management/analytics_index_drop.hxx +1 -0
  108. package/deps/couchbase-cxx-client/core/operations/management/analytics_index_get_all.hxx +1 -0
  109. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_connect.hxx +1 -0
  110. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_create.hxx +1 -0
  111. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_disconnect.hxx +1 -0
  112. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_drop.hxx +1 -0
  113. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_get_all.cxx +23 -15
  114. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_get_all.hxx +4 -3
  115. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_replace.hxx +1 -0
  116. package/deps/couchbase-cxx-client/core/operations/management/bucket_create.hxx +1 -0
  117. package/deps/couchbase-cxx-client/core/operations/management/bucket_describe.cxx +2 -1
  118. package/deps/couchbase-cxx-client/core/operations/management/bucket_describe.hxx +1 -0
  119. package/deps/couchbase-cxx-client/core/operations/management/bucket_drop.cxx +3 -1
  120. package/deps/couchbase-cxx-client/core/operations/management/bucket_drop.hxx +1 -0
  121. package/deps/couchbase-cxx-client/core/operations/management/bucket_flush.cxx +3 -1
  122. package/deps/couchbase-cxx-client/core/operations/management/bucket_flush.hxx +1 -0
  123. package/deps/couchbase-cxx-client/core/operations/management/bucket_get.cxx +3 -1
  124. package/deps/couchbase-cxx-client/core/operations/management/bucket_get.hxx +1 -0
  125. package/deps/couchbase-cxx-client/core/operations/management/bucket_get_all.hxx +1 -0
  126. package/deps/couchbase-cxx-client/core/operations/management/bucket_update.cxx +3 -1
  127. package/deps/couchbase-cxx-client/core/operations/management/bucket_update.hxx +1 -0
  128. package/deps/couchbase-cxx-client/core/operations/management/change_password.hxx +1 -0
  129. package/deps/couchbase-cxx-client/core/operations/management/cluster_describe.hxx +1 -0
  130. package/deps/couchbase-cxx-client/core/operations/management/cluster_developer_preview_enable.hxx +1 -0
  131. package/deps/couchbase-cxx-client/core/operations/management/collection_create.cxx +3 -2
  132. package/deps/couchbase-cxx-client/core/operations/management/collection_create.hxx +2 -0
  133. package/deps/couchbase-cxx-client/core/operations/management/collection_drop.cxx +5 -2
  134. package/deps/couchbase-cxx-client/core/operations/management/collection_drop.hxx +1 -0
  135. package/deps/couchbase-cxx-client/core/operations/management/collection_update.cxx +4 -2
  136. package/deps/couchbase-cxx-client/core/operations/management/collection_update.hxx +2 -0
  137. package/deps/couchbase-cxx-client/core/operations/management/collections_manifest_get.hxx +2 -0
  138. package/deps/couchbase-cxx-client/core/operations/management/eventing_deploy_function.hxx +3 -2
  139. package/deps/couchbase-cxx-client/core/operations/management/eventing_drop_function.hxx +3 -2
  140. package/deps/couchbase-cxx-client/core/operations/management/eventing_get_all_functions.hxx +3 -2
  141. package/deps/couchbase-cxx-client/core/operations/management/eventing_get_function.hxx +3 -2
  142. package/deps/couchbase-cxx-client/core/operations/management/eventing_get_status.hxx +3 -2
  143. package/deps/couchbase-cxx-client/core/operations/management/eventing_pause_function.hxx +3 -2
  144. package/deps/couchbase-cxx-client/core/operations/management/eventing_resume_function.hxx +3 -2
  145. package/deps/couchbase-cxx-client/core/operations/management/eventing_undeploy_function.hxx +3 -2
  146. package/deps/couchbase-cxx-client/core/operations/management/eventing_upsert_function.hxx +3 -2
  147. package/deps/couchbase-cxx-client/core/operations/management/freeform.hxx +2 -0
  148. package/deps/couchbase-cxx-client/core/operations/management/group_drop.hxx +1 -0
  149. package/deps/couchbase-cxx-client/core/operations/management/group_get.hxx +1 -0
  150. package/deps/couchbase-cxx-client/core/operations/management/group_get_all.hxx +1 -0
  151. package/deps/couchbase-cxx-client/core/operations/management/group_upsert.cxx +3 -3
  152. package/deps/couchbase-cxx-client/core/operations/management/group_upsert.hxx +1 -0
  153. package/deps/couchbase-cxx-client/core/operations/management/query_index_build.hxx +2 -0
  154. package/deps/couchbase-cxx-client/core/operations/management/query_index_build_deferred.hxx +3 -0
  155. package/deps/couchbase-cxx-client/core/operations/management/query_index_create.hxx +1 -0
  156. package/deps/couchbase-cxx-client/core/operations/management/query_index_drop.hxx +1 -0
  157. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all.hxx +2 -0
  158. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all_deferred.hxx +3 -0
  159. package/deps/couchbase-cxx-client/core/operations/management/role_get_all.hxx +1 -0
  160. package/deps/couchbase-cxx-client/core/operations/management/scope_create.cxx +2 -1
  161. package/deps/couchbase-cxx-client/core/operations/management/scope_create.hxx +1 -0
  162. package/deps/couchbase-cxx-client/core/operations/management/scope_drop.cxx +4 -1
  163. package/deps/couchbase-cxx-client/core/operations/management/scope_drop.hxx +1 -0
  164. package/deps/couchbase-cxx-client/core/operations/management/scope_get_all.cxx +3 -1
  165. package/deps/couchbase-cxx-client/core/operations/management/scope_get_all.hxx +1 -0
  166. package/deps/couchbase-cxx-client/core/operations/management/search_get_stats.hxx +1 -0
  167. package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.cxx +3 -2
  168. package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.hxx +1 -0
  169. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.cxx +3 -2
  170. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.hxx +1 -0
  171. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.cxx +3 -2
  172. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.hxx +1 -0
  173. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.cxx +3 -2
  174. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.hxx +1 -0
  175. package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.cxx +5 -2
  176. package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.hxx +1 -0
  177. package/deps/couchbase-cxx-client/core/operations/management/search_index_get.cxx +5 -2
  178. package/deps/couchbase-cxx-client/core/operations/management/search_index_get.hxx +1 -0
  179. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.cxx +4 -2
  180. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.hxx +1 -0
  181. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.cxx +3 -2
  182. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.hxx +2 -0
  183. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_stats.hxx +1 -0
  184. package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.cxx +5 -2
  185. package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.hxx +1 -0
  186. package/deps/couchbase-cxx-client/core/operations/management/user_drop.hxx +1 -0
  187. package/deps/couchbase-cxx-client/core/operations/management/user_get.hxx +1 -0
  188. package/deps/couchbase-cxx-client/core/operations/management/user_get_all.hxx +1 -0
  189. package/deps/couchbase-cxx-client/core/operations/management/user_upsert.cxx +3 -3
  190. package/deps/couchbase-cxx-client/core/operations/management/user_upsert.hxx +1 -0
  191. package/deps/couchbase-cxx-client/core/operations/management/view_index_drop.cxx +2 -1
  192. package/deps/couchbase-cxx-client/core/operations/management/view_index_drop.hxx +1 -0
  193. package/deps/couchbase-cxx-client/core/operations/management/view_index_get.cxx +2 -1
  194. package/deps/couchbase-cxx-client/core/operations/management/view_index_get.hxx +1 -0
  195. package/deps/couchbase-cxx-client/core/operations/management/view_index_get_all.cxx +3 -1
  196. package/deps/couchbase-cxx-client/core/operations/management/view_index_get_all.hxx +2 -0
  197. package/deps/couchbase-cxx-client/core/operations/management/view_index_upsert.cxx +2 -1
  198. package/deps/couchbase-cxx-client/core/operations/management/view_index_upsert.hxx +1 -0
  199. package/deps/couchbase-cxx-client/core/origin.cxx +37 -17
  200. package/deps/couchbase-cxx-client/core/platform/base64.cc +1 -1
  201. package/deps/couchbase-cxx-client/core/platform/random.cc +2 -0
  202. package/deps/couchbase-cxx-client/core/platform/uuid.h +6 -6
  203. package/deps/couchbase-cxx-client/core/row_streamer.cxx +1 -1
  204. package/deps/couchbase-cxx-client/core/sasl/scram-sha/stringutils.cc +1 -1
  205. package/deps/couchbase-cxx-client/core/sasl/scram-sha/stringutils.h +4 -4
  206. package/deps/couchbase-cxx-client/core/topology/configuration.hxx +2 -0
  207. package/deps/couchbase-cxx-client/core/topology/configuration_json.hxx +8 -0
  208. package/deps/couchbase-cxx-client/core/tracing/constants.hxx +3 -0
  209. package/deps/couchbase-cxx-client/core/tracing/tracer_wrapper.cxx +87 -0
  210. package/deps/couchbase-cxx-client/core/tracing/tracer_wrapper.hxx +57 -0
  211. package/deps/couchbase-cxx-client/core/transactions/async_attempt_context.hxx +9 -21
  212. package/deps/couchbase-cxx-client/core/transactions/attempt_context.hxx +6 -33
  213. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.cxx +57 -56
  214. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.hxx +17 -18
  215. package/deps/couchbase-cxx-client/core/transactions/staged_mutation.cxx +2 -2
  216. package/deps/couchbase-cxx-client/core/transactions/transaction_context.cxx +2 -2
  217. package/deps/couchbase-cxx-client/core/transactions/transaction_get_result.hxx +0 -20
  218. package/deps/couchbase-cxx-client/core/transactions/transactions.cxx +2 -2
  219. package/deps/couchbase-cxx-client/core/utils/connection_string.cxx +128 -52
  220. package/deps/couchbase-cxx-client/couchbase/analytics_options.hxx +4 -3
  221. package/deps/couchbase-cxx-client/couchbase/codec/tao_json_serializer.hxx +1 -1
  222. package/deps/couchbase-cxx-client/couchbase/common_options.hxx +16 -1
  223. package/deps/couchbase-cxx-client/couchbase/metrics/otel_meter.hxx +16 -20
  224. package/deps/couchbase-cxx-client/couchbase/mutate_in_specs.hxx +2 -2
  225. package/deps/couchbase-cxx-client/couchbase/query_options.hxx +4 -3
  226. package/deps/couchbase-cxx-client/couchbase/search_options.hxx +1 -1
  227. package/dist/analyticsindexmanager.d.ts +98 -14
  228. package/dist/analyticsindexmanager.js +452 -411
  229. package/dist/binding.d.ts +53 -4
  230. package/dist/bindingutilities.d.ts +26 -1
  231. package/dist/bindingutilities.js +108 -1
  232. package/dist/couchbase.d.ts +3 -1
  233. package/dist/couchbase.js +2 -0
  234. package/dist/rangeScan.d.ts +1 -1
  235. package/dist/rangeScan.js +1 -1
  236. package/dist/transactions.d.ts +34 -3
  237. package/dist/transactions.js +25 -18
  238. package/dist/transcoders.d.ts +68 -0
  239. package/dist/transcoders.js +194 -1
  240. package/dist/usermanager.d.ts +14 -14
  241. package/dist/usermanager.js +178 -228
  242. package/dist/utilities.js +4 -6
  243. package/dist/utilities_internal.js +1 -2
  244. package/package.json +9 -8
  245. package/src/binding.cpp +13 -13
  246. package/src/connection.cpp +22 -0
  247. package/src/connection.hpp +12 -0
  248. package/src/connection_autogen.cpp +100 -0
  249. package/src/jstocbpp_autogen.hpp +315 -8
  250. package/src/jstocbpp_transactions.hpp +1 -2
  251. package/tools/gen-bindings-js.js +38 -3
  252. package/tools/gen-bindings-json.py +575 -328
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AnalyticsIndexManager = exports.AzureExternalAnalyticsLink = exports.S3ExternalAnalyticsLink = exports.CouchbaseRemoteAnalyticsLink = exports.AnalyticsLink = exports.CouchbaseAnalyticsEncryptionSettings = exports.AnalyticsIndex = exports.AnalyticsDataset = exports.AnalyticsEncryptionLevel = exports.AnalyticsLinkType = void 0;
4
4
  const errors_1 = require("./errors");
5
- const httpexecutor_1 = require("./httpexecutor");
5
+ const bindingutilities_1 = require("./bindingutilities");
6
6
  const utilities_1 = require("./utilities");
7
7
  /**
8
8
  * Represents the type of an analytics link.
@@ -102,19 +102,21 @@ class AnalyticsLink {
102
102
  */
103
103
  constructor() {
104
104
  this.linkType = '';
105
+ this.dataverse = '';
106
+ this.name = '';
105
107
  }
106
108
  /**
107
109
  * @internal
108
110
  */
109
111
  static _toHttpData(data) {
110
112
  if (data.linkType === AnalyticsLinkType.CouchbaseRemote) {
111
- return CouchbaseRemoteAnalyticsLink._toHttpData(data);
113
+ return CouchbaseRemoteAnalyticsLink._toHttpData(new CouchbaseRemoteAnalyticsLink(data));
112
114
  }
113
115
  else if (data.linkType === AnalyticsLinkType.S3External) {
114
- return S3ExternalAnalyticsLink._toHttpData(data);
116
+ return S3ExternalAnalyticsLink._toHttpData(new S3ExternalAnalyticsLink(data));
115
117
  }
116
118
  else if (data.linkType === AnalyticsLinkType.AzureBlobExternal) {
117
- return AzureExternalAnalyticsLink._toHttpData(data);
119
+ return AzureExternalAnalyticsLink._toHttpData(new AzureExternalAnalyticsLink(data));
118
120
  }
119
121
  else {
120
122
  throw new Error('invalid link type');
@@ -143,6 +145,39 @@ exports.AnalyticsLink = AnalyticsLink;
143
145
  * Provides information about a analytics remote Couchbase link.
144
146
  */
145
147
  class CouchbaseRemoteAnalyticsLink extends AnalyticsLink {
148
+ /**
149
+ * Validates the CouchbaseRemoteAnalyticsLink.
150
+ */
151
+ validate() {
152
+ if (!this.dataverse) {
153
+ throw new errors_1.InvalidArgumentError(new Error('Must provide a dataverse for the CouchbaseRemoteAnalyticsLink.'));
154
+ }
155
+ if (!this.name) {
156
+ throw new errors_1.InvalidArgumentError(new Error('Must provide a name for the CouchbaseRemoteAnalyticsLink.'));
157
+ }
158
+ if (!this.hostname) {
159
+ throw new errors_1.InvalidArgumentError(new Error('Must provide a hostname for the CouchbaseRemoteAnalyticsLink.'));
160
+ }
161
+ if (this.encryption) {
162
+ if ([AnalyticsEncryptionLevel.None, AnalyticsEncryptionLevel.Half].includes(this.encryption.encryptionLevel)) {
163
+ if (!this.username || !this.password) {
164
+ throw new errors_1.InvalidArgumentError(new Error('When encryption level is half or none, username and password must be set for the CouchbaseRemoteAnalyticsLink.'));
165
+ }
166
+ }
167
+ else {
168
+ if (!this.encryption.certificate ||
169
+ this.encryption.certificate.length == 0) {
170
+ throw new errors_1.InvalidArgumentError(new Error('When encryption level full, a certificate must be set for the CouchbaseRemoteAnalyticsLink.'));
171
+ }
172
+ const clientCertificateInvalid = !this.encryption.clientCertificate ||
173
+ this.encryption.clientCertificate.length == 0;
174
+ const clientKeyInvalid = !this.encryption.clientKey || this.encryption.clientKey.length == 0;
175
+ if (clientCertificateInvalid || clientKeyInvalid) {
176
+ throw new errors_1.InvalidArgumentError(new Error('When encryption level full, a client key and certificate must be set for the CouchbaseRemoteAnalyticsLink.'));
177
+ }
178
+ }
179
+ }
180
+ }
146
181
  /**
147
182
  * @internal
148
183
  */
@@ -159,61 +194,27 @@ class CouchbaseRemoteAnalyticsLink extends AnalyticsLink {
159
194
  /**
160
195
  * @internal
161
196
  */
162
- static _toHttpData(data) {
163
- let dvSpecific;
164
- if (data.dataverse.indexOf('/') !== -1) {
165
- const encDataverse = encodeURIComponent(data.dataverse);
166
- const encName = encodeURIComponent(data.name);
167
- dvSpecific = {
168
- httpPath: `/analytics/link/${encDataverse}/${encName}`,
169
- };
170
- }
171
- else {
172
- dvSpecific = {
173
- httpPath: `/analytics/link`,
174
- dataverse: data.dataverse,
175
- name: data.name,
176
- };
177
- }
197
+ static _toCppData(data) {
198
+ data.validate();
178
199
  return {
179
- type: 'couchbase',
180
- ...dvSpecific,
200
+ link_name: data.name,
201
+ dataverse: data.dataverse,
181
202
  hostname: data.hostname,
182
- username: data.username,
203
+ username: data.hostname,
183
204
  password: data.password,
184
- encryption: data.encryption ? data.encryption.encryptionLevel : undefined,
185
- certificate: data.encryption
186
- ? data.encryption.certificate
187
- ? data.encryption.certificate.toString()
188
- : undefined
189
- : undefined,
190
- clientCertificate: data.encryption
191
- ? data.encryption.clientCertificate
192
- ? data.encryption.clientCertificate.toString()
193
- : undefined
194
- : undefined,
195
- clientKey: data.encryption
196
- ? data.encryption.clientKey
197
- ? data.encryption.clientKey.toString()
198
- : undefined
199
- : undefined,
205
+ encryption: (0, bindingutilities_1.encryptionSettingsToCpp)(data.encryption),
200
206
  };
201
207
  }
202
208
  /**
203
209
  * @internal
204
210
  */
205
- static _fromHttpData(data) {
211
+ static _fromCppData(data) {
206
212
  return new CouchbaseRemoteAnalyticsLink({
207
213
  linkType: AnalyticsLinkType.CouchbaseRemote,
208
- dataverse: data.dataverse || data.scope,
209
- name: data.name,
210
- hostname: data.activeHostname,
211
- encryption: new CouchbaseAnalyticsEncryptionSettings({
212
- encryptionLevel: data.encryption,
213
- certificate: Buffer.from(data.certificate),
214
- clientCertificate: Buffer.from(data.clientCertificate),
215
- clientKey: Buffer.from(data.clientKey),
216
- }),
214
+ dataverse: data.dataverse,
215
+ name: data.link_name,
216
+ hostname: data.hostname,
217
+ encryption: (0, bindingutilities_1.encryptionSettingsFromCpp)(data.encryption),
217
218
  username: data.username,
218
219
  password: undefined,
219
220
  });
@@ -239,47 +240,53 @@ class S3ExternalAnalyticsLink extends AnalyticsLink {
239
240
  this.serviceEndpoint = data.serviceEndpoint;
240
241
  }
241
242
  /**
242
- * @internal
243
+ * Validates the S3ExternalAnalyticsLink.
243
244
  */
244
- static _toHttpData(data) {
245
- let dvSpecific;
246
- if (data.dataverse.indexOf('/') !== -1) {
247
- const encDataverse = encodeURIComponent(data.dataverse);
248
- const encName = encodeURIComponent(data.name);
249
- dvSpecific = {
250
- httpPath: `/analytics/link/${encDataverse}/${encName}`,
251
- };
245
+ validate() {
246
+ if (!this.dataverse) {
247
+ throw new errors_1.InvalidArgumentError(new Error('Must provide a dataverse for the S3ExternalAnalyticsLink.'));
252
248
  }
253
- else {
254
- dvSpecific = {
255
- httpPath: `/analytics/link`,
256
- dataverse: data.dataverse,
257
- name: data.name,
258
- };
249
+ if (!this.name) {
250
+ throw new errors_1.InvalidArgumentError(new Error('Must provide a name for the S3ExternalAnalyticsLink.'));
251
+ }
252
+ if (!this.accessKeyId) {
253
+ throw new errors_1.InvalidArgumentError(new Error('Must provide an accessKeyId for the S3ExternalAnalyticsLink.'));
254
+ }
255
+ if (!this.secretAccessKey) {
256
+ throw new errors_1.InvalidArgumentError(new Error('Must provide an secretAccessKey for the S3ExternalAnalyticsLink.'));
257
+ }
258
+ if (!this.region) {
259
+ throw new errors_1.InvalidArgumentError(new Error('Must provide an region for the S3ExternalAnalyticsLink.'));
259
260
  }
261
+ }
262
+ /**
263
+ * @internal
264
+ */
265
+ static _toCppData(data) {
266
+ data.validate();
260
267
  return {
261
- type: 's3',
262
- ...dvSpecific,
263
- accessKeyId: data.accessKeyId,
264
- secretAccessKey: data.secretAccessKey,
268
+ link_name: data.name,
269
+ dataverse: data.dataverse,
270
+ access_key_id: data.accessKeyId,
271
+ secret_access_key: data.secretAccessKey,
272
+ session_token: data.sessionToken,
265
273
  region: data.region,
266
- sessionToken: data.sessionToken,
267
- serviceEndpoint: data.serviceEndpoint,
274
+ service_endpoint: data.serviceEndpoint,
268
275
  };
269
276
  }
270
277
  /**
271
278
  * @internal
272
279
  */
273
- static _fromHttpData(data) {
280
+ static _fromCppData(data) {
274
281
  return new S3ExternalAnalyticsLink({
282
+ name: data.link_name,
275
283
  linkType: AnalyticsLinkType.S3External,
276
- dataverse: data.dataverse || data.scope,
277
- name: data.name,
278
- accessKeyId: data.accessKeyId,
284
+ dataverse: data.dataverse,
285
+ accessKeyId: data.access_key_id,
279
286
  secretAccessKey: undefined,
280
- region: data.region,
281
287
  sessionToken: undefined,
282
- serviceEndpoint: data.serviceEndpoint,
288
+ region: data.region,
289
+ serviceEndpoint: data.service_endpoint,
283
290
  });
284
291
  }
285
292
  }
@@ -304,49 +311,54 @@ class AzureExternalAnalyticsLink extends AnalyticsLink {
304
311
  this.endpointSuffix = data.endpointSuffix;
305
312
  }
306
313
  /**
307
- * @internal
314
+ * Validates the AzureExternalAnalyticsLink.
308
315
  */
309
- static _toHttpData(data) {
310
- let dvSpecific;
311
- if (data.dataverse.indexOf('/') !== -1) {
312
- const encDataverse = encodeURIComponent(data.dataverse);
313
- const encName = encodeURIComponent(data.name);
314
- dvSpecific = {
315
- httpPath: `/analytics/link/${encDataverse}/${encName}`,
316
- };
316
+ validate() {
317
+ if (!this.dataverse) {
318
+ throw new errors_1.InvalidArgumentError(new Error('Must provide a dataverse for the AzureExternalAnalyticsLink.'));
317
319
  }
318
- else {
319
- dvSpecific = {
320
- httpPath: `/analytics/link`,
321
- dataverse: data.dataverse,
322
- name: data.name,
323
- };
320
+ if (!this.name) {
321
+ throw new errors_1.InvalidArgumentError(new Error('Must provide a name for the AzureExternalAnalyticsLink.'));
324
322
  }
323
+ if (!this.connectionString) {
324
+ const missingAcctNameAndKey = !(this.accountName && this.accountKey);
325
+ const missingAcctNameAndSharedAccessSignature = !(this.accountName && this.sharedAccessSignature);
326
+ if (missingAcctNameAndKey && missingAcctNameAndSharedAccessSignature) {
327
+ throw new errors_1.InvalidArgumentError(new Error('If not providing connectionString, accountName and either accountKey' +
328
+ ' or sharedAccessSignature must be provided for the AzureExternalAnalyticsLink.'));
329
+ }
330
+ }
331
+ }
332
+ /**
333
+ * @internal
334
+ */
335
+ static _toCppData(data) {
336
+ data.validate();
325
337
  return {
326
- type: 'azure',
327
- ...dvSpecific,
328
- connectionString: data.connectionString,
329
- accountName: data.accountName,
330
- accountKey: data.accountKey,
331
- sharedAccessSignature: data.sharedAccessSignature,
332
- blobEndpoint: data.blobEndpoint,
333
- endpointSuffix: data.endpointSuffix,
338
+ link_name: data.name,
339
+ dataverse: data.dataverse,
340
+ connection_string: data.connectionString,
341
+ account_name: data.accountName,
342
+ account_key: data.accountKey,
343
+ shared_access_signature: data.sharedAccessSignature,
344
+ blob_endpoint: data.blobEndpoint,
345
+ endpoint_suffix: data.endpointSuffix,
334
346
  };
335
347
  }
336
348
  /**
337
349
  * @internal
338
350
  */
339
- static _fromHttpData(data) {
351
+ static _fromCppData(data) {
340
352
  return new AzureExternalAnalyticsLink({
353
+ name: data.link_name,
341
354
  linkType: AnalyticsLinkType.AzureBlobExternal,
342
- dataverse: data.dataverse || data.scope,
343
- name: data.name,
355
+ dataverse: data.dataverse,
344
356
  connectionString: undefined,
345
- accountName: data.accountName,
357
+ accountName: data.account_name,
346
358
  accountKey: undefined,
347
359
  sharedAccessSignature: undefined,
348
- blobEndpoint: data.blobEndpoint,
349
- endpointSuffix: data.endpointSuffix,
360
+ blobEndpoint: data.blob_endpoint,
361
+ endpointSuffix: data.endpoint_suffix,
350
362
  });
351
363
  }
352
364
  }
@@ -364,9 +376,6 @@ class AnalyticsIndexManager {
364
376
  constructor(cluster) {
365
377
  this._cluster = cluster;
366
378
  }
367
- get _http() {
368
- return new httpexecutor_1.HttpExecutor(this._cluster.conn);
369
- }
370
379
  /**
371
380
  * Creates a new dataverse.
372
381
  *
@@ -382,25 +391,20 @@ class AnalyticsIndexManager {
382
391
  if (!options) {
383
392
  options = {};
384
393
  }
385
- let qs = '';
386
- qs += 'CREATE DATAVERSE';
387
- qs += ' `' + dataverseName.split('/').join('`.`') + '`';
388
- if (options.ignoreIfExists) {
389
- qs += ' IF NOT EXISTS';
390
- }
391
394
  const timeout = options.timeout || this._cluster.managementTimeout;
392
- return utilities_1.PromiseHelper.wrapAsync(async () => {
393
- try {
394
- await this._cluster.analyticsQuery(qs, {
395
- timeout: timeout,
396
- });
397
- }
398
- catch (err) {
399
- if (err instanceof errors_1.DataverseExistsError) {
400
- throw err;
395
+ const ignoreIfExists = options.ignoreIfExists || false;
396
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
397
+ this._cluster.conn.managementAnalyticsDataverseCreate({
398
+ dataverse_name: dataverseName,
399
+ timeout: timeout,
400
+ ignore_if_exists: ignoreIfExists,
401
+ }, (cppErr) => {
402
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
403
+ if (err) {
404
+ return wrapCallback(err, null);
401
405
  }
402
- throw new errors_1.CouchbaseError('failed to create dataverse', err);
403
- }
406
+ wrapCallback(err);
407
+ });
404
408
  }, callback);
405
409
  }
406
410
  /**
@@ -418,25 +422,20 @@ class AnalyticsIndexManager {
418
422
  if (!options) {
419
423
  options = {};
420
424
  }
421
- let qs = '';
422
- qs += 'DROP DATAVERSE';
423
- qs += ' `' + dataverseName.split('/').join('`.`') + '`';
424
- if (options.ignoreIfNotExists) {
425
- qs += ' IF EXISTS';
426
- }
427
425
  const timeout = options.timeout || this._cluster.managementTimeout;
428
- return utilities_1.PromiseHelper.wrapAsync(async () => {
429
- try {
430
- await this._cluster.analyticsQuery(qs, {
431
- timeout: timeout,
432
- });
433
- }
434
- catch (err) {
435
- if (err instanceof errors_1.DataverseNotFoundError) {
436
- throw err;
426
+ const ignoreIfNotExists = options.ignoreIfNotExists || false;
427
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
428
+ this._cluster.conn.managementAnalyticsDataverseDrop({
429
+ dataverse_name: dataverseName,
430
+ timeout: timeout,
431
+ ignore_if_does_not_exist: ignoreIfNotExists,
432
+ }, (cppErr) => {
433
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
434
+ if (err) {
435
+ return wrapCallback(err, null);
437
436
  }
438
- throw new errors_1.CouchbaseError('failed to drop dataverse', err);
439
- }
437
+ wrapCallback(err);
438
+ });
440
439
  }, callback);
441
440
  }
442
441
  /**
@@ -455,39 +454,24 @@ class AnalyticsIndexManager {
455
454
  if (!options) {
456
455
  options = {};
457
456
  }
458
- let qs = '';
459
- qs += 'CREATE DATASET';
460
- if (options.ignoreIfExists) {
461
- qs += ' IF NOT EXISTS';
462
- }
463
- if (options.dataverseName) {
464
- qs +=
465
- ' `' +
466
- options.dataverseName.split('/').join('`.`') +
467
- '`.`' +
468
- datasetName +
469
- '`';
470
- }
471
- else {
472
- qs += ' `' + datasetName + '`';
473
- }
474
- qs += ' ON `' + bucketName + '`';
475
- if (options.condition) {
476
- qs += ' WHERE ' + options.condition;
477
- }
457
+ const dataverseName = options.dataverseName || 'Default';
458
+ const ignoreIfExists = options.ignoreIfExists || false;
478
459
  const timeout = options.timeout || this._cluster.managementTimeout;
479
- return utilities_1.PromiseHelper.wrapAsync(async () => {
480
- try {
481
- await this._cluster.analyticsQuery(qs, {
482
- timeout: timeout,
483
- });
484
- }
485
- catch (err) {
486
- if (err instanceof errors_1.DatasetExistsError) {
487
- throw err;
460
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
461
+ this._cluster.conn.managementAnalyticsDatasetCreate({
462
+ dataverse_name: dataverseName,
463
+ dataset_name: datasetName,
464
+ bucket_name: bucketName,
465
+ condition: options === null || options === void 0 ? void 0 : options.condition,
466
+ timeout: timeout,
467
+ ignore_if_exists: ignoreIfExists,
468
+ }, (cppErr) => {
469
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
470
+ if (err) {
471
+ return wrapCallback(err, null);
488
472
  }
489
- throw new errors_1.CouchbaseError('failed to create dataset', err);
490
- }
473
+ wrapCallback(err);
474
+ });
491
475
  }, callback);
492
476
  }
493
477
  /**
@@ -505,35 +489,22 @@ class AnalyticsIndexManager {
505
489
  if (!options) {
506
490
  options = {};
507
491
  }
508
- let qs = '';
509
- qs += 'DROP DATASET';
510
- if (options.dataverseName) {
511
- qs +=
512
- ' `' +
513
- options.dataverseName.split('/').join('`.`') +
514
- '`.`' +
515
- datasetName +
516
- '`';
517
- }
518
- else {
519
- qs += ' `' + datasetName + '`';
520
- }
521
- if (options.ignoreIfNotExists) {
522
- qs += ' IF EXISTS';
523
- }
492
+ const dataverseName = options.dataverseName || 'Default';
493
+ const ignoreIfNotExists = options.ignoreIfNotExists || false;
524
494
  const timeout = options.timeout || this._cluster.managementTimeout;
525
- return utilities_1.PromiseHelper.wrapAsync(async () => {
526
- try {
527
- await this._cluster.analyticsQuery(qs, {
528
- timeout: timeout,
529
- });
530
- }
531
- catch (err) {
532
- if (err instanceof errors_1.DatasetNotFoundError) {
533
- throw err;
495
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
496
+ this._cluster.conn.managementAnalyticsDatasetDrop({
497
+ dataverse_name: dataverseName,
498
+ dataset_name: datasetName,
499
+ timeout: timeout,
500
+ ignore_if_does_not_exist: ignoreIfNotExists,
501
+ }, (cppErr) => {
502
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
503
+ if (err) {
504
+ return wrapCallback(err, null);
534
505
  }
535
- throw new errors_1.CouchbaseError('failed to drop dataset', err);
536
- }
506
+ wrapCallback(err);
507
+ });
537
508
  }, callback);
538
509
  }
539
510
  /**
@@ -550,19 +521,23 @@ class AnalyticsIndexManager {
550
521
  if (!options) {
551
522
  options = {};
552
523
  }
553
- const qs = 'SELECT d.* FROM `Metadata`.`Dataset` d WHERE d.DataverseName <> "Metadata"';
554
524
  const timeout = options.timeout || this._cluster.managementTimeout;
555
- return utilities_1.PromiseHelper.wrapAsync(async () => {
556
- const res = await this._cluster.analyticsQuery(qs, {
525
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
526
+ this._cluster.conn.managementAnalyticsDatasetGetAll({
557
527
  timeout: timeout,
528
+ }, (cppErr, resp) => {
529
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
530
+ if (err) {
531
+ return wrapCallback(err, null);
532
+ }
533
+ const dataSets = resp.datasets.map((dataset) => new AnalyticsDataset({
534
+ name: dataset.name,
535
+ dataverseName: dataset.dataverse_name,
536
+ linkName: dataset.link_name,
537
+ bucketName: dataset.bucket_name,
538
+ }));
539
+ wrapCallback(null, dataSets);
558
540
  });
559
- const datasets = res.rows.map((row) => new AnalyticsDataset({
560
- name: row.DatasetName,
561
- dataverseName: row.DataverseName,
562
- linkName: row.LinkName,
563
- bucketName: row.BucketName,
564
- }));
565
- return datasets;
566
541
  }, callback);
567
542
  }
568
543
  /**
@@ -582,32 +557,23 @@ class AnalyticsIndexManager {
582
557
  if (!options) {
583
558
  options = {};
584
559
  }
585
- let qs = '';
586
- qs += 'CREATE INDEX';
587
- qs += ' `' + indexName + '`';
588
- if (options.ignoreIfExists) {
589
- qs += ' IF NOT EXISTS';
590
- }
591
- if (options.dataverseName) {
592
- qs +=
593
- ' ON `' +
594
- options.dataverseName.split('/').join('`.`') +
595
- '`.`' +
596
- datasetName +
597
- '`';
598
- }
599
- else {
600
- qs += ' ON `' + datasetName + '`';
601
- }
602
- qs += ' (';
603
- qs += Object.keys(fields)
604
- .map((i) => '`' + i + '`: ' + fields[i])
605
- .join(', ');
606
- qs += ')';
560
+ const dataverseName = options.dataverseName || 'Default';
561
+ const ignoreIfExists = options.ignoreIfExists || false;
607
562
  const timeout = options.timeout || this._cluster.managementTimeout;
608
- return utilities_1.PromiseHelper.wrapAsync(async () => {
609
- await this._cluster.analyticsQuery(qs, {
563
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
564
+ this._cluster.conn.managementAnalyticsIndexCreate({
565
+ dataverse_name: dataverseName,
566
+ dataset_name: datasetName,
567
+ index_name: indexName,
568
+ fields: fields,
610
569
  timeout: timeout,
570
+ ignore_if_exists: ignoreIfExists,
571
+ }, (cppErr) => {
572
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
573
+ if (err) {
574
+ return wrapCallback(err, null);
575
+ }
576
+ wrapCallback(err);
611
577
  });
612
578
  }, callback);
613
579
  }
@@ -627,27 +593,22 @@ class AnalyticsIndexManager {
627
593
  if (!options) {
628
594
  options = {};
629
595
  }
630
- let qs = '';
631
- qs += 'DROP INDEX';
632
- if (options.dataverseName) {
633
- qs +=
634
- ' `' +
635
- options.dataverseName.split('/').join('`.`') +
636
- '`.`' +
637
- datasetName +
638
- '`';
639
- }
640
- else {
641
- qs += ' `' + datasetName + '`';
642
- }
643
- qs += '.`' + indexName + '`';
644
- if (options.ignoreIfNotExists) {
645
- qs += ' IF EXISTS';
646
- }
596
+ const dataverseName = options.dataverseName || 'Default';
597
+ const ignoreIfNotExists = options.ignoreIfNotExists || false;
647
598
  const timeout = options.timeout || this._cluster.managementTimeout;
648
- return utilities_1.PromiseHelper.wrapAsync(async () => {
649
- await this._cluster.analyticsQuery(qs, {
599
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
600
+ this._cluster.conn.managementAnalyticsIndexDrop({
601
+ dataverse_name: dataverseName,
602
+ dataset_name: datasetName,
603
+ index_name: indexName,
650
604
  timeout: timeout,
605
+ ignore_if_does_not_exist: ignoreIfNotExists,
606
+ }, (cppErr) => {
607
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
608
+ if (err) {
609
+ return wrapCallback(err, null);
610
+ }
611
+ wrapCallback(err);
651
612
  });
652
613
  }, callback);
653
614
  }
@@ -665,29 +626,41 @@ class AnalyticsIndexManager {
665
626
  if (!options) {
666
627
  options = {};
667
628
  }
668
- const qs = 'SELECT d.* FROM `Metadata`.`Index` d WHERE d.DataverseName <> "Metadata"';
669
629
  const timeout = options.timeout || this._cluster.managementTimeout;
670
- return utilities_1.PromiseHelper.wrapAsync(async () => {
671
- const res = await this._cluster.analyticsQuery(qs, {
630
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
631
+ this._cluster.conn.managementAnalyticsIndexGetAll({
672
632
  timeout: timeout,
633
+ }, (cppErr, resp) => {
634
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
635
+ if (err) {
636
+ return wrapCallback(err, null);
637
+ }
638
+ const indexes = resp.indexes.map((index) => new AnalyticsIndex({
639
+ name: index.name,
640
+ dataverseName: index.dataverse_name,
641
+ datasetName: index.dataset_name,
642
+ isPrimary: index.is_primary,
643
+ }));
644
+ wrapCallback(null, indexes);
673
645
  });
674
- const indexes = res.rows.map((row) => new AnalyticsIndex({
675
- name: row.IndexName,
676
- datasetName: row.DatasetName,
677
- dataverseName: row.DataverseName,
678
- isPrimary: row.IsPrimary,
679
- }));
680
- return indexes;
681
646
  }, callback);
682
647
  }
683
648
  /**
684
- * Connects a not yet connected link.
685
- *
686
- * @param linkName The name of the link to connect.
687
- * @param options Optional parameters for this operation.
688
- * @param callback A node-style callback to be invoked after execution.
649
+ * @internal
650
+ */
651
+ async connectLink() {
652
+ if (typeof arguments[0] === 'string') {
653
+ return this._connectLinkDeprecated(arguments[0], arguments[1], arguments[2]);
654
+ }
655
+ else {
656
+ return this._connectLink(arguments[0], arguments[1]);
657
+ }
658
+ }
659
+ // TODO(JSCBC-1293): Remove deprecated path
660
+ /**
661
+ * @internal
689
662
  */
690
- async connectLink(linkName, options, callback) {
663
+ async _connectLinkDeprecated(linkStr, options, callback) {
691
664
  if (options instanceof Function) {
692
665
  callback = arguments[1];
693
666
  options = undefined;
@@ -695,8 +668,12 @@ class AnalyticsIndexManager {
695
668
  if (!options) {
696
669
  options = {};
697
670
  }
698
- const qs = 'CONNECT LINK ' + linkName;
671
+ const force = options.force || false;
699
672
  const timeout = options.timeout || this._cluster.managementTimeout;
673
+ let qs = 'CONNECT LINK ' + linkStr;
674
+ if (force) {
675
+ qs += ' WITH {"force": true}';
676
+ }
700
677
  return utilities_1.PromiseHelper.wrapAsync(async () => {
701
678
  await this._cluster.analyticsQuery(qs, {
702
679
  timeout: timeout,
@@ -704,13 +681,9 @@ class AnalyticsIndexManager {
704
681
  }, callback);
705
682
  }
706
683
  /**
707
- * Disconnects a previously connected link.
708
- *
709
- * @param linkName The name of the link to disconnect.
710
- * @param options Optional parameters for this operation.
711
- * @param callback A node-style callback to be invoked after execution.
684
+ * @internal
712
685
  */
713
- async disconnectLink(linkName, options, callback) {
686
+ async _connectLink(options, callback) {
714
687
  if (options instanceof Function) {
715
688
  callback = arguments[1];
716
689
  options = undefined;
@@ -718,7 +691,49 @@ class AnalyticsIndexManager {
718
691
  if (!options) {
719
692
  options = {};
720
693
  }
721
- const qs = 'DISCONNECT LINK ' + linkName;
694
+ const dataverseName = options.dataverseName || 'Default';
695
+ const linkName = options.linkName || 'Local';
696
+ const force = options.force || false;
697
+ const timeout = options.timeout || this._cluster.managementTimeout;
698
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
699
+ this._cluster.conn.managementAnalyticsLinkConnect({
700
+ dataverse_name: dataverseName,
701
+ link_name: linkName,
702
+ timeout: timeout,
703
+ force: force,
704
+ }, (cppErr) => {
705
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
706
+ if (err) {
707
+ return wrapCallback(err, null);
708
+ }
709
+ wrapCallback(err);
710
+ });
711
+ }, callback);
712
+ }
713
+ /**
714
+ * @internal
715
+ */
716
+ async disconnectLink() {
717
+ if (typeof arguments[0] === 'string') {
718
+ return this._disconnectLinkDeprecated(arguments[0], arguments[1], arguments[2]);
719
+ }
720
+ else {
721
+ return this._disconnectLink(arguments[0], arguments[1]);
722
+ }
723
+ }
724
+ // TODO(JSCBC-1293): Remove deprecated path
725
+ /**
726
+ * @internal
727
+ */
728
+ async _disconnectLinkDeprecated(linkStr, options, callback) {
729
+ if (options instanceof Function) {
730
+ callback = arguments[1];
731
+ options = undefined;
732
+ }
733
+ if (!options) {
734
+ options = {};
735
+ }
736
+ const qs = 'DISCONNECT LINK ' + linkStr;
722
737
  const timeout = options.timeout || this._cluster.managementTimeout;
723
738
  return utilities_1.PromiseHelper.wrapAsync(async () => {
724
739
  await this._cluster.analyticsQuery(qs, {
@@ -726,6 +741,34 @@ class AnalyticsIndexManager {
726
741
  });
727
742
  }, callback);
728
743
  }
744
+ /**
745
+ * @internal
746
+ */
747
+ async _disconnectLink(options, callback) {
748
+ if (options instanceof Function) {
749
+ callback = arguments[1];
750
+ options = undefined;
751
+ }
752
+ if (!options) {
753
+ options = {};
754
+ }
755
+ const dataverseName = options.dataverseName || 'Default';
756
+ const linkName = options.linkName || 'Local';
757
+ const timeout = options.timeout || this._cluster.managementTimeout;
758
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
759
+ this._cluster.conn.managementAnalyticsLinkDisconnect({
760
+ dataverse_name: dataverseName,
761
+ link_name: linkName,
762
+ timeout: timeout,
763
+ }, (cppErr) => {
764
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
765
+ if (err) {
766
+ return wrapCallback(err, null);
767
+ }
768
+ wrapCallback(err);
769
+ });
770
+ }, callback);
771
+ }
729
772
  /**
730
773
  * Returns a list of all pending mutations.
731
774
  *
@@ -741,18 +784,19 @@ class AnalyticsIndexManager {
741
784
  options = {};
742
785
  }
743
786
  const timeout = options.timeout || this._cluster.managementTimeout;
744
- return utilities_1.PromiseHelper.wrapAsync(async () => {
745
- const res = await this._http.request({
746
- type: httpexecutor_1.HttpServiceType.Analytics,
747
- method: httpexecutor_1.HttpMethod.Get,
748
- path: `/analytics/node/agg/stats/remaining`,
787
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
788
+ this._cluster.conn.managementAnalyticsGetPendingMutations({
749
789
  timeout: timeout,
790
+ }, (cppErr, resp) => {
791
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
792
+ if (err) {
793
+ return wrapCallback(err, null);
794
+ }
795
+ const stats = {
796
+ stats: resp.stats,
797
+ };
798
+ wrapCallback(null, stats);
750
799
  });
751
- if (res.statusCode !== 200) {
752
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
753
- throw new errors_1.CouchbaseError('failed to get pending mutations', undefined, errCtx);
754
- }
755
- return JSON.parse(res.body.toString());
756
800
  }, callback);
757
801
  }
758
802
  /**
@@ -771,31 +815,51 @@ class AnalyticsIndexManager {
771
815
  options = {};
772
816
  }
773
817
  const timeout = options.timeout || this._cluster.managementTimeout;
774
- return utilities_1.PromiseHelper.wrapAsync(async () => {
775
- const linkData = AnalyticsLink._toHttpData(link);
776
- const res = await this._http.request({
777
- type: httpexecutor_1.HttpServiceType.Analytics,
778
- method: httpexecutor_1.HttpMethod.Post,
779
- path: linkData.httpPath,
780
- contentType: 'application/x-www-form-urlencoded',
781
- body: (0, utilities_1.cbQsStringify)({
782
- linkData,
783
- httpPath: undefined,
784
- }),
785
- timeout: timeout,
786
- });
787
- if (res.statusCode !== 200) {
788
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
789
- const errText = res.body.toString().toLowerCase();
790
- if (errText.includes('24055')) {
791
- throw new errors_1.LinkExistsError(undefined, errCtx);
792
- }
793
- else if (errText.includes('24034')) {
794
- throw new errors_1.DataverseNotFoundError(undefined, errCtx);
795
- }
796
- throw new errors_1.CouchbaseError('failed to create link', undefined, errCtx);
797
- }
798
- }, callback);
818
+ if (link.linkType == AnalyticsLinkType.CouchbaseRemote) {
819
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
820
+ this._cluster.conn.managementAnalyticsLinkCreateCouchbaseRemoteLink({
821
+ link: CouchbaseRemoteAnalyticsLink._toCppData(new CouchbaseRemoteAnalyticsLink(link)),
822
+ timeout: timeout,
823
+ }, (cppErr) => {
824
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
825
+ if (err) {
826
+ return wrapCallback(err, null);
827
+ }
828
+ wrapCallback(err);
829
+ });
830
+ }, callback);
831
+ }
832
+ else if (link.linkType == AnalyticsLinkType.S3External) {
833
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
834
+ this._cluster.conn.managementAnalyticsLinkCreateS3ExternalLink({
835
+ link: S3ExternalAnalyticsLink._toCppData(new S3ExternalAnalyticsLink(link)),
836
+ timeout: timeout,
837
+ }, (cppErr) => {
838
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
839
+ if (err) {
840
+ return wrapCallback(err, null);
841
+ }
842
+ wrapCallback(err);
843
+ });
844
+ }, callback);
845
+ }
846
+ else if (link.linkType == AnalyticsLinkType.AzureBlobExternal) {
847
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
848
+ this._cluster.conn.managementAnalyticsLinkCreateAzureBlobExternalLink({
849
+ link: AzureExternalAnalyticsLink._toCppData(new AzureExternalAnalyticsLink(link)),
850
+ timeout: timeout,
851
+ }, (cppErr) => {
852
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
853
+ if (err) {
854
+ return wrapCallback(err, null);
855
+ }
856
+ wrapCallback(err);
857
+ });
858
+ }, callback);
859
+ }
860
+ else {
861
+ throw new Error('invalid link type');
862
+ }
799
863
  }
800
864
  /**
801
865
  * Replaces an existing analytics remote link.
@@ -813,31 +877,51 @@ class AnalyticsIndexManager {
813
877
  options = {};
814
878
  }
815
879
  const timeout = options.timeout || this._cluster.managementTimeout;
816
- return utilities_1.PromiseHelper.wrapAsync(async () => {
817
- const linkData = AnalyticsLink._toHttpData(link);
818
- const res = await this._http.request({
819
- type: httpexecutor_1.HttpServiceType.Analytics,
820
- method: httpexecutor_1.HttpMethod.Put,
821
- path: linkData.httpPath,
822
- contentType: 'application/x-www-form-urlencoded',
823
- body: (0, utilities_1.cbQsStringify)({
824
- linkData,
825
- httpPath: undefined,
826
- }),
827
- timeout: timeout,
828
- });
829
- if (res.statusCode !== 200) {
830
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
831
- const errText = res.body.toString().toLowerCase();
832
- if (errText.includes('24055')) {
833
- throw new errors_1.LinkExistsError(undefined, errCtx);
834
- }
835
- else if (errText.includes('24034')) {
836
- throw new errors_1.DataverseNotFoundError(undefined, errCtx);
837
- }
838
- throw new errors_1.CouchbaseError('failed to replace link', undefined, errCtx);
839
- }
840
- }, callback);
880
+ if (link.linkType == AnalyticsLinkType.CouchbaseRemote) {
881
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
882
+ this._cluster.conn.managementAnalyticsLinkReplaceCouchbaseRemoteLink({
883
+ link: CouchbaseRemoteAnalyticsLink._toCppData(new CouchbaseRemoteAnalyticsLink(link)),
884
+ timeout: timeout,
885
+ }, (cppErr) => {
886
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
887
+ if (err) {
888
+ return wrapCallback(err, null);
889
+ }
890
+ wrapCallback(err);
891
+ });
892
+ }, callback);
893
+ }
894
+ else if (link.linkType == AnalyticsLinkType.S3External) {
895
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
896
+ this._cluster.conn.managementAnalyticsLinkReplaceS3ExternalLink({
897
+ link: S3ExternalAnalyticsLink._toCppData(new S3ExternalAnalyticsLink(link)),
898
+ timeout: timeout,
899
+ }, (cppErr) => {
900
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
901
+ if (err) {
902
+ return wrapCallback(err, null);
903
+ }
904
+ wrapCallback(err);
905
+ });
906
+ }, callback);
907
+ }
908
+ else if (link.linkType == AnalyticsLinkType.AzureBlobExternal) {
909
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
910
+ this._cluster.conn.managementAnalyticsLinkReplaceAzureBlobExternalLink({
911
+ link: AzureExternalAnalyticsLink._toCppData(new AzureExternalAnalyticsLink(link)),
912
+ timeout: timeout,
913
+ }, (cppErr) => {
914
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
915
+ if (err) {
916
+ return wrapCallback(err, null);
917
+ }
918
+ wrapCallback(err);
919
+ });
920
+ }, callback);
921
+ }
922
+ else {
923
+ throw new Error('invalid link type');
924
+ }
841
925
  }
842
926
  /**
843
927
  * Drops an existing analytics remote link.
@@ -856,41 +940,18 @@ class AnalyticsIndexManager {
856
940
  options = {};
857
941
  }
858
942
  const timeout = options.timeout || this._cluster.managementTimeout;
859
- return utilities_1.PromiseHelper.wrapAsync(async () => {
860
- let httpPath;
861
- let httpParams;
862
- if (dataverseName.indexOf('/') !== -1) {
863
- const encDataverse = encodeURIComponent(dataverseName);
864
- const encName = encodeURIComponent(linkName);
865
- httpPath = `/analytics/link/${encDataverse}/${encName}`;
866
- httpParams = {};
867
- }
868
- else {
869
- httpPath = `/analytics/link`;
870
- httpParams = {
871
- dataverse: dataverseName,
872
- name: linkName,
873
- };
874
- }
875
- const res = await this._http.request({
876
- type: httpexecutor_1.HttpServiceType.Analytics,
877
- method: httpexecutor_1.HttpMethod.Delete,
878
- path: httpPath,
879
- contentType: 'application/x-www-form-urlencoded',
880
- body: (0, utilities_1.cbQsStringify)(httpParams),
943
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
944
+ this._cluster.conn.managementAnalyticsLinkDrop({
945
+ dataverse_name: dataverseName,
946
+ link_name: linkName,
881
947
  timeout: timeout,
882
- });
883
- if (res.statusCode !== 200) {
884
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
885
- const errText = res.body.toString().toLowerCase();
886
- if (errText.includes('24055')) {
887
- throw new errors_1.LinkExistsError(undefined, errCtx);
888
- }
889
- else if (errText.includes('24034')) {
890
- throw new errors_1.DataverseNotFoundError(undefined, errCtx);
948
+ }, (cppErr) => {
949
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
950
+ if (err) {
951
+ return wrapCallback(err, null);
891
952
  }
892
- throw new errors_1.CouchbaseError('failed to delete link', undefined, errCtx);
893
- }
953
+ wrapCallback(err);
954
+ });
894
955
  }, callback);
895
956
  }
896
957
  /**
@@ -911,49 +972,29 @@ class AnalyticsIndexManager {
911
972
  const linkName = options.name;
912
973
  const linkType = options.linkType;
913
974
  const timeout = options.timeout || this._cluster.managementTimeout;
914
- return utilities_1.PromiseHelper.wrapAsync(async () => {
915
- let httpPath;
916
- if (dataverseName && dataverseName.indexOf('/') !== -1) {
917
- const encDataverse = encodeURIComponent(dataverseName);
918
- httpPath = `/analytics/link/${encDataverse}`;
919
- if (linkName) {
920
- const encName = encodeURIComponent(linkName);
921
- httpPath += `/${encName}`;
922
- }
923
- httpPath += '?';
924
- if (linkType) {
925
- httpPath += `type=${linkType}&`;
926
- }
927
- }
928
- else {
929
- httpPath = `/analytics/link?`;
930
- if (dataverseName) {
931
- httpPath += `dataverse=${dataverseName}&`;
932
- if (linkName) {
933
- httpPath += `dataverse=${linkName}&`;
934
- }
935
- }
936
- if (linkType) {
937
- httpPath += `type=${linkType}&`;
938
- }
939
- }
940
- const res = await this._http.request({
941
- type: httpexecutor_1.HttpServiceType.Analytics,
942
- method: httpexecutor_1.HttpMethod.Get,
943
- path: httpPath,
975
+ return utilities_1.PromiseHelper.wrap((wrapCallback) => {
976
+ this._cluster.conn.managementAnalyticsLinkGetAll({
977
+ link_type: linkType,
978
+ link_name: linkName,
979
+ dataverse_name: dataverseName,
944
980
  timeout: timeout,
945
- });
946
- if (res.statusCode !== 200) {
947
- const errCtx = httpexecutor_1.HttpExecutor.errorContextFromResponse(res);
948
- const errText = res.body.toString().toLowerCase();
949
- if (errText.includes('24034')) {
950
- throw new errors_1.DataverseNotFoundError(undefined, errCtx);
981
+ }, (cppErr, resp) => {
982
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
983
+ if (err) {
984
+ return wrapCallback(err, null);
951
985
  }
952
- throw new errors_1.CouchbaseError('failed to get links', undefined, errCtx);
953
- }
954
- const linksData = JSON.parse(res.body.toString());
955
- const links = linksData.map((linkData) => AnalyticsLink._fromHttpData(linkData));
956
- return links;
986
+ const links = [];
987
+ resp.couchbase.forEach((link) => {
988
+ links.push(CouchbaseRemoteAnalyticsLink._fromCppData(link));
989
+ });
990
+ resp.s3.forEach((link) => {
991
+ links.push(S3ExternalAnalyticsLink._fromCppData(link));
992
+ });
993
+ resp.azure_blob.forEach((link) => {
994
+ links.push(AzureExternalAnalyticsLink._fromCppData(link));
995
+ });
996
+ wrapCallback(null, links);
997
+ });
957
998
  }, callback);
958
999
  }
959
1000
  }