couchbase 4.6.1 → 4.7.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (312) hide show
  1. package/CMakeLists.txt +2 -1
  2. package/deps/couchbase-cxx-cache/mozilla-ca-bundle.crt +23 -5
  3. package/deps/couchbase-cxx-cache/mozilla-ca-bundle.sha256 +1 -1
  4. package/deps/couchbase-cxx-client/CMakeLists.txt +24 -11
  5. package/deps/couchbase-cxx-client/README.md +2 -2
  6. package/deps/couchbase-cxx-client/cmake/APKBUILD.in +17 -1
  7. package/deps/couchbase-cxx-client/cmake/Bundler.cmake +9 -1
  8. package/deps/couchbase-cxx-client/cmake/Cache.cmake +48 -19
  9. package/deps/couchbase-cxx-client/cmake/CompilerOptions.cmake +3 -1
  10. package/deps/couchbase-cxx-client/cmake/OpenSSL.cmake +10 -2
  11. package/deps/couchbase-cxx-client/cmake/Packaging.cmake +48 -8
  12. package/deps/couchbase-cxx-client/cmake/ThirdPartyDependencies.cmake +41 -0
  13. package/deps/couchbase-cxx-client/cmake/build_config.hxx.in +2 -0
  14. package/deps/couchbase-cxx-client/cmake/couchbase-cxx-client.spec.in +18 -0
  15. package/deps/couchbase-cxx-client/cmake/debian/control +6 -1
  16. package/deps/couchbase-cxx-client/cmake/debian/rules +1 -0
  17. package/deps/couchbase-cxx-client/cmake/tarball_glob.txt +10 -0
  18. package/deps/couchbase-cxx-client/core/app_telemetry_meter.cxx +1 -0
  19. package/deps/couchbase-cxx-client/core/app_telemetry_reporter.cxx +45 -43
  20. package/deps/couchbase-cxx-client/core/app_telemetry_reporter.hxx +4 -3
  21. package/deps/couchbase-cxx-client/core/bucket.cxx +128 -13
  22. package/deps/couchbase-cxx-client/core/bucket.hxx +12 -2
  23. package/deps/couchbase-cxx-client/core/cluster.cxx +304 -152
  24. package/deps/couchbase-cxx-client/core/cluster.hxx +32 -0
  25. package/deps/couchbase-cxx-client/core/cluster_credentials.cxx +25 -0
  26. package/deps/couchbase-cxx-client/core/cluster_credentials.hxx +5 -0
  27. package/deps/couchbase-cxx-client/core/cluster_label_listener.cxx +72 -0
  28. package/deps/couchbase-cxx-client/core/cluster_label_listener.hxx +46 -0
  29. package/deps/couchbase-cxx-client/core/cluster_options.hxx +4 -0
  30. package/deps/couchbase-cxx-client/core/deprecation_utils.hxx +26 -0
  31. package/deps/couchbase-cxx-client/core/error.hxx +27 -0
  32. package/deps/couchbase-cxx-client/core/free_form_http_request.hxx +0 -2
  33. package/deps/couchbase-cxx-client/core/http_component.cxx +12 -48
  34. package/deps/couchbase-cxx-client/core/impl/analytics.cxx +3 -2
  35. package/deps/couchbase-cxx-client/core/impl/analytics.hxx +2 -1
  36. package/deps/couchbase-cxx-client/core/impl/analytics_index_manager.cxx +249 -137
  37. package/deps/couchbase-cxx-client/core/impl/binary_collection.cxx +134 -58
  38. package/deps/couchbase-cxx-client/core/impl/bucket_manager.cxx +87 -35
  39. package/deps/couchbase-cxx-client/core/impl/collection.cxx +560 -245
  40. package/deps/couchbase-cxx-client/core/impl/collection_manager.cxx +89 -49
  41. package/deps/couchbase-cxx-client/core/impl/dns_srv_tracker.cxx +3 -3
  42. package/deps/couchbase-cxx-client/core/impl/error.cxx +20 -13
  43. package/deps/couchbase-cxx-client/core/impl/error.hxx +15 -10
  44. package/deps/couchbase-cxx-client/core/impl/get_all_replicas.hxx +1 -1
  45. package/deps/couchbase-cxx-client/core/impl/get_any_replica.hxx +2 -1
  46. package/deps/couchbase-cxx-client/core/impl/get_replica.hxx +2 -0
  47. package/deps/couchbase-cxx-client/core/impl/lookup_in_replica.hxx +1 -1
  48. package/deps/couchbase-cxx-client/core/impl/observability_recorder.cxx +161 -0
  49. package/deps/couchbase-cxx-client/core/impl/observability_recorder.hxx +77 -0
  50. package/deps/couchbase-cxx-client/core/impl/observe_seqno.hxx +2 -0
  51. package/deps/couchbase-cxx-client/core/impl/public_bucket.cxx +31 -7
  52. package/deps/couchbase-cxx-client/core/impl/public_cluster.cxx +107 -19
  53. package/deps/couchbase-cxx-client/core/impl/query.cxx +6 -3
  54. package/deps/couchbase-cxx-client/core/impl/query.hxx +3 -1
  55. package/deps/couchbase-cxx-client/core/impl/query_index_manager.cxx +267 -102
  56. package/deps/couchbase-cxx-client/core/impl/scope.cxx +53 -11
  57. package/deps/couchbase-cxx-client/core/impl/search.cxx +8 -4
  58. package/deps/couchbase-cxx-client/core/impl/search.hxx +6 -2
  59. package/deps/couchbase-cxx-client/core/impl/search_index_manager.cxx +131 -41
  60. package/deps/couchbase-cxx-client/core/impl/with_cancellation.hxx +75 -0
  61. package/deps/couchbase-cxx-client/core/io/config_tracker.cxx +9 -9
  62. package/deps/couchbase-cxx-client/core/io/config_tracker.hxx +2 -1
  63. package/deps/couchbase-cxx-client/core/io/http_command.hxx +98 -49
  64. package/deps/couchbase-cxx-client/core/io/http_context.hxx +2 -0
  65. package/deps/couchbase-cxx-client/core/io/http_session.cxx +23 -10
  66. package/deps/couchbase-cxx-client/core/io/http_session.hxx +17 -9
  67. package/deps/couchbase-cxx-client/core/io/http_session_manager.hxx +163 -228
  68. package/deps/couchbase-cxx-client/core/io/http_traits.hxx +0 -7
  69. package/deps/couchbase-cxx-client/core/io/mcbp_command.hxx +123 -44
  70. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +251 -26
  71. package/deps/couchbase-cxx-client/core/io/mcbp_session.hxx +9 -1
  72. package/deps/couchbase-cxx-client/core/io/mcbp_traits.hxx +0 -8
  73. package/deps/couchbase-cxx-client/core/io/streams.cxx +3 -3
  74. package/deps/couchbase-cxx-client/core/io/streams.hxx +3 -2
  75. package/deps/couchbase-cxx-client/core/meta/features.hxx +15 -0
  76. package/deps/couchbase-cxx-client/core/meta/version.cxx +13 -0
  77. package/deps/couchbase-cxx-client/core/meta/version.hxx +3 -0
  78. package/deps/couchbase-cxx-client/core/metrics/constants.hxx +23 -0
  79. package/deps/couchbase-cxx-client/core/metrics/logging_meter.cxx +5 -5
  80. package/deps/couchbase-cxx-client/core/metrics/meter_wrapper.cxx +65 -63
  81. package/deps/couchbase-cxx-client/core/metrics/meter_wrapper.hxx +12 -10
  82. package/deps/couchbase-cxx-client/core/operations/document_analytics.hxx +0 -5
  83. package/deps/couchbase-cxx-client/core/operations/document_append.hxx +0 -4
  84. package/deps/couchbase-cxx-client/core/operations/document_decrement.hxx +0 -5
  85. package/deps/couchbase-cxx-client/core/operations/document_exists.hxx +0 -7
  86. package/deps/couchbase-cxx-client/core/operations/document_get.hxx +0 -7
  87. package/deps/couchbase-cxx-client/core/operations/document_get_all_replicas.hxx +77 -27
  88. package/deps/couchbase-cxx-client/core/operations/document_get_and_lock.hxx +0 -9
  89. package/deps/couchbase-cxx-client/core/operations/document_get_and_touch.hxx +0 -9
  90. package/deps/couchbase-cxx-client/core/operations/document_get_any_replica.hxx +83 -2
  91. package/deps/couchbase-cxx-client/core/operations/document_get_projected.hxx +0 -9
  92. package/deps/couchbase-cxx-client/core/operations/document_increment.hxx +0 -5
  93. package/deps/couchbase-cxx-client/core/operations/document_insert.hxx +0 -4
  94. package/deps/couchbase-cxx-client/core/operations/document_lookup_in.hxx +0 -9
  95. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_all_replicas.hxx +46 -4
  96. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_any_replica.hxx +121 -43
  97. package/deps/couchbase-cxx-client/core/operations/document_mutate_in.hxx +0 -5
  98. package/deps/couchbase-cxx-client/core/operations/document_prepend.hxx +0 -4
  99. package/deps/couchbase-cxx-client/core/operations/document_query.hxx +0 -4
  100. package/deps/couchbase-cxx-client/core/operations/document_remove.hxx +0 -4
  101. package/deps/couchbase-cxx-client/core/operations/document_replace.hxx +0 -4
  102. package/deps/couchbase-cxx-client/core/operations/document_search.hxx +0 -7
  103. package/deps/couchbase-cxx-client/core/operations/document_touch.hxx +0 -7
  104. package/deps/couchbase-cxx-client/core/operations/document_unlock.hxx +0 -6
  105. package/deps/couchbase-cxx-client/core/operations/document_upsert.hxx +0 -4
  106. package/deps/couchbase-cxx-client/core/operations/document_view.cxx +2 -0
  107. package/deps/couchbase-cxx-client/core/operations/document_view.hxx +10 -13
  108. package/deps/couchbase-cxx-client/core/operations/http_noop.hxx +2 -0
  109. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_create.hxx +2 -0
  110. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_drop.hxx +2 -0
  111. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_get_all.hxx +2 -0
  112. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataverse_create.hxx +2 -0
  113. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataverse_drop.hxx +2 -0
  114. package/deps/couchbase-cxx-client/core/operations/management/analytics_get_pending_mutations.hxx +2 -0
  115. package/deps/couchbase-cxx-client/core/operations/management/analytics_index_create.hxx +2 -0
  116. package/deps/couchbase-cxx-client/core/operations/management/analytics_index_drop.hxx +2 -0
  117. package/deps/couchbase-cxx-client/core/operations/management/analytics_index_get_all.hxx +2 -0
  118. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_connect.hxx +2 -0
  119. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_create.hxx +2 -0
  120. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_disconnect.hxx +2 -0
  121. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_drop.hxx +2 -0
  122. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_get_all.hxx +2 -0
  123. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_replace.hxx +2 -0
  124. package/deps/couchbase-cxx-client/core/operations/management/bucket_create.hxx +2 -0
  125. package/deps/couchbase-cxx-client/core/operations/management/bucket_describe.hxx +2 -0
  126. package/deps/couchbase-cxx-client/core/operations/management/bucket_drop.hxx +2 -0
  127. package/deps/couchbase-cxx-client/core/operations/management/bucket_flush.hxx +2 -0
  128. package/deps/couchbase-cxx-client/core/operations/management/bucket_get.hxx +2 -0
  129. package/deps/couchbase-cxx-client/core/operations/management/bucket_get_all.hxx +2 -0
  130. package/deps/couchbase-cxx-client/core/operations/management/bucket_update.hxx +2 -0
  131. package/deps/couchbase-cxx-client/core/operations/management/change_password.hxx +2 -0
  132. package/deps/couchbase-cxx-client/core/operations/management/cluster_describe.hxx +2 -0
  133. package/deps/couchbase-cxx-client/core/operations/management/cluster_developer_preview_enable.hxx +2 -0
  134. package/deps/couchbase-cxx-client/core/operations/management/collection_create.hxx +2 -0
  135. package/deps/couchbase-cxx-client/core/operations/management/collection_drop.hxx +2 -0
  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/error_utils.cxx +4 -1
  139. package/deps/couchbase-cxx-client/core/operations/management/eventing_deploy_function.hxx +2 -0
  140. package/deps/couchbase-cxx-client/core/operations/management/eventing_drop_function.hxx +2 -0
  141. package/deps/couchbase-cxx-client/core/operations/management/eventing_get_all_functions.hxx +2 -0
  142. package/deps/couchbase-cxx-client/core/operations/management/eventing_get_function.hxx +2 -0
  143. package/deps/couchbase-cxx-client/core/operations/management/eventing_get_status.hxx +2 -0
  144. package/deps/couchbase-cxx-client/core/operations/management/eventing_pause_function.hxx +2 -0
  145. package/deps/couchbase-cxx-client/core/operations/management/eventing_resume_function.hxx +2 -0
  146. package/deps/couchbase-cxx-client/core/operations/management/eventing_undeploy_function.hxx +2 -0
  147. package/deps/couchbase-cxx-client/core/operations/management/eventing_upsert_function.hxx +2 -0
  148. package/deps/couchbase-cxx-client/core/operations/management/freeform.hxx +2 -0
  149. package/deps/couchbase-cxx-client/core/operations/management/group_drop.hxx +2 -0
  150. package/deps/couchbase-cxx-client/core/operations/management/group_get.hxx +2 -0
  151. package/deps/couchbase-cxx-client/core/operations/management/group_get_all.hxx +2 -0
  152. package/deps/couchbase-cxx-client/core/operations/management/group_upsert.hxx +2 -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 +68 -30
  155. package/deps/couchbase-cxx-client/core/operations/management/query_index_create.hxx +2 -0
  156. package/deps/couchbase-cxx-client/core/operations/management/query_index_drop.hxx +2 -0
  157. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all.hxx +4 -3
  158. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all_deferred.hxx +2 -1
  159. package/deps/couchbase-cxx-client/core/operations/management/role_get_all.hxx +2 -0
  160. package/deps/couchbase-cxx-client/core/operations/management/scope_create.hxx +2 -0
  161. package/deps/couchbase-cxx-client/core/operations/management/scope_drop.hxx +2 -0
  162. package/deps/couchbase-cxx-client/core/operations/management/scope_get_all.hxx +2 -0
  163. package/deps/couchbase-cxx-client/core/operations/management/search_get_stats.hxx +2 -0
  164. package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.hxx +2 -0
  165. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.hxx +2 -0
  166. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.hxx +2 -0
  167. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.hxx +2 -0
  168. package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.hxx +2 -0
  169. package/deps/couchbase-cxx-client/core/operations/management/search_index_get.hxx +2 -0
  170. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.hxx +2 -0
  171. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.hxx +2 -0
  172. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_stats.hxx +2 -0
  173. package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.hxx +2 -0
  174. package/deps/couchbase-cxx-client/core/operations/management/user_drop.hxx +2 -0
  175. package/deps/couchbase-cxx-client/core/operations/management/user_get.hxx +2 -0
  176. package/deps/couchbase-cxx-client/core/operations/management/user_get_all.hxx +2 -0
  177. package/deps/couchbase-cxx-client/core/operations/management/user_upsert.hxx +2 -0
  178. package/deps/couchbase-cxx-client/core/operations/management/view_index_drop.hxx +2 -0
  179. package/deps/couchbase-cxx-client/core/operations/management/view_index_get.hxx +2 -0
  180. package/deps/couchbase-cxx-client/core/operations/management/view_index_get_all.hxx +2 -0
  181. package/deps/couchbase-cxx-client/core/operations/management/view_index_upsert.hxx +2 -0
  182. package/deps/couchbase-cxx-client/core/operations/operation_traits.hxx +6 -0
  183. package/deps/couchbase-cxx-client/core/operations.hxx +0 -1
  184. package/deps/couchbase-cxx-client/core/operations_fwd.hxx +8 -0
  185. package/deps/couchbase-cxx-client/core/origin.cxx +67 -12
  186. package/deps/couchbase-cxx-client/core/origin.hxx +13 -8
  187. package/deps/couchbase-cxx-client/core/orphan_reporter.cxx +164 -0
  188. package/deps/couchbase-cxx-client/core/orphan_reporter.hxx +65 -0
  189. package/deps/couchbase-cxx-client/core/sasl/CMakeLists.txt +1 -0
  190. package/deps/couchbase-cxx-client/core/sasl/client.cc +6 -0
  191. package/deps/couchbase-cxx-client/core/sasl/mechanism.cc +2 -1
  192. package/deps/couchbase-cxx-client/core/sasl/mechanism.h +2 -1
  193. package/deps/couchbase-cxx-client/core/sasl/oauthbearer/oauthbearer.cc +41 -0
  194. package/deps/couchbase-cxx-client/core/sasl/oauthbearer/oauthbearer.h +47 -0
  195. package/deps/couchbase-cxx-client/core/tls_context_provider.cxx +44 -0
  196. package/deps/couchbase-cxx-client/core/tls_context_provider.hxx +44 -0
  197. package/deps/couchbase-cxx-client/core/tracing/attribute_helpers.hxx +45 -0
  198. package/deps/couchbase-cxx-client/core/tracing/constants.hxx +148 -68
  199. package/deps/couchbase-cxx-client/core/tracing/threshold_logging_options.hxx +0 -3
  200. package/deps/couchbase-cxx-client/core/tracing/threshold_logging_tracer.cxx +122 -170
  201. package/deps/couchbase-cxx-client/core/tracing/tracer_wrapper.cxx +17 -24
  202. package/deps/couchbase-cxx-client/core/tracing/tracer_wrapper.hxx +8 -10
  203. package/deps/couchbase-cxx-client/core/tracing/wrapper_sdk_tracer.cxx +114 -0
  204. package/deps/couchbase-cxx-client/core/tracing/wrapper_sdk_tracer.hxx +85 -0
  205. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.cxx +16 -14
  206. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.hxx +4 -4
  207. package/deps/couchbase-cxx-client/core/transactions/transactions.cxx +1 -1
  208. package/deps/couchbase-cxx-client/core/transactions/transactions_cleanup.cxx +1 -2
  209. package/deps/couchbase-cxx-client/core/utils/byteswap.hxx +12 -0
  210. package/deps/couchbase-cxx-client/core/utils/concurrent_fixed_priority_queue.hxx +102 -0
  211. package/deps/couchbase-cxx-client/core/utils/connection_string.cxx +2 -0
  212. package/deps/couchbase-cxx-client/couchbase/certificate_authenticator.hxx +1 -0
  213. package/deps/couchbase-cxx-client/couchbase/cluster.hxx +47 -0
  214. package/deps/couchbase-cxx-client/couchbase/cluster_options.hxx +16 -0
  215. package/deps/couchbase-cxx-client/couchbase/collection.hxx +60 -15
  216. package/deps/couchbase-cxx-client/couchbase/error_codes.hxx +48 -48
  217. package/deps/couchbase-cxx-client/couchbase/jwt_authenticator.hxx +52 -0
  218. package/deps/couchbase-cxx-client/couchbase/metrics/meter.hxx +2 -1
  219. package/deps/couchbase-cxx-client/couchbase/metrics/otel_meter.hxx +75 -80
  220. package/deps/couchbase-cxx-client/couchbase/network_options.hxx +19 -0
  221. package/deps/couchbase-cxx-client/couchbase/password_authenticator.hxx +1 -0
  222. package/deps/couchbase-cxx-client/couchbase/tracing/otel_tracer.hxx +15 -17
  223. package/deps/couchbase-cxx-client/couchbase/tracing/request_span.hxx +2 -2
  224. package/dist/analyticsexecutor.d.ts +15 -0
  225. package/dist/analyticsexecutor.js +79 -50
  226. package/dist/analyticsindexmanager.d.ts +66 -0
  227. package/dist/analyticsindexmanager.js +404 -277
  228. package/dist/analyticstypes.d.ts +5 -0
  229. package/dist/authenticators.d.ts +34 -1
  230. package/dist/authenticators.js +19 -1
  231. package/dist/binarycollection.d.ts +17 -0
  232. package/dist/binding.d.ts +245 -228
  233. package/dist/bindingutilities.js +1 -1
  234. package/dist/bucket.d.ts +8 -0
  235. package/dist/bucket.js +8 -0
  236. package/dist/bucketmanager.d.ts +30 -0
  237. package/dist/bucketmanager.js +128 -69
  238. package/dist/cluster.d.ts +45 -0
  239. package/dist/cluster.js +133 -21
  240. package/dist/collection.d.ts +75 -2
  241. package/dist/collection.js +772 -551
  242. package/dist/collectionmanager.d.ts +34 -0
  243. package/dist/collectionmanager.js +172 -89
  244. package/dist/couchbase.d.ts +5 -0
  245. package/dist/couchbase.js +5 -0
  246. package/dist/datastructures.js +310 -97
  247. package/dist/errors.d.ts +8 -0
  248. package/dist/errors.js +12 -1
  249. package/dist/eventingfunctionmanager.d.ts +42 -0
  250. package/dist/eventingfunctionmanager.js +172 -100
  251. package/dist/logger.d.ts +192 -0
  252. package/dist/logger.js +213 -0
  253. package/dist/loggingmeter.d.ts +120 -0
  254. package/dist/loggingmeter.js +226 -0
  255. package/dist/metrics.d.ts +33 -0
  256. package/dist/metrics.js +5 -0
  257. package/dist/observability.d.ts +60 -0
  258. package/dist/observability.js +86 -0
  259. package/dist/observabilityhandler.d.ts +176 -0
  260. package/dist/observabilityhandler.js +733 -0
  261. package/dist/observabilitytypes.d.ts +320 -0
  262. package/dist/observabilitytypes.js +362 -0
  263. package/dist/observabilityutilities.d.ts +60 -0
  264. package/dist/observabilityutilities.js +175 -0
  265. package/dist/otelmeter.d.ts +51 -0
  266. package/dist/otelmeter.js +100 -0
  267. package/dist/oteltracer.d.ts +69 -0
  268. package/dist/oteltracer.js +141 -0
  269. package/dist/queryexecutor.d.ts +16 -0
  270. package/dist/queryexecutor.js +128 -86
  271. package/dist/queryindexmanager.d.ts +29 -0
  272. package/dist/queryindexmanager.js +277 -150
  273. package/dist/querytypes.d.ts +5 -0
  274. package/dist/scope.js +2 -2
  275. package/dist/scopeeventingfunctionmanager.d.ts +5 -0
  276. package/dist/scopeeventingfunctionmanager.js +217 -119
  277. package/dist/scopesearchindexmanager.d.ts +5 -0
  278. package/dist/scopesearchindexmanager.js +295 -166
  279. package/dist/sdspecs.js +6 -1
  280. package/dist/searchexecutor.d.ts +15 -0
  281. package/dist/searchexecutor.js +54 -26
  282. package/dist/searchindexmanager.d.ts +54 -0
  283. package/dist/searchindexmanager.js +235 -142
  284. package/dist/searchtypes.d.ts +5 -0
  285. package/dist/thresholdlogging.d.ts +301 -0
  286. package/dist/thresholdlogging.js +657 -0
  287. package/dist/tracing.d.ts +55 -0
  288. package/dist/tracing.js +2 -0
  289. package/dist/usermanager.d.ts +46 -0
  290. package/dist/usermanager.js +199 -118
  291. package/dist/utilities.d.ts +4 -0
  292. package/dist/utilities.js +11 -1
  293. package/dist/version.d.ts +2 -0
  294. package/dist/version.js +7 -0
  295. package/dist/viewexecutor.d.ts +15 -0
  296. package/dist/viewexecutor.js +54 -29
  297. package/dist/viewindexmanager.d.ts +30 -0
  298. package/dist/viewindexmanager.js +129 -100
  299. package/dist/viewtypes.d.ts +5 -0
  300. package/package.json +19 -9
  301. package/scripts/prebuilds.js +1 -1
  302. package/scripts/updateVersion.js +26 -0
  303. package/src/connection.cpp +79 -98
  304. package/src/connection.hpp +46 -38
  305. package/src/connection_autogen.cpp +1236 -292
  306. package/src/jstocbpp_autogen.hpp +1117 -313
  307. package/src/jstocbpp_basic.hpp +73 -0
  308. package/src/jstocbpp_defs.hpp +37 -9
  309. package/src/jstocbpp_errors.hpp +37 -11
  310. package/tools/gen-bindings-js.js +100 -22
  311. package/tools/gen-bindings-json.py +40 -6
  312. package/src/transcoder.hpp +0 -96
@@ -0,0 +1,733 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WrappedSpan = exports.ObservableRequestHandler = void 0;
4
+ const observability_1 = require("./observability");
5
+ const observabilitytypes_1 = require("./observabilitytypes");
6
+ const observabilityutilities_1 = require("./observabilityutilities");
7
+ const observabilityutilities_2 = require("./observabilityutilities");
8
+ const utilities_1 = require("./utilities");
9
+ /**
10
+ * @internal
11
+ */
12
+ class ObservableRequestHandlerTracerImpl {
13
+ constructor(opType, observabilityInstruments, parentSpan) {
14
+ this._startTime = (0, observabilityutilities_1.timeInputToHiResTime)();
15
+ this._opType = opType;
16
+ this._serviceName = (0, observabilitytypes_1.serviceNameFromOpType)(opType);
17
+ this._tracer = observabilityInstruments.tracer;
18
+ this._getClusterLabelsFn = observabilityInstruments.clusterLabelsFn;
19
+ this._wrappedSpan = new WrappedSpan(this._serviceName, this._opType, this._tracer, this._startTime, parentSpan);
20
+ this._processedCoreSpan = false;
21
+ }
22
+ /**
23
+ * @internal
24
+ */
25
+ get clusterName() {
26
+ return this._wrappedSpan.clusterName;
27
+ }
28
+ /**
29
+ * @internal
30
+ */
31
+ get clusterUUID() {
32
+ return this._wrappedSpan.clusterUUID;
33
+ }
34
+ /**
35
+ * @internal
36
+ */
37
+ get wrapperSpanName() {
38
+ return this._wrappedSpan.name;
39
+ }
40
+ /**
41
+ * @internal
42
+ */
43
+ get wrappedSpan() {
44
+ return this._wrappedSpan;
45
+ }
46
+ /**
47
+ * @internal
48
+ */
49
+ maybeAddEncodingSpan(encodeFn) {
50
+ return this._wrappedSpan.maybeAddEncodingSpan(encodeFn);
51
+ }
52
+ /**
53
+ * @internal
54
+ */
55
+ maybeCreateEncodingSpan(encodeFn) {
56
+ return this._wrappedSpan.maybeCreateEncodingSpan(encodeFn);
57
+ }
58
+ /**
59
+ * @internal
60
+ */
61
+ end() {
62
+ this._endTime = (0, observabilityutilities_1.timeInputToHiResTime)();
63
+ this._wrappedSpan.end(this._endTime);
64
+ }
65
+ /**
66
+ * @internal
67
+ */
68
+ endWithError(error) {
69
+ if (!this._processedCoreSpan && this._getClusterLabelsFn) {
70
+ const clusterLabels = this._getClusterLabelsFn();
71
+ this._wrappedSpan.setClusterLabels(clusterLabels);
72
+ this._wrappedSpan.setRetryAttribute(0);
73
+ }
74
+ if (error) {
75
+ this._wrappedSpan.setStatus({
76
+ code: observabilitytypes_1.SpanStatusCode.ERROR,
77
+ message: (0, utilities_1.getErrorMessage)(error),
78
+ });
79
+ }
80
+ else {
81
+ this._wrappedSpan.setStatus({
82
+ code: observabilitytypes_1.SpanStatusCode.ERROR,
83
+ });
84
+ }
85
+ this.end();
86
+ }
87
+ /**
88
+ * @internal
89
+ */
90
+ reset(opType, parentSpan, withError = false) {
91
+ if (withError) {
92
+ this.endWithError();
93
+ }
94
+ this._startTime = (0, observabilityutilities_1.timeInputToHiResTime)();
95
+ this._opType = opType;
96
+ this._serviceName = (0, observabilitytypes_1.serviceNameFromOpType)(opType);
97
+ this._endTime = undefined;
98
+ this._wrappedSpan = new WrappedSpan(this._serviceName, this._opType, this._tracer, this._startTime, parentSpan);
99
+ }
100
+ /**
101
+ * @internal
102
+ */
103
+ processCoreSpan(coreSpan) {
104
+ if (!coreSpan) {
105
+ return;
106
+ }
107
+ this._wrappedSpan.processCoreSpan(coreSpan);
108
+ this._processedCoreSpan = true;
109
+ }
110
+ /**
111
+ * @internal
112
+ */
113
+ setRequestHttpAttributes(options) {
114
+ const opAttrs = (0, observabilityutilities_1.getAttributesForHttpOpType)(this._opType, options);
115
+ for (const [k, v] of Object.entries(opAttrs)) {
116
+ this._wrappedSpan.setAttribute(k, v);
117
+ }
118
+ }
119
+ /**
120
+ * @internal
121
+ */
122
+ setRequestKeyValueAttributes(cppDocId, durability) {
123
+ const opAttrs = (0, observabilityutilities_1.getAttributesForKeyValueOpType)(this._opType, cppDocId, durability);
124
+ for (const [k, v] of Object.entries(opAttrs)) {
125
+ this._wrappedSpan.setAttribute(k, v);
126
+ }
127
+ // TODO: meter attrs
128
+ }
129
+ }
130
+ /**
131
+ * @internal
132
+ */
133
+ class ObservableRequestHandlerNoOpTracerImpl {
134
+ constructor(opType, _observabilityInstruments, _parentSpan) {
135
+ this._opType = opType;
136
+ }
137
+ /**
138
+ * @internal
139
+ */
140
+ get clusterName() {
141
+ return undefined;
142
+ }
143
+ /**
144
+ * @internal
145
+ */
146
+ get clusterUUID() {
147
+ return undefined;
148
+ }
149
+ /**
150
+ * @internal
151
+ */
152
+ get wrapperSpanName() {
153
+ return '';
154
+ }
155
+ /**
156
+ * @internal
157
+ */
158
+ get wrappedSpan() {
159
+ return this._wrappedSpan;
160
+ }
161
+ /**
162
+ * @internal
163
+ */
164
+ end() { }
165
+ /**
166
+ * @internal
167
+ */
168
+ endWithError(_error) { }
169
+ /**
170
+ * @internal
171
+ */
172
+ maybeAddEncodingSpan(encodeFn) {
173
+ return encodeFn();
174
+ }
175
+ /**
176
+ * @internal
177
+ */
178
+ maybeCreateEncodingSpan(encodeFn) {
179
+ return encodeFn();
180
+ }
181
+ /**
182
+ * @internal
183
+ */
184
+ processCoreSpan(_coreSpan) { }
185
+ /**
186
+ * @internal
187
+ */
188
+ reset(_opType, _parentSpan, _withError = false) { }
189
+ /**
190
+ * @internal
191
+ */
192
+ setRequestHttpAttributes(_options) { }
193
+ /**
194
+ * @internal
195
+ */
196
+ setRequestKeyValueAttributes(_cppDocId, _durability) { }
197
+ }
198
+ /**
199
+ * @internal
200
+ */
201
+ class ObservableRequestHandlerNoOpMeterImpl {
202
+ constructor(opType, _observabilityInstruments) {
203
+ this._opType = opType;
204
+ }
205
+ /**
206
+ * @internal
207
+ */
208
+ setRequestKeyValueAttributes(_cppDocId, _durability) { }
209
+ /**
210
+ * @internal
211
+ */
212
+ setRequestHttpAttributes(_options) { }
213
+ /**
214
+ * @internal
215
+ */
216
+ processEnd(_clusterName, _clusterUUID, _error) { }
217
+ /**
218
+ * @internal
219
+ */
220
+ reset(_opType, _clusterName, _clusterUUID, _error) { }
221
+ }
222
+ /**
223
+ * @internal
224
+ */
225
+ class ObservableRequestHandlerMeterImpl {
226
+ constructor(opType, observabilityInstruments) {
227
+ this._attrs = {};
228
+ this._opType = opType;
229
+ this._serviceName = (0, observabilitytypes_1.serviceNameFromOpType)(opType);
230
+ this._meter = observabilityInstruments.meter;
231
+ this._getClusterLabelsFn = observabilityInstruments.clusterLabelsFn;
232
+ this._startTime = (0, observabilityutilities_1.timeInputToHiResTime)();
233
+ this._ignoreTopLevelOp = Object.values(observabilitytypes_1.DatastructureOp).includes(opType);
234
+ }
235
+ /**
236
+ * @internal
237
+ */
238
+ setRequestKeyValueAttributes(cppDocId) {
239
+ this._attrs = (0, observabilityutilities_1.getAttributesForKeyValueOpType)(this._opType, cppDocId);
240
+ }
241
+ /**
242
+ * @internal
243
+ */
244
+ setRequestHttpAttributes(options) {
245
+ this._attrs = (0, observabilityutilities_1.getAttributesForHttpOpType)(this._opType, options);
246
+ }
247
+ /**
248
+ * @internal
249
+ */
250
+ processEnd(clusterName, clusterUUID, error) {
251
+ const endTime = (0, observabilityutilities_1.timeInputToHiResTime)();
252
+ const duration = (0, observabilityutilities_2.hiResTimeToMicros)((0, observabilityutilities_2.getHiResTimeDelta)(this._startTime, endTime));
253
+ if (this._ignoreTopLevelOp) {
254
+ return;
255
+ }
256
+ // Get cluster labels if not provided
257
+ if (this._getClusterLabelsFn &&
258
+ (clusterName === undefined || clusterUUID === undefined)) {
259
+ const clusterLabels = this._getClusterLabelsFn();
260
+ clusterName = clusterName || clusterLabels.clusterName;
261
+ clusterUUID = clusterUUID || clusterLabels.clusterUUID;
262
+ }
263
+ // Build final tags
264
+ const tags = {
265
+ ...this._attrs,
266
+ };
267
+ if (Object.keys(tags).length === 0) {
268
+ tags[observabilitytypes_1.OpAttributeName.SystemName] = 'couchbase';
269
+ tags[observabilitytypes_1.OpAttributeName.Service] = this._serviceName;
270
+ tags[observabilitytypes_1.OpAttributeName.OperationName] = this._getOpName();
271
+ tags[observabilitytypes_1.OpAttributeName.ReservedUnit] = observabilitytypes_1.OpAttributeName.ReservedUnitSeconds;
272
+ }
273
+ else {
274
+ tags[observabilitytypes_1.OpAttributeName.ReservedUnit] = observabilitytypes_1.OpAttributeName.ReservedUnitSeconds;
275
+ }
276
+ // Add cluster labels
277
+ if (clusterName) {
278
+ tags[observabilitytypes_1.OpAttributeName.ClusterName] = clusterName;
279
+ }
280
+ if (clusterUUID) {
281
+ tags[observabilitytypes_1.OpAttributeName.ClusterUUID] = clusterUUID;
282
+ }
283
+ // Handle error
284
+ if (error) {
285
+ this._handleError(tags, error);
286
+ }
287
+ // Record the duration
288
+ this._meter
289
+ .valueRecorder(observabilitytypes_1.OpAttributeName.MeterNameOpDuration, tags)
290
+ .recordValue(duration);
291
+ }
292
+ /**
293
+ * @internal
294
+ */
295
+ reset(opType, clusterName, clusterUUID, error) {
296
+ this.processEnd(clusterName, clusterUUID, error);
297
+ this._opType = opType;
298
+ this._serviceName = (0, observabilitytypes_1.serviceNameFromOpType)(opType);
299
+ this._startTime = (0, observabilityutilities_1.timeInputToHiResTime)();
300
+ this._attrs = {};
301
+ }
302
+ _getOpName() {
303
+ return this._opType.toString();
304
+ }
305
+ _handleError(tags, error) {
306
+ var _a;
307
+ if (typeof error !== 'object' || error === null) {
308
+ tags[observabilitytypes_1.OpAttributeName.ErrorType] = '_OTHER';
309
+ return;
310
+ }
311
+ let errorType = (error === null || error === void 0 ? void 0 : error.name) || ((_a = error === null || error === void 0 ? void 0 : error.constructor) === null || _a === void 0 ? void 0 : _a.name) || '_OTHER';
312
+ if (errorType.endsWith('Error')) {
313
+ errorType = errorType.slice(0, -5);
314
+ }
315
+ tags[observabilitytypes_1.OpAttributeName.ErrorType] = errorType;
316
+ }
317
+ }
318
+ /**
319
+ * @internal
320
+ */
321
+ class ObservableRequestHandler {
322
+ constructor(opType, observabilityInstruments, parentSpan) {
323
+ this._opType = opType;
324
+ this._requestHasEnded = false;
325
+ if (!observabilityInstruments.tracer ||
326
+ observabilityInstruments.tracer instanceof observability_1.NoOpTracer) {
327
+ this._tracerImpl = new ObservableRequestHandlerNoOpTracerImpl(opType, observabilityInstruments, parentSpan);
328
+ }
329
+ else {
330
+ this._tracerImpl = new ObservableRequestHandlerTracerImpl(opType, observabilityInstruments, parentSpan);
331
+ }
332
+ if (observabilityInstruments.meter instanceof observability_1.NoOpMeter) {
333
+ this._meterImpl = new ObservableRequestHandlerNoOpMeterImpl(opType, observabilityInstruments);
334
+ }
335
+ else {
336
+ this._meterImpl = new ObservableRequestHandlerMeterImpl(opType, observabilityInstruments);
337
+ }
338
+ }
339
+ /**
340
+ * @internal
341
+ */
342
+ get opType() {
343
+ return this._opType;
344
+ }
345
+ /**
346
+ * @internal
347
+ */
348
+ get requestHasEnded() {
349
+ return this._requestHasEnded;
350
+ }
351
+ /**
352
+ * @internal
353
+ */
354
+ get wrapperSpanName() {
355
+ return this._tracerImpl.wrapperSpanName;
356
+ }
357
+ /**
358
+ * @internal
359
+ */
360
+ get wrappedSpan() {
361
+ return this._tracerImpl.wrappedSpan;
362
+ }
363
+ /**
364
+ * @internal
365
+ */
366
+ get clusterName() {
367
+ return this._tracerImpl.clusterName;
368
+ }
369
+ /**
370
+ * @internal
371
+ */
372
+ get clusterUUID() {
373
+ return this._tracerImpl.clusterUUID;
374
+ }
375
+ /**
376
+ * @internal
377
+ */
378
+ end() {
379
+ this._requestHasEnded = true;
380
+ this._tracerImpl.end();
381
+ this._meterImpl.processEnd(this.clusterName, this.clusterUUID);
382
+ }
383
+ /**
384
+ * @internal
385
+ */
386
+ endWithError(error) {
387
+ this._requestHasEnded = true;
388
+ this._tracerImpl.endWithError(error);
389
+ this._meterImpl.processEnd(this.clusterName, this.clusterUUID, error);
390
+ }
391
+ /**
392
+ * @internal
393
+ */
394
+ maybeAddEncodingSpan(encodeFn) {
395
+ return this._tracerImpl.maybeAddEncodingSpan(encodeFn);
396
+ }
397
+ /**
398
+ * @internal
399
+ */
400
+ maybeCreateEncodingSpan(encodeFn) {
401
+ return this._tracerImpl.maybeCreateEncodingSpan(encodeFn);
402
+ }
403
+ /**
404
+ * @internal
405
+ */
406
+ reset(opType, parentSpan, withError = false) {
407
+ this._opType = opType;
408
+ this._tracerImpl.reset(opType, parentSpan, withError);
409
+ this._meterImpl.reset(opType, this.clusterName, this.clusterUUID, withError ? undefined : undefined);
410
+ }
411
+ /**
412
+ * @internal
413
+ */
414
+ processCoreSpan(coreSpan) {
415
+ this._tracerImpl.processCoreSpan(coreSpan);
416
+ }
417
+ /**
418
+ * @internal
419
+ */
420
+ setRequestHttpAttributes(options) {
421
+ this._tracerImpl.setRequestHttpAttributes(options);
422
+ this._meterImpl.setRequestHttpAttributes(options);
423
+ }
424
+ /**
425
+ * @internal
426
+ */
427
+ setRequestKeyValueAttributes(cppDocId, durability) {
428
+ this._tracerImpl.setRequestKeyValueAttributes(cppDocId, durability);
429
+ this._meterImpl.setRequestKeyValueAttributes(cppDocId, durability);
430
+ }
431
+ }
432
+ exports.ObservableRequestHandler = ObservableRequestHandler;
433
+ /**
434
+ * @internal
435
+ */
436
+ class WrappedEncodingSpan {
437
+ constructor(span, endTime) {
438
+ this.span = span;
439
+ this.endTime = endTime;
440
+ }
441
+ }
442
+ /**
443
+ * @internal
444
+ */
445
+ class WrappedSpan {
446
+ constructor(serviceName, opType, tracer, startTime, parentSpan) {
447
+ this._serviceName = serviceName;
448
+ this._opType = opType;
449
+ this._tracer = tracer;
450
+ this._parentSpan = parentSpan;
451
+ // requestSpan's parent needs to be a RequestSpan
452
+ const pSpan = this._parentSpan instanceof WrappedSpan
453
+ ? this._parentSpan._requestSpan
454
+ : this._parentSpan;
455
+ this._hasMultipleEncodingSpans = this._opType == observabilitytypes_1.KeyValueOp.MutateIn;
456
+ this._requestSpan = this._createRequestSpan(this._opType, startTime, pSpan);
457
+ this._endedEncodingSpans = false;
458
+ this._startTime = startTime;
459
+ this._endTimeWatermark = (0, observabilityutilities_1.timeInputToHiResTime)();
460
+ }
461
+ /**
462
+ * @internal
463
+ */
464
+ get clusterName() {
465
+ return this._clusterName;
466
+ }
467
+ /**
468
+ * @internal
469
+ */
470
+ get clusterUUID() {
471
+ return this._clusterUUID;
472
+ }
473
+ /**
474
+ * @internal
475
+ */
476
+ get name() {
477
+ return this._opType;
478
+ }
479
+ /**
480
+ * @internal
481
+ */
482
+ get requestSpan() {
483
+ return this._requestSpan;
484
+ }
485
+ /**
486
+ * @internal
487
+ */
488
+ maybeAddEncodingSpan(encodeFn) {
489
+ if (!this._hasMultipleEncodingSpans) {
490
+ return encodeFn();
491
+ }
492
+ if (!this._encodingSpans) {
493
+ this._encodingSpans = [];
494
+ }
495
+ const encodingSpan = this._tracer.requestSpan(observabilitytypes_1.OpAttributeName.EncodingSpanName, this._requestSpan, (0, observabilityutilities_1.timeInputToHiResTime)());
496
+ encodingSpan.setAttribute(observabilitytypes_1.OpAttributeName.SystemName, 'couchbase');
497
+ try {
498
+ const encodedOutput = encodeFn();
499
+ return encodedOutput;
500
+ }
501
+ catch (e) {
502
+ encodingSpan.setStatus({
503
+ code: observabilitytypes_1.SpanStatusCode.ERROR,
504
+ message: (0, utilities_1.getErrorMessage)(e),
505
+ });
506
+ throw e;
507
+ }
508
+ finally {
509
+ // we wait to set the end time until we process the underylying
510
+ // core span so that we can add the cluster_[name|uuid] attributes
511
+ this._encodingSpans.push(new WrappedEncodingSpan(encodingSpan, (0, observabilityutilities_1.timeInputToHiResTime)()));
512
+ }
513
+ }
514
+ /**
515
+ * @internal
516
+ */
517
+ maybeCreateEncodingSpan(encodeFn) {
518
+ // mutateIn can have multiple encoding spans, should use maybeAddEncodingSpan instead
519
+ if (this._hasMultipleEncodingSpans) {
520
+ return encodeFn();
521
+ }
522
+ const encodingSpan = this._tracer.requestSpan(observabilitytypes_1.OpAttributeName.EncodingSpanName, this._requestSpan, (0, observabilityutilities_1.timeInputToHiResTime)());
523
+ encodingSpan.setAttribute(observabilitytypes_1.OpAttributeName.SystemName, 'couchbase');
524
+ try {
525
+ const encodedOutput = encodeFn();
526
+ return encodedOutput;
527
+ }
528
+ catch (e) {
529
+ encodingSpan.setStatus({
530
+ code: observabilitytypes_1.SpanStatusCode.ERROR,
531
+ message: (0, utilities_1.getErrorMessage)(e),
532
+ });
533
+ throw e;
534
+ }
535
+ finally {
536
+ // we wait to set the end time until we process the underylying
537
+ // core span so that we can add the cluster_[name|uuid] attributes
538
+ this._encodingSpan = new WrappedEncodingSpan(encodingSpan, (0, observabilityutilities_1.timeInputToHiResTime)());
539
+ }
540
+ }
541
+ /**
542
+ * @internal
543
+ */
544
+ maybeUpdateEndTimeWatermark(endTime) {
545
+ this._endTimeWatermark = (0, observabilityutilities_1.getLatestTime)(this._endTimeWatermark, endTime);
546
+ }
547
+ /**
548
+ * @internal
549
+ */
550
+ _setAttributeOnAllSpans(attrName, attrValue, skip_encoding_span) {
551
+ this.setAttribute(attrName, attrValue);
552
+ if (this._parentSpan instanceof WrappedSpan) {
553
+ this._parentSpan._setAttributeOnAllSpans(attrName, attrValue);
554
+ }
555
+ if (skip_encoding_span) {
556
+ return;
557
+ }
558
+ if (this._encodingSpans instanceof Array) {
559
+ for (const span of this._encodingSpans) {
560
+ span.span.setAttribute(attrName, attrValue);
561
+ }
562
+ }
563
+ else if (this._encodingSpan) {
564
+ this._encodingSpan.span.setAttribute(attrName, attrValue);
565
+ }
566
+ }
567
+ /**
568
+ * @internal
569
+ */
570
+ _maybeSetAttributeFromCoreSpan(coreSpan, attrName, skip_encoding_span) {
571
+ var _a;
572
+ let attrVal;
573
+ const coreSpanAttr = (_a = coreSpan.attributes) === null || _a === void 0 ? void 0 : _a[attrName];
574
+ if (coreSpanAttr) {
575
+ attrVal = coreSpanAttr;
576
+ }
577
+ if (typeof attrVal === 'undefined' && attrName == 'retries') {
578
+ attrVal = 0;
579
+ }
580
+ if (typeof attrVal !== 'undefined') {
581
+ let filteredAttrName;
582
+ if ((0, observabilitytypes_1.isCppAttribute)(attrName)) {
583
+ filteredAttrName = observabilitytypes_1.CppOpAttributeNameToOpAttributeNameMap[attrName];
584
+ }
585
+ else {
586
+ filteredAttrName = attrName;
587
+ }
588
+ this._setAttributeOnAllSpans(filteredAttrName, attrVal, skip_encoding_span);
589
+ }
590
+ }
591
+ /**
592
+ * @internal
593
+ */
594
+ _buildCoreSpans(coreSpans, parentSpan) {
595
+ for (const span of coreSpans) {
596
+ if (span.name === observabilitytypes_1.OpAttributeName.DispatchSpanName) {
597
+ this._buildDispatchCoreSpan(span, parentSpan);
598
+ }
599
+ else {
600
+ this._buildNonDispatchCoreSpan(span, parentSpan);
601
+ }
602
+ }
603
+ }
604
+ /**
605
+ * @internal
606
+ */
607
+ _buildDispatchCoreSpan(coreSpan, parentSpan) {
608
+ var _a;
609
+ const pSpan = parentSpan instanceof WrappedSpan ? parentSpan.requestSpan : parentSpan;
610
+ const latestStartTime = (0, observabilityutilities_1.getLatestTime)(this._startTime, coreSpan.start);
611
+ const newSpan = this._createRequestSpan(coreSpan.name, latestStartTime, pSpan);
612
+ const children = coreSpan.children;
613
+ if (children) {
614
+ this._buildCoreSpans(children, newSpan);
615
+ }
616
+ for (const [attrName, attrVal] of Object.entries((_a = coreSpan.attributes) !== null && _a !== void 0 ? _a : {})) {
617
+ newSpan.setAttribute(attrName, attrVal);
618
+ }
619
+ const coreSpanEndTime = (0, observabilityutilities_1.getCoreSpanEndTime)(coreSpan.end);
620
+ this._endTimeWatermark = (0, observabilityutilities_1.getLatestTime)(this._endTimeWatermark, coreSpanEndTime);
621
+ newSpan.end(coreSpanEndTime);
622
+ }
623
+ /**
624
+ * @internal
625
+ */
626
+ _buildNonDispatchCoreSpan(coreSpan, parentSpan) {
627
+ var _a;
628
+ const pSpan = parentSpan instanceof WrappedSpan ? parentSpan.requestSpan : parentSpan;
629
+ const latestStartTime = (0, observabilityutilities_1.getLatestTime)(this._startTime, coreSpan.start);
630
+ const newSpan = new WrappedSpan(this._serviceName, coreSpan.name, this._tracer, latestStartTime, pSpan);
631
+ const children = coreSpan.children;
632
+ if (children) {
633
+ this._buildCoreSpans(children, newSpan);
634
+ }
635
+ for (const [attrName, attrVal] of Object.entries((_a = coreSpan.attributes) !== null && _a !== void 0 ? _a : {})) {
636
+ newSpan.setAttribute(attrName, attrVal);
637
+ }
638
+ const coreSpanEndTime = (0, observabilityutilities_1.getCoreSpanEndTime)(coreSpan.end);
639
+ this._endTimeWatermark = (0, observabilityutilities_1.getLatestTime)(this._endTimeWatermark, coreSpanEndTime);
640
+ newSpan.end(coreSpanEndTime);
641
+ }
642
+ /**
643
+ * @internal
644
+ */
645
+ _endEncodingSpans() {
646
+ if (this._endedEncodingSpans) {
647
+ return;
648
+ }
649
+ this._endedEncodingSpans = true;
650
+ if (this._encodingSpans instanceof Array) {
651
+ for (const span of this._encodingSpans) {
652
+ span.span.end(span.endTime);
653
+ }
654
+ }
655
+ else if (this._encodingSpan) {
656
+ this._encodingSpan.span.end(this._encodingSpan.endTime);
657
+ }
658
+ }
659
+ /**
660
+ * @internal
661
+ */
662
+ processCoreSpan(coreSpan) {
663
+ this._maybeSetAttributeFromCoreSpan(coreSpan, observabilitytypes_1.CppOpAttributeName.ClusterName);
664
+ this._maybeSetAttributeFromCoreSpan(coreSpan, observabilitytypes_1.CppOpAttributeName.ClusterUUID);
665
+ this._maybeSetAttributeFromCoreSpan(coreSpan, observabilitytypes_1.CppOpAttributeName.RetryCount, true);
666
+ // we can now end encoding spans since we have added (or atleast attempted) the cluster_[name|uuid] attributes
667
+ this._endEncodingSpans();
668
+ if (coreSpan.children) {
669
+ this._buildCoreSpans(coreSpan.children, this);
670
+ }
671
+ }
672
+ /**
673
+ * @internal
674
+ */
675
+ setClusterLabels(clusterLabels) {
676
+ if (clusterLabels.clusterName) {
677
+ this._setAttributeOnAllSpans(observabilitytypes_1.OpAttributeName.ClusterName, clusterLabels.clusterName);
678
+ }
679
+ if (clusterLabels.clusterUUID) {
680
+ this._setAttributeOnAllSpans(observabilitytypes_1.OpAttributeName.ClusterUUID, clusterLabels.clusterUUID);
681
+ }
682
+ }
683
+ /**
684
+ * @internal
685
+ */
686
+ setRetryAttribute(retrCount = 0) {
687
+ this._setAttributeOnAllSpans(observabilitytypes_1.OpAttributeName.RetryCount, retrCount, true);
688
+ }
689
+ /**
690
+ * @internal
691
+ */
692
+ addEvent() { }
693
+ /**
694
+ * @internal
695
+ */
696
+ end(endTime) {
697
+ this._endTimeWatermark = (0, observabilityutilities_1.getLatestTime)(this._endTimeWatermark, endTime);
698
+ if (this._parentSpan && this._parentSpan instanceof WrappedSpan) {
699
+ this._parentSpan.maybeUpdateEndTimeWatermark(this._endTimeWatermark);
700
+ }
701
+ this._endEncodingSpans();
702
+ this._requestSpan.end(this._endTimeWatermark);
703
+ }
704
+ /**
705
+ * @internal
706
+ */
707
+ setAttribute(key, value) {
708
+ if (key === observabilitytypes_1.OpAttributeName.ClusterName) {
709
+ this._clusterName = value;
710
+ }
711
+ else if (key === observabilitytypes_1.OpAttributeName.ClusterUUID) {
712
+ this._clusterUUID = value;
713
+ }
714
+ this._requestSpan.setAttribute(key, value);
715
+ }
716
+ /**
717
+ * @internal
718
+ */
719
+ setStatus(status) {
720
+ var _a;
721
+ (_a = this._requestSpan) === null || _a === void 0 ? void 0 : _a.setStatus(status);
722
+ }
723
+ /**
724
+ * @internal
725
+ */
726
+ _createRequestSpan(spanName, startTime, parentSpan) {
727
+ if (typeof startTime === 'undefined') {
728
+ startTime = (0, observabilityutilities_1.timeInputToHiResTime)();
729
+ }
730
+ return this._tracer.requestSpan(spanName, parentSpan, startTime);
731
+ }
732
+ }
733
+ exports.WrappedSpan = WrappedSpan;