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.
- package/CMakeLists.txt +2 -1
- package/deps/couchbase-cxx-cache/mozilla-ca-bundle.crt +23 -5
- package/deps/couchbase-cxx-cache/mozilla-ca-bundle.sha256 +1 -1
- package/deps/couchbase-cxx-client/CMakeLists.txt +24 -11
- package/deps/couchbase-cxx-client/README.md +2 -2
- package/deps/couchbase-cxx-client/cmake/APKBUILD.in +17 -1
- package/deps/couchbase-cxx-client/cmake/Bundler.cmake +9 -1
- package/deps/couchbase-cxx-client/cmake/Cache.cmake +48 -19
- package/deps/couchbase-cxx-client/cmake/CompilerOptions.cmake +3 -1
- package/deps/couchbase-cxx-client/cmake/OpenSSL.cmake +10 -2
- package/deps/couchbase-cxx-client/cmake/Packaging.cmake +48 -8
- package/deps/couchbase-cxx-client/cmake/ThirdPartyDependencies.cmake +41 -0
- package/deps/couchbase-cxx-client/cmake/build_config.hxx.in +2 -0
- package/deps/couchbase-cxx-client/cmake/couchbase-cxx-client.spec.in +18 -0
- package/deps/couchbase-cxx-client/cmake/debian/control +6 -1
- package/deps/couchbase-cxx-client/cmake/debian/rules +1 -0
- package/deps/couchbase-cxx-client/cmake/tarball_glob.txt +10 -0
- package/deps/couchbase-cxx-client/core/app_telemetry_meter.cxx +1 -0
- package/deps/couchbase-cxx-client/core/app_telemetry_reporter.cxx +45 -43
- package/deps/couchbase-cxx-client/core/app_telemetry_reporter.hxx +4 -3
- package/deps/couchbase-cxx-client/core/bucket.cxx +128 -13
- package/deps/couchbase-cxx-client/core/bucket.hxx +12 -2
- package/deps/couchbase-cxx-client/core/cluster.cxx +304 -152
- package/deps/couchbase-cxx-client/core/cluster.hxx +32 -0
- package/deps/couchbase-cxx-client/core/cluster_credentials.cxx +25 -0
- package/deps/couchbase-cxx-client/core/cluster_credentials.hxx +5 -0
- package/deps/couchbase-cxx-client/core/cluster_label_listener.cxx +72 -0
- package/deps/couchbase-cxx-client/core/cluster_label_listener.hxx +46 -0
- package/deps/couchbase-cxx-client/core/cluster_options.hxx +4 -0
- package/deps/couchbase-cxx-client/core/deprecation_utils.hxx +26 -0
- package/deps/couchbase-cxx-client/core/error.hxx +27 -0
- package/deps/couchbase-cxx-client/core/free_form_http_request.hxx +0 -2
- package/deps/couchbase-cxx-client/core/http_component.cxx +12 -48
- package/deps/couchbase-cxx-client/core/impl/analytics.cxx +3 -2
- package/deps/couchbase-cxx-client/core/impl/analytics.hxx +2 -1
- package/deps/couchbase-cxx-client/core/impl/analytics_index_manager.cxx +249 -137
- package/deps/couchbase-cxx-client/core/impl/binary_collection.cxx +134 -58
- package/deps/couchbase-cxx-client/core/impl/bucket_manager.cxx +87 -35
- package/deps/couchbase-cxx-client/core/impl/collection.cxx +560 -245
- package/deps/couchbase-cxx-client/core/impl/collection_manager.cxx +89 -49
- package/deps/couchbase-cxx-client/core/impl/dns_srv_tracker.cxx +3 -3
- package/deps/couchbase-cxx-client/core/impl/error.cxx +20 -13
- package/deps/couchbase-cxx-client/core/impl/error.hxx +15 -10
- package/deps/couchbase-cxx-client/core/impl/get_all_replicas.hxx +1 -1
- package/deps/couchbase-cxx-client/core/impl/get_any_replica.hxx +2 -1
- package/deps/couchbase-cxx-client/core/impl/get_replica.hxx +2 -0
- package/deps/couchbase-cxx-client/core/impl/lookup_in_replica.hxx +1 -1
- package/deps/couchbase-cxx-client/core/impl/observability_recorder.cxx +161 -0
- package/deps/couchbase-cxx-client/core/impl/observability_recorder.hxx +77 -0
- package/deps/couchbase-cxx-client/core/impl/observe_seqno.hxx +2 -0
- package/deps/couchbase-cxx-client/core/impl/public_bucket.cxx +31 -7
- package/deps/couchbase-cxx-client/core/impl/public_cluster.cxx +107 -19
- package/deps/couchbase-cxx-client/core/impl/query.cxx +6 -3
- package/deps/couchbase-cxx-client/core/impl/query.hxx +3 -1
- package/deps/couchbase-cxx-client/core/impl/query_index_manager.cxx +267 -102
- package/deps/couchbase-cxx-client/core/impl/scope.cxx +53 -11
- package/deps/couchbase-cxx-client/core/impl/search.cxx +8 -4
- package/deps/couchbase-cxx-client/core/impl/search.hxx +6 -2
- package/deps/couchbase-cxx-client/core/impl/search_index_manager.cxx +131 -41
- package/deps/couchbase-cxx-client/core/impl/with_cancellation.hxx +75 -0
- package/deps/couchbase-cxx-client/core/io/config_tracker.cxx +9 -9
- package/deps/couchbase-cxx-client/core/io/config_tracker.hxx +2 -1
- package/deps/couchbase-cxx-client/core/io/http_command.hxx +98 -49
- package/deps/couchbase-cxx-client/core/io/http_context.hxx +2 -0
- package/deps/couchbase-cxx-client/core/io/http_session.cxx +23 -10
- package/deps/couchbase-cxx-client/core/io/http_session.hxx +17 -9
- package/deps/couchbase-cxx-client/core/io/http_session_manager.hxx +163 -228
- package/deps/couchbase-cxx-client/core/io/http_traits.hxx +0 -7
- package/deps/couchbase-cxx-client/core/io/mcbp_command.hxx +123 -44
- package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +251 -26
- package/deps/couchbase-cxx-client/core/io/mcbp_session.hxx +9 -1
- package/deps/couchbase-cxx-client/core/io/mcbp_traits.hxx +0 -8
- package/deps/couchbase-cxx-client/core/io/streams.cxx +3 -3
- package/deps/couchbase-cxx-client/core/io/streams.hxx +3 -2
- package/deps/couchbase-cxx-client/core/meta/features.hxx +15 -0
- package/deps/couchbase-cxx-client/core/meta/version.cxx +13 -0
- package/deps/couchbase-cxx-client/core/meta/version.hxx +3 -0
- package/deps/couchbase-cxx-client/core/metrics/constants.hxx +23 -0
- package/deps/couchbase-cxx-client/core/metrics/logging_meter.cxx +5 -5
- package/deps/couchbase-cxx-client/core/metrics/meter_wrapper.cxx +65 -63
- package/deps/couchbase-cxx-client/core/metrics/meter_wrapper.hxx +12 -10
- package/deps/couchbase-cxx-client/core/operations/document_analytics.hxx +0 -5
- package/deps/couchbase-cxx-client/core/operations/document_append.hxx +0 -4
- package/deps/couchbase-cxx-client/core/operations/document_decrement.hxx +0 -5
- package/deps/couchbase-cxx-client/core/operations/document_exists.hxx +0 -7
- package/deps/couchbase-cxx-client/core/operations/document_get.hxx +0 -7
- package/deps/couchbase-cxx-client/core/operations/document_get_all_replicas.hxx +77 -27
- package/deps/couchbase-cxx-client/core/operations/document_get_and_lock.hxx +0 -9
- package/deps/couchbase-cxx-client/core/operations/document_get_and_touch.hxx +0 -9
- package/deps/couchbase-cxx-client/core/operations/document_get_any_replica.hxx +83 -2
- package/deps/couchbase-cxx-client/core/operations/document_get_projected.hxx +0 -9
- package/deps/couchbase-cxx-client/core/operations/document_increment.hxx +0 -5
- package/deps/couchbase-cxx-client/core/operations/document_insert.hxx +0 -4
- package/deps/couchbase-cxx-client/core/operations/document_lookup_in.hxx +0 -9
- package/deps/couchbase-cxx-client/core/operations/document_lookup_in_all_replicas.hxx +46 -4
- package/deps/couchbase-cxx-client/core/operations/document_lookup_in_any_replica.hxx +121 -43
- package/deps/couchbase-cxx-client/core/operations/document_mutate_in.hxx +0 -5
- package/deps/couchbase-cxx-client/core/operations/document_prepend.hxx +0 -4
- package/deps/couchbase-cxx-client/core/operations/document_query.hxx +0 -4
- package/deps/couchbase-cxx-client/core/operations/document_remove.hxx +0 -4
- package/deps/couchbase-cxx-client/core/operations/document_replace.hxx +0 -4
- package/deps/couchbase-cxx-client/core/operations/document_search.hxx +0 -7
- package/deps/couchbase-cxx-client/core/operations/document_touch.hxx +0 -7
- package/deps/couchbase-cxx-client/core/operations/document_unlock.hxx +0 -6
- package/deps/couchbase-cxx-client/core/operations/document_upsert.hxx +0 -4
- package/deps/couchbase-cxx-client/core/operations/document_view.cxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/document_view.hxx +10 -13
- package/deps/couchbase-cxx-client/core/operations/http_noop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_create.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_drop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_get_all.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_dataverse_create.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_dataverse_drop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_get_pending_mutations.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_index_create.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_index_drop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_index_get_all.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_link_connect.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_link_create.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_link_disconnect.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_link_drop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_link_get_all.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_link_replace.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/bucket_create.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/bucket_describe.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/bucket_drop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/bucket_flush.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/bucket_get.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/bucket_get_all.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/bucket_update.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/change_password.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/cluster_describe.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/cluster_developer_preview_enable.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/collection_create.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/collection_drop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/collection_update.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/collections_manifest_get.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/error_utils.cxx +4 -1
- package/deps/couchbase-cxx-client/core/operations/management/eventing_deploy_function.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/eventing_drop_function.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/eventing_get_all_functions.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/eventing_get_function.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/eventing_get_status.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/eventing_pause_function.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/eventing_resume_function.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/eventing_undeploy_function.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/eventing_upsert_function.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/freeform.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/group_drop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/group_get.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/group_get_all.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/group_upsert.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/query_index_build.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/query_index_build_deferred.hxx +68 -30
- package/deps/couchbase-cxx-client/core/operations/management/query_index_create.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/query_index_drop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all.hxx +4 -3
- package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all_deferred.hxx +2 -1
- package/deps/couchbase-cxx-client/core/operations/management/role_get_all.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/scope_create.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/scope_drop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/scope_get_all.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_get_stats.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get_stats.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/user_drop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/user_get.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/user_get_all.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/user_upsert.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/view_index_drop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/view_index_get.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/view_index_get_all.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/view_index_upsert.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/operation_traits.hxx +6 -0
- package/deps/couchbase-cxx-client/core/operations.hxx +0 -1
- package/deps/couchbase-cxx-client/core/operations_fwd.hxx +8 -0
- package/deps/couchbase-cxx-client/core/origin.cxx +67 -12
- package/deps/couchbase-cxx-client/core/origin.hxx +13 -8
- package/deps/couchbase-cxx-client/core/orphan_reporter.cxx +164 -0
- package/deps/couchbase-cxx-client/core/orphan_reporter.hxx +65 -0
- package/deps/couchbase-cxx-client/core/sasl/CMakeLists.txt +1 -0
- package/deps/couchbase-cxx-client/core/sasl/client.cc +6 -0
- package/deps/couchbase-cxx-client/core/sasl/mechanism.cc +2 -1
- package/deps/couchbase-cxx-client/core/sasl/mechanism.h +2 -1
- package/deps/couchbase-cxx-client/core/sasl/oauthbearer/oauthbearer.cc +41 -0
- package/deps/couchbase-cxx-client/core/sasl/oauthbearer/oauthbearer.h +47 -0
- package/deps/couchbase-cxx-client/core/tls_context_provider.cxx +44 -0
- package/deps/couchbase-cxx-client/core/tls_context_provider.hxx +44 -0
- package/deps/couchbase-cxx-client/core/tracing/attribute_helpers.hxx +45 -0
- package/deps/couchbase-cxx-client/core/tracing/constants.hxx +148 -68
- package/deps/couchbase-cxx-client/core/tracing/threshold_logging_options.hxx +0 -3
- package/deps/couchbase-cxx-client/core/tracing/threshold_logging_tracer.cxx +122 -170
- package/deps/couchbase-cxx-client/core/tracing/tracer_wrapper.cxx +17 -24
- package/deps/couchbase-cxx-client/core/tracing/tracer_wrapper.hxx +8 -10
- package/deps/couchbase-cxx-client/core/tracing/wrapper_sdk_tracer.cxx +114 -0
- package/deps/couchbase-cxx-client/core/tracing/wrapper_sdk_tracer.hxx +85 -0
- package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.cxx +16 -14
- package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.hxx +4 -4
- package/deps/couchbase-cxx-client/core/transactions/transactions.cxx +1 -1
- package/deps/couchbase-cxx-client/core/transactions/transactions_cleanup.cxx +1 -2
- package/deps/couchbase-cxx-client/core/utils/byteswap.hxx +12 -0
- package/deps/couchbase-cxx-client/core/utils/concurrent_fixed_priority_queue.hxx +102 -0
- package/deps/couchbase-cxx-client/core/utils/connection_string.cxx +2 -0
- package/deps/couchbase-cxx-client/couchbase/certificate_authenticator.hxx +1 -0
- package/deps/couchbase-cxx-client/couchbase/cluster.hxx +47 -0
- package/deps/couchbase-cxx-client/couchbase/cluster_options.hxx +16 -0
- package/deps/couchbase-cxx-client/couchbase/collection.hxx +60 -15
- package/deps/couchbase-cxx-client/couchbase/error_codes.hxx +48 -48
- package/deps/couchbase-cxx-client/couchbase/jwt_authenticator.hxx +52 -0
- package/deps/couchbase-cxx-client/couchbase/metrics/meter.hxx +2 -1
- package/deps/couchbase-cxx-client/couchbase/metrics/otel_meter.hxx +75 -80
- package/deps/couchbase-cxx-client/couchbase/network_options.hxx +19 -0
- package/deps/couchbase-cxx-client/couchbase/password_authenticator.hxx +1 -0
- package/deps/couchbase-cxx-client/couchbase/tracing/otel_tracer.hxx +15 -17
- package/deps/couchbase-cxx-client/couchbase/tracing/request_span.hxx +2 -2
- package/dist/analyticsexecutor.d.ts +15 -0
- package/dist/analyticsexecutor.js +79 -50
- package/dist/analyticsindexmanager.d.ts +66 -0
- package/dist/analyticsindexmanager.js +404 -277
- package/dist/analyticstypes.d.ts +5 -0
- package/dist/authenticators.d.ts +34 -1
- package/dist/authenticators.js +19 -1
- package/dist/binarycollection.d.ts +17 -0
- package/dist/binding.d.ts +245 -228
- package/dist/bindingutilities.js +1 -1
- package/dist/bucket.d.ts +8 -0
- package/dist/bucket.js +8 -0
- package/dist/bucketmanager.d.ts +30 -0
- package/dist/bucketmanager.js +128 -69
- package/dist/cluster.d.ts +45 -0
- package/dist/cluster.js +133 -21
- package/dist/collection.d.ts +75 -2
- package/dist/collection.js +772 -551
- package/dist/collectionmanager.d.ts +34 -0
- package/dist/collectionmanager.js +172 -89
- package/dist/couchbase.d.ts +5 -0
- package/dist/couchbase.js +5 -0
- package/dist/datastructures.js +310 -97
- package/dist/errors.d.ts +8 -0
- package/dist/errors.js +12 -1
- package/dist/eventingfunctionmanager.d.ts +42 -0
- package/dist/eventingfunctionmanager.js +172 -100
- package/dist/logger.d.ts +192 -0
- package/dist/logger.js +213 -0
- package/dist/loggingmeter.d.ts +120 -0
- package/dist/loggingmeter.js +226 -0
- package/dist/metrics.d.ts +33 -0
- package/dist/metrics.js +5 -0
- package/dist/observability.d.ts +60 -0
- package/dist/observability.js +86 -0
- package/dist/observabilityhandler.d.ts +176 -0
- package/dist/observabilityhandler.js +733 -0
- package/dist/observabilitytypes.d.ts +320 -0
- package/dist/observabilitytypes.js +362 -0
- package/dist/observabilityutilities.d.ts +60 -0
- package/dist/observabilityutilities.js +175 -0
- package/dist/otelmeter.d.ts +51 -0
- package/dist/otelmeter.js +100 -0
- package/dist/oteltracer.d.ts +69 -0
- package/dist/oteltracer.js +141 -0
- package/dist/queryexecutor.d.ts +16 -0
- package/dist/queryexecutor.js +128 -86
- package/dist/queryindexmanager.d.ts +29 -0
- package/dist/queryindexmanager.js +277 -150
- package/dist/querytypes.d.ts +5 -0
- package/dist/scope.js +2 -2
- package/dist/scopeeventingfunctionmanager.d.ts +5 -0
- package/dist/scopeeventingfunctionmanager.js +217 -119
- package/dist/scopesearchindexmanager.d.ts +5 -0
- package/dist/scopesearchindexmanager.js +295 -166
- package/dist/sdspecs.js +6 -1
- package/dist/searchexecutor.d.ts +15 -0
- package/dist/searchexecutor.js +54 -26
- package/dist/searchindexmanager.d.ts +54 -0
- package/dist/searchindexmanager.js +235 -142
- package/dist/searchtypes.d.ts +5 -0
- package/dist/thresholdlogging.d.ts +301 -0
- package/dist/thresholdlogging.js +657 -0
- package/dist/tracing.d.ts +55 -0
- package/dist/tracing.js +2 -0
- package/dist/usermanager.d.ts +46 -0
- package/dist/usermanager.js +199 -118
- package/dist/utilities.d.ts +4 -0
- package/dist/utilities.js +11 -1
- package/dist/version.d.ts +2 -0
- package/dist/version.js +7 -0
- package/dist/viewexecutor.d.ts +15 -0
- package/dist/viewexecutor.js +54 -29
- package/dist/viewindexmanager.d.ts +30 -0
- package/dist/viewindexmanager.js +129 -100
- package/dist/viewtypes.d.ts +5 -0
- package/package.json +19 -9
- package/scripts/prebuilds.js +1 -1
- package/scripts/updateVersion.js +26 -0
- package/src/connection.cpp +79 -98
- package/src/connection.hpp +46 -38
- package/src/connection_autogen.cpp +1236 -292
- package/src/jstocbpp_autogen.hpp +1117 -313
- package/src/jstocbpp_basic.hpp +73 -0
- package/src/jstocbpp_defs.hpp +37 -9
- package/src/jstocbpp_errors.hpp +37 -11
- package/tools/gen-bindings-js.js +100 -22
- package/tools/gen-bindings-json.py +40 -6
- package/src/transcoder.hpp +0 -96
package/dist/collection.js
CHANGED
|
@@ -31,6 +31,9 @@ const crudoptypes_1 = require("./crudoptypes");
|
|
|
31
31
|
const datastructures_1 = require("./datastructures");
|
|
32
32
|
const errors_1 = require("./errors");
|
|
33
33
|
const generaltypes_1 = require("./generaltypes");
|
|
34
|
+
const observability_1 = require("./observability");
|
|
35
|
+
const observabilityhandler_1 = require("./observabilityhandler");
|
|
36
|
+
const observabilitytypes_1 = require("./observabilitytypes");
|
|
34
37
|
const queryindexmanager_1 = require("./queryindexmanager");
|
|
35
38
|
const rangeScan_1 = require("./rangeScan");
|
|
36
39
|
const sdspecs_1 = require("./sdspecs");
|
|
@@ -85,6 +88,12 @@ class Collection {
|
|
|
85
88
|
get transcoder() {
|
|
86
89
|
return this._scope.transcoder;
|
|
87
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* @internal
|
|
93
|
+
*/
|
|
94
|
+
get observabilityInstruments() {
|
|
95
|
+
return this._scope.bucket.cluster.observabilityInstruments;
|
|
96
|
+
}
|
|
88
97
|
/**
|
|
89
98
|
@internal
|
|
90
99
|
*/
|
|
@@ -171,35 +180,41 @@ class Collection {
|
|
|
171
180
|
if (!options) {
|
|
172
181
|
options = {};
|
|
173
182
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
183
|
+
const obsReqHandler = new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.Get, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
184
|
+
try {
|
|
185
|
+
const cppDocId = this._cppDocId(key);
|
|
186
|
+
obsReqHandler.setRequestKeyValueAttributes(cppDocId);
|
|
187
|
+
if (options.project || options.withExpiry) {
|
|
188
|
+
options.parentSpan = obsReqHandler.wrappedSpan;
|
|
189
|
+
return this._projectedGet(key, options, obsReqHandler, callback);
|
|
190
|
+
}
|
|
191
|
+
const transcoder = options.transcoder || this.transcoder;
|
|
192
|
+
const timeout = options.timeout || this.cluster.kvTimeout;
|
|
193
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
194
|
+
const [err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.get.bind(this._conn), {
|
|
195
|
+
id: cppDocId,
|
|
196
|
+
timeout,
|
|
197
|
+
partition: 0,
|
|
198
|
+
opaque: 0,
|
|
199
|
+
}, obsReqHandler);
|
|
187
200
|
if (err) {
|
|
188
|
-
|
|
201
|
+
obsReqHandler.endWithError(err);
|
|
202
|
+
throw err;
|
|
189
203
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
content: content,
|
|
196
|
-
cas: resp.cas,
|
|
197
|
-
}));
|
|
204
|
+
const content = transcoder.decode(resp.value, resp.flags);
|
|
205
|
+
obsReqHandler.end();
|
|
206
|
+
return new crudoptypes_1.GetResult({
|
|
207
|
+
content: content,
|
|
208
|
+
cas: resp.cas,
|
|
198
209
|
});
|
|
199
|
-
});
|
|
200
|
-
}
|
|
210
|
+
}, callback);
|
|
211
|
+
}
|
|
212
|
+
catch (e) {
|
|
213
|
+
obsReqHandler.endWithError(e);
|
|
214
|
+
throw e;
|
|
215
|
+
}
|
|
201
216
|
}
|
|
202
|
-
_projectedGet(key, options, callback) {
|
|
217
|
+
_projectedGet(key, options, obsReqHandler, callback) {
|
|
203
218
|
let expiryStart = -1;
|
|
204
219
|
let projStart = -1;
|
|
205
220
|
let paths = [];
|
|
@@ -233,9 +248,16 @@ class Collection {
|
|
|
233
248
|
needReproject = true;
|
|
234
249
|
}
|
|
235
250
|
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
251
|
+
let res;
|
|
252
|
+
try {
|
|
253
|
+
res = await this.lookupIn(key, spec, {
|
|
254
|
+
...options,
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
catch (e) {
|
|
258
|
+
obsReqHandler.endWithError(e);
|
|
259
|
+
throw e;
|
|
260
|
+
}
|
|
239
261
|
let content = null;
|
|
240
262
|
let expiry = undefined;
|
|
241
263
|
if (expiryStart >= 0) {
|
|
@@ -262,6 +284,8 @@ class Collection {
|
|
|
262
284
|
}
|
|
263
285
|
}
|
|
264
286
|
}
|
|
287
|
+
// The parent span is created w/in the get() operation
|
|
288
|
+
obsReqHandler.end();
|
|
265
289
|
return new crudoptypes_1.GetResult({
|
|
266
290
|
content: content,
|
|
267
291
|
cas: res.cas,
|
|
@@ -284,101 +308,109 @@ class Collection {
|
|
|
284
308
|
if (!options) {
|
|
285
309
|
options = {};
|
|
286
310
|
}
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
this.
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
311
|
+
const obsReqHandler = new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.Exists, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
312
|
+
try {
|
|
313
|
+
const cppDocId = this._cppDocId(key);
|
|
314
|
+
const timeout = options.timeout || this.cluster.kvTimeout;
|
|
315
|
+
obsReqHandler.setRequestKeyValueAttributes(cppDocId);
|
|
316
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
317
|
+
const [err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.exists.bind(this._conn), {
|
|
318
|
+
id: cppDocId,
|
|
319
|
+
partition: 0,
|
|
320
|
+
opaque: 0,
|
|
321
|
+
timeout,
|
|
322
|
+
}, obsReqHandler);
|
|
296
323
|
if (err) {
|
|
297
|
-
|
|
324
|
+
obsReqHandler.endWithError(err);
|
|
325
|
+
throw err;
|
|
298
326
|
}
|
|
327
|
+
obsReqHandler.end();
|
|
299
328
|
if (resp.deleted) {
|
|
300
|
-
return
|
|
329
|
+
return new crudoptypes_1.ExistsResult({
|
|
301
330
|
cas: undefined,
|
|
302
331
|
exists: false,
|
|
303
|
-
})
|
|
332
|
+
});
|
|
304
333
|
}
|
|
305
|
-
|
|
334
|
+
return new crudoptypes_1.ExistsResult({
|
|
306
335
|
cas: resp.cas,
|
|
307
336
|
exists: resp.document_exists,
|
|
308
|
-
})
|
|
309
|
-
});
|
|
310
|
-
}
|
|
337
|
+
});
|
|
338
|
+
}, callback);
|
|
339
|
+
}
|
|
340
|
+
catch (e) {
|
|
341
|
+
obsReqHandler.endWithError(e);
|
|
342
|
+
throw e;
|
|
343
|
+
}
|
|
311
344
|
}
|
|
312
345
|
/**
|
|
313
346
|
* @internal
|
|
314
347
|
*/
|
|
315
|
-
_getReplica(key,
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
options = undefined;
|
|
319
|
-
}
|
|
320
|
-
if (!options) {
|
|
321
|
-
options = {};
|
|
322
|
-
}
|
|
348
|
+
_getReplica(key, obsReqHandler, options, callback) {
|
|
349
|
+
const cppDocId = this._cppDocId(key);
|
|
350
|
+
obsReqHandler.setRequestKeyValueAttributes(cppDocId);
|
|
323
351
|
const emitter = new streamablepromises_1.StreamableReplicasPromise((replicas) => replicas);
|
|
324
352
|
const transcoder = options.transcoder || this.transcoder;
|
|
325
353
|
const timeout = options.timeout || this.cluster.kvTimeout;
|
|
326
|
-
if (
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
354
|
+
if (obsReqHandler.opType == observabilitytypes_1.KeyValueOp.GetAllReplicas) {
|
|
355
|
+
utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
356
|
+
const [err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.getAllReplicas.bind(this._conn), {
|
|
357
|
+
id: cppDocId,
|
|
358
|
+
timeout: timeout,
|
|
359
|
+
read_preference: (0, bindingutilities_1.readPreferenceToCpp)(options.readPreference),
|
|
360
|
+
}, obsReqHandler);
|
|
333
361
|
if (err) {
|
|
362
|
+
obsReqHandler.endWithError(err);
|
|
334
363
|
emitter.emit('error', err);
|
|
335
364
|
emitter.emit('end');
|
|
336
365
|
return;
|
|
337
366
|
}
|
|
338
367
|
resp.entries.forEach((replica) => {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
emitter.emit('error', err);
|
|
342
|
-
emitter.emit('end');
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
368
|
+
try {
|
|
369
|
+
const content = transcoder.decode(replica.value, replica.flags);
|
|
345
370
|
emitter.emit('replica', new crudoptypes_1.GetReplicaResult({
|
|
346
371
|
content: content,
|
|
347
372
|
cas: replica.cas,
|
|
348
373
|
isReplica: replica.replica,
|
|
349
374
|
}));
|
|
350
|
-
}
|
|
375
|
+
}
|
|
376
|
+
catch (err) {
|
|
377
|
+
obsReqHandler.endWithError(err);
|
|
378
|
+
emitter.emit('error', err);
|
|
379
|
+
emitter.emit('end');
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
351
382
|
});
|
|
383
|
+
obsReqHandler.end();
|
|
352
384
|
emitter.emit('end');
|
|
353
|
-
return;
|
|
354
385
|
});
|
|
355
386
|
}
|
|
356
387
|
else {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
388
|
+
utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
389
|
+
const [err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.getAnyReplica.bind(this._conn), {
|
|
390
|
+
id: cppDocId,
|
|
391
|
+
timeout: timeout,
|
|
392
|
+
read_preference: (0, bindingutilities_1.readPreferenceToCpp)(options.readPreference),
|
|
393
|
+
}, obsReqHandler);
|
|
363
394
|
if (err) {
|
|
395
|
+
obsReqHandler.endWithError(err);
|
|
364
396
|
emitter.emit('error', err);
|
|
365
397
|
emitter.emit('end');
|
|
366
398
|
return;
|
|
367
399
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
emitter.emit('error', err);
|
|
371
|
-
emitter.emit('end');
|
|
372
|
-
return;
|
|
373
|
-
}
|
|
400
|
+
try {
|
|
401
|
+
const content = transcoder.decode(resp.value, resp.flags);
|
|
374
402
|
emitter.emit('replica', new crudoptypes_1.GetReplicaResult({
|
|
375
403
|
content: content,
|
|
376
404
|
cas: resp.cas,
|
|
377
405
|
isReplica: resp.replica,
|
|
378
406
|
}));
|
|
379
|
-
}
|
|
407
|
+
}
|
|
408
|
+
catch (err) {
|
|
409
|
+
obsReqHandler.endWithError(err);
|
|
410
|
+
emitter.emit('error', err);
|
|
411
|
+
}
|
|
412
|
+
obsReqHandler.end();
|
|
380
413
|
emitter.emit('end');
|
|
381
|
-
return;
|
|
382
414
|
});
|
|
383
415
|
}
|
|
384
416
|
return utilities_1.PromiseHelper.wrapAsync(() => emitter, callback);
|
|
@@ -396,10 +428,20 @@ class Collection {
|
|
|
396
428
|
callback = arguments[1];
|
|
397
429
|
options = undefined;
|
|
398
430
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
431
|
+
if (!options) {
|
|
432
|
+
options = {};
|
|
433
|
+
}
|
|
434
|
+
const obsReqHandler = new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.GetAnyReplica, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
435
|
+
try {
|
|
436
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
437
|
+
const replicas = await this._getReplica(key, obsReqHandler, options);
|
|
438
|
+
return replicas[0];
|
|
439
|
+
}, callback);
|
|
440
|
+
}
|
|
441
|
+
catch (e) {
|
|
442
|
+
obsReqHandler.endWithError(e);
|
|
443
|
+
throw e;
|
|
444
|
+
}
|
|
403
445
|
}
|
|
404
446
|
/**
|
|
405
447
|
* Retrieves the value of the document from all available replicas. Note that
|
|
@@ -410,7 +452,21 @@ class Collection {
|
|
|
410
452
|
* @param callback A node-style callback to be invoked after execution.
|
|
411
453
|
*/
|
|
412
454
|
getAllReplicas(key, options, callback) {
|
|
413
|
-
|
|
455
|
+
if (options instanceof Function) {
|
|
456
|
+
callback = arguments[1];
|
|
457
|
+
options = undefined;
|
|
458
|
+
}
|
|
459
|
+
if (!options) {
|
|
460
|
+
options = {};
|
|
461
|
+
}
|
|
462
|
+
const obsReqHandler = new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.GetAllReplicas, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
463
|
+
try {
|
|
464
|
+
return this._getReplica(key, obsReqHandler, options, callback);
|
|
465
|
+
}
|
|
466
|
+
catch (e) {
|
|
467
|
+
obsReqHandler.endWithError(e);
|
|
468
|
+
throw e;
|
|
469
|
+
}
|
|
414
470
|
}
|
|
415
471
|
/**
|
|
416
472
|
* Inserts a new document to the collection, failing if the document already exists.
|
|
@@ -428,51 +484,61 @@ class Collection {
|
|
|
428
484
|
if (!options) {
|
|
429
485
|
options = {};
|
|
430
486
|
}
|
|
431
|
-
const
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
wrapCallback(err, new crudoptypes_1.MutationResult({
|
|
457
|
-
cas: resp.cas,
|
|
458
|
-
token: resp.token,
|
|
459
|
-
}));
|
|
460
|
-
};
|
|
487
|
+
const obsReqHandler = new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.Insert, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
488
|
+
try {
|
|
489
|
+
const cppDocId = this._cppDocId(key);
|
|
490
|
+
const cppDurability = (0, bindingutilities_1.durabilityToCpp)(options.durabilityLevel);
|
|
491
|
+
const expiry = (0, utilities_1.parseExpiry)(options.expiry);
|
|
492
|
+
const transcoder = options.transcoder || this.transcoder;
|
|
493
|
+
const persistTo = options.durabilityPersistTo;
|
|
494
|
+
const replicateTo = options.durabilityReplicateTo;
|
|
495
|
+
const timeout = options.timeout || this._mutationTimeout(options.durabilityLevel);
|
|
496
|
+
obsReqHandler.setRequestKeyValueAttributes(cppDocId, cppDurability);
|
|
497
|
+
const [bytesBuf, flags] = obsReqHandler.maybeCreateEncodingSpan(() => {
|
|
498
|
+
return transcoder.encode(value);
|
|
499
|
+
});
|
|
500
|
+
const insertReq = {
|
|
501
|
+
id: cppDocId,
|
|
502
|
+
value: bytesBuf,
|
|
503
|
+
flags: flags,
|
|
504
|
+
expiry: expiry,
|
|
505
|
+
timeout,
|
|
506
|
+
partition: 0,
|
|
507
|
+
opaque: 0,
|
|
508
|
+
};
|
|
509
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
510
|
+
let err = null;
|
|
511
|
+
let resp = null;
|
|
461
512
|
if (persistTo || replicateTo) {
|
|
462
|
-
|
|
513
|
+
;
|
|
514
|
+
[err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.insertWithLegacyDurability.bind(this._conn), {
|
|
463
515
|
...insertReq,
|
|
464
516
|
persist_to: (0, bindingutilities_1.persistToToCpp)(persistTo),
|
|
465
517
|
replicate_to: (0, bindingutilities_1.replicateToToCpp)(replicateTo),
|
|
466
|
-
},
|
|
518
|
+
}, obsReqHandler);
|
|
467
519
|
}
|
|
468
520
|
else {
|
|
469
|
-
|
|
521
|
+
;
|
|
522
|
+
[err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.insert.bind(this._conn), {
|
|
470
523
|
...insertReq,
|
|
471
|
-
durability_level:
|
|
472
|
-
},
|
|
524
|
+
durability_level: cppDurability,
|
|
525
|
+
}, obsReqHandler);
|
|
473
526
|
}
|
|
474
|
-
|
|
475
|
-
|
|
527
|
+
if (err) {
|
|
528
|
+
obsReqHandler.endWithError(err);
|
|
529
|
+
throw err;
|
|
530
|
+
}
|
|
531
|
+
obsReqHandler.end();
|
|
532
|
+
return new crudoptypes_1.MutationResult({
|
|
533
|
+
cas: resp.cas,
|
|
534
|
+
token: resp.token,
|
|
535
|
+
});
|
|
536
|
+
}, callback);
|
|
537
|
+
}
|
|
538
|
+
catch (e) {
|
|
539
|
+
obsReqHandler.endWithError(e);
|
|
540
|
+
throw e;
|
|
541
|
+
}
|
|
476
542
|
}
|
|
477
543
|
/**
|
|
478
544
|
* Upserts a document to the collection. This operation succeeds whether or not the
|
|
@@ -491,53 +557,63 @@ class Collection {
|
|
|
491
557
|
if (!options) {
|
|
492
558
|
options = {};
|
|
493
559
|
}
|
|
494
|
-
const
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
wrapCallback(err, new crudoptypes_1.MutationResult({
|
|
522
|
-
cas: resp.cas,
|
|
523
|
-
token: resp.token,
|
|
524
|
-
}));
|
|
525
|
-
};
|
|
560
|
+
const obsReqHandler = new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.Upsert, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
561
|
+
try {
|
|
562
|
+
const cppDocId = this._cppDocId(key);
|
|
563
|
+
const cppDurability = (0, bindingutilities_1.durabilityToCpp)(options.durabilityLevel);
|
|
564
|
+
const expiry = (0, utilities_1.parseExpiry)(options.expiry);
|
|
565
|
+
const preserve_expiry = options.preserveExpiry;
|
|
566
|
+
const transcoder = options.transcoder || this.transcoder;
|
|
567
|
+
const persistTo = options.durabilityPersistTo;
|
|
568
|
+
const replicateTo = options.durabilityReplicateTo;
|
|
569
|
+
const timeout = options.timeout || this._mutationTimeout(options.durabilityLevel);
|
|
570
|
+
obsReqHandler.setRequestKeyValueAttributes(cppDocId, cppDurability);
|
|
571
|
+
const [bytesBuf, flags] = obsReqHandler.maybeCreateEncodingSpan(() => {
|
|
572
|
+
return transcoder.encode(value);
|
|
573
|
+
});
|
|
574
|
+
const upsertReq = {
|
|
575
|
+
id: cppDocId,
|
|
576
|
+
value: bytesBuf,
|
|
577
|
+
flags: flags,
|
|
578
|
+
expiry: expiry,
|
|
579
|
+
preserve_expiry: preserve_expiry || false,
|
|
580
|
+
timeout,
|
|
581
|
+
partition: 0,
|
|
582
|
+
opaque: 0,
|
|
583
|
+
};
|
|
584
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
585
|
+
let err = null;
|
|
586
|
+
let resp = null;
|
|
526
587
|
if (persistTo || replicateTo) {
|
|
527
|
-
|
|
588
|
+
;
|
|
589
|
+
[err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.upsertWithLegacyDurability.bind(this._conn), {
|
|
528
590
|
...upsertReq,
|
|
529
591
|
persist_to: (0, bindingutilities_1.persistToToCpp)(persistTo),
|
|
530
592
|
replicate_to: (0, bindingutilities_1.replicateToToCpp)(replicateTo),
|
|
531
|
-
},
|
|
593
|
+
}, obsReqHandler);
|
|
532
594
|
}
|
|
533
595
|
else {
|
|
534
|
-
|
|
596
|
+
;
|
|
597
|
+
[err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.upsert.bind(this._conn), {
|
|
535
598
|
...upsertReq,
|
|
536
|
-
durability_level:
|
|
537
|
-
},
|
|
599
|
+
durability_level: cppDurability,
|
|
600
|
+
}, obsReqHandler);
|
|
538
601
|
}
|
|
539
|
-
|
|
540
|
-
|
|
602
|
+
if (err) {
|
|
603
|
+
obsReqHandler.endWithError(err);
|
|
604
|
+
throw err;
|
|
605
|
+
}
|
|
606
|
+
obsReqHandler.end();
|
|
607
|
+
return new crudoptypes_1.MutationResult({
|
|
608
|
+
cas: resp.cas,
|
|
609
|
+
token: resp.token,
|
|
610
|
+
});
|
|
611
|
+
}, callback);
|
|
612
|
+
}
|
|
613
|
+
catch (e) {
|
|
614
|
+
obsReqHandler.endWithError(e);
|
|
615
|
+
throw e;
|
|
616
|
+
}
|
|
541
617
|
}
|
|
542
618
|
/**
|
|
543
619
|
* Replaces the value of an existing document. Failing if the document does not exist.
|
|
@@ -555,55 +631,65 @@ class Collection {
|
|
|
555
631
|
if (!options) {
|
|
556
632
|
options = {};
|
|
557
633
|
}
|
|
558
|
-
const
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
wrapCallback(err, new crudoptypes_1.MutationResult({
|
|
588
|
-
cas: resp.cas,
|
|
589
|
-
token: resp.token,
|
|
590
|
-
}));
|
|
591
|
-
};
|
|
634
|
+
const obsReqHandler = new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.Replace, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
635
|
+
try {
|
|
636
|
+
const cppDocId = this._cppDocId(key);
|
|
637
|
+
const cppDurability = (0, bindingutilities_1.durabilityToCpp)(options.durabilityLevel);
|
|
638
|
+
const expiry = (0, utilities_1.parseExpiry)(options.expiry);
|
|
639
|
+
const cas = options.cas;
|
|
640
|
+
const preserve_expiry = options.preserveExpiry;
|
|
641
|
+
const transcoder = options.transcoder || this.transcoder;
|
|
642
|
+
const persistTo = options.durabilityPersistTo;
|
|
643
|
+
const replicateTo = options.durabilityReplicateTo;
|
|
644
|
+
const timeout = options.timeout || this._mutationTimeout(options.durabilityLevel);
|
|
645
|
+
obsReqHandler.setRequestKeyValueAttributes(cppDocId, cppDurability);
|
|
646
|
+
const [bytesBuf, flags] = obsReqHandler.maybeCreateEncodingSpan(() => {
|
|
647
|
+
return transcoder.encode(value);
|
|
648
|
+
});
|
|
649
|
+
const replaceReq = {
|
|
650
|
+
id: cppDocId,
|
|
651
|
+
value: bytesBuf,
|
|
652
|
+
flags: flags,
|
|
653
|
+
expiry,
|
|
654
|
+
cas: cas || binding_1.zeroCas,
|
|
655
|
+
preserve_expiry: preserve_expiry || false,
|
|
656
|
+
timeout,
|
|
657
|
+
partition: 0,
|
|
658
|
+
opaque: 0,
|
|
659
|
+
};
|
|
660
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
661
|
+
let err = null;
|
|
662
|
+
let resp = null;
|
|
592
663
|
if (persistTo || replicateTo) {
|
|
593
|
-
|
|
664
|
+
;
|
|
665
|
+
[err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.replaceWithLegacyDurability.bind(this._conn), {
|
|
594
666
|
...replaceReq,
|
|
595
667
|
persist_to: (0, bindingutilities_1.persistToToCpp)(persistTo),
|
|
596
668
|
replicate_to: (0, bindingutilities_1.replicateToToCpp)(replicateTo),
|
|
597
|
-
},
|
|
669
|
+
}, obsReqHandler);
|
|
598
670
|
}
|
|
599
671
|
else {
|
|
600
|
-
|
|
672
|
+
;
|
|
673
|
+
[err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.replace.bind(this._conn), {
|
|
601
674
|
...replaceReq,
|
|
602
|
-
durability_level:
|
|
603
|
-
},
|
|
675
|
+
durability_level: cppDurability,
|
|
676
|
+
}, obsReqHandler);
|
|
604
677
|
}
|
|
605
|
-
|
|
606
|
-
|
|
678
|
+
if (err) {
|
|
679
|
+
obsReqHandler.endWithError(err);
|
|
680
|
+
throw err;
|
|
681
|
+
}
|
|
682
|
+
obsReqHandler.end();
|
|
683
|
+
return new crudoptypes_1.MutationResult({
|
|
684
|
+
cas: resp.cas,
|
|
685
|
+
token: resp.token,
|
|
686
|
+
});
|
|
687
|
+
}, callback);
|
|
688
|
+
}
|
|
689
|
+
catch (e) {
|
|
690
|
+
obsReqHandler.endWithError(e);
|
|
691
|
+
throw e;
|
|
692
|
+
}
|
|
607
693
|
}
|
|
608
694
|
/**
|
|
609
695
|
* Remove an existing document from the collection.
|
|
@@ -620,43 +706,55 @@ class Collection {
|
|
|
620
706
|
if (!options) {
|
|
621
707
|
options = {};
|
|
622
708
|
}
|
|
623
|
-
const
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
709
|
+
const obsReqHandler = new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.Remove, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
710
|
+
try {
|
|
711
|
+
const cppDocId = this._cppDocId(key);
|
|
712
|
+
const cppDurability = (0, bindingutilities_1.durabilityToCpp)(options.durabilityLevel);
|
|
713
|
+
const cas = options.cas;
|
|
714
|
+
const persistTo = options.durabilityPersistTo;
|
|
715
|
+
const replicateTo = options.durabilityReplicateTo;
|
|
716
|
+
const timeout = options.timeout || this._mutationTimeout(options.durabilityLevel);
|
|
717
|
+
obsReqHandler.setRequestKeyValueAttributes(cppDocId, cppDurability);
|
|
629
718
|
const removeReq = {
|
|
630
|
-
id:
|
|
719
|
+
id: cppDocId,
|
|
631
720
|
cas: cas || binding_1.zeroCas,
|
|
632
721
|
timeout,
|
|
633
722
|
partition: 0,
|
|
634
723
|
opaque: 0,
|
|
635
724
|
};
|
|
636
|
-
|
|
637
|
-
|
|
725
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
726
|
+
let err = null;
|
|
727
|
+
let resp = null;
|
|
728
|
+
if (persistTo || replicateTo) {
|
|
729
|
+
;
|
|
730
|
+
[err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.removeWithLegacyDurability.bind(this._conn), {
|
|
731
|
+
...removeReq,
|
|
732
|
+
persist_to: (0, bindingutilities_1.persistToToCpp)(persistTo),
|
|
733
|
+
replicate_to: (0, bindingutilities_1.replicateToToCpp)(replicateTo),
|
|
734
|
+
}, obsReqHandler);
|
|
735
|
+
}
|
|
736
|
+
else {
|
|
737
|
+
;
|
|
738
|
+
[err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.remove.bind(this._conn), {
|
|
739
|
+
...removeReq,
|
|
740
|
+
durability_level: cppDurability,
|
|
741
|
+
}, obsReqHandler);
|
|
742
|
+
}
|
|
638
743
|
if (err) {
|
|
639
|
-
|
|
744
|
+
obsReqHandler.endWithError(err);
|
|
745
|
+
throw err;
|
|
640
746
|
}
|
|
641
|
-
|
|
747
|
+
obsReqHandler.end();
|
|
748
|
+
return new crudoptypes_1.MutationResult({
|
|
642
749
|
cas: resp.cas,
|
|
643
750
|
token: resp.token,
|
|
644
|
-
})
|
|
645
|
-
};
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
}, removeCallback);
|
|
652
|
-
}
|
|
653
|
-
else {
|
|
654
|
-
this._conn.remove({
|
|
655
|
-
...removeReq,
|
|
656
|
-
durability_level: (0, bindingutilities_1.durabilityToCpp)(durabilityLevel),
|
|
657
|
-
}, removeCallback);
|
|
658
|
-
}
|
|
659
|
-
}, callback);
|
|
751
|
+
});
|
|
752
|
+
}, callback);
|
|
753
|
+
}
|
|
754
|
+
catch (e) {
|
|
755
|
+
obsReqHandler.endWithError(e);
|
|
756
|
+
throw e;
|
|
757
|
+
}
|
|
660
758
|
}
|
|
661
759
|
/**
|
|
662
760
|
* Retrieves the value of the document and simultanously updates the expiry time
|
|
@@ -680,31 +778,36 @@ class Collection {
|
|
|
680
778
|
if (!options) {
|
|
681
779
|
options = {};
|
|
682
780
|
}
|
|
683
|
-
const
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
this.
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
781
|
+
const obsReqHandler = new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.GetAndTouch, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
782
|
+
try {
|
|
783
|
+
const cppDocId = this._cppDocId(key);
|
|
784
|
+
const transcoder = options.transcoder || this.transcoder;
|
|
785
|
+
const timeout = options.timeout || this.cluster.kvTimeout;
|
|
786
|
+
obsReqHandler.setRequestKeyValueAttributes(cppDocId);
|
|
787
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
788
|
+
const [err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.getAndTouch.bind(this._conn), {
|
|
789
|
+
id: cppDocId,
|
|
790
|
+
expiry: (0, utilities_1.parseExpiry)(expiry),
|
|
791
|
+
timeout,
|
|
792
|
+
partition: 0,
|
|
793
|
+
opaque: 0,
|
|
794
|
+
}, obsReqHandler);
|
|
694
795
|
if (err) {
|
|
695
|
-
|
|
796
|
+
obsReqHandler.endWithError(err);
|
|
797
|
+
throw err;
|
|
696
798
|
}
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
content: content,
|
|
703
|
-
cas: resp.cas,
|
|
704
|
-
}));
|
|
799
|
+
const content = transcoder.decode(resp.value, resp.flags);
|
|
800
|
+
obsReqHandler.end();
|
|
801
|
+
return new crudoptypes_1.GetResult({
|
|
802
|
+
content: content,
|
|
803
|
+
cas: resp.cas,
|
|
705
804
|
});
|
|
706
|
-
});
|
|
707
|
-
}
|
|
805
|
+
}, callback);
|
|
806
|
+
}
|
|
807
|
+
catch (e) {
|
|
808
|
+
obsReqHandler.endWithError(e);
|
|
809
|
+
throw e;
|
|
810
|
+
}
|
|
708
811
|
}
|
|
709
812
|
/**
|
|
710
813
|
* Updates the expiry on an existing document.
|
|
@@ -727,24 +830,33 @@ class Collection {
|
|
|
727
830
|
if (!options) {
|
|
728
831
|
options = {};
|
|
729
832
|
}
|
|
730
|
-
const
|
|
731
|
-
|
|
732
|
-
this.
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
833
|
+
const obsReqHandler = new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.Touch, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
834
|
+
try {
|
|
835
|
+
const cppDocId = this._cppDocId(key);
|
|
836
|
+
const timeout = options.timeout || this.cluster.kvTimeout;
|
|
837
|
+
obsReqHandler.setRequestKeyValueAttributes(cppDocId);
|
|
838
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
839
|
+
const [err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.touch.bind(this._conn), {
|
|
840
|
+
id: cppDocId,
|
|
841
|
+
expiry: (0, utilities_1.parseExpiry)(expiry),
|
|
842
|
+
timeout,
|
|
843
|
+
partition: 0,
|
|
844
|
+
opaque: 0,
|
|
845
|
+
}, obsReqHandler);
|
|
740
846
|
if (err) {
|
|
741
|
-
|
|
847
|
+
obsReqHandler.endWithError(err);
|
|
848
|
+
throw err;
|
|
742
849
|
}
|
|
743
|
-
|
|
850
|
+
obsReqHandler.end();
|
|
851
|
+
return new crudoptypes_1.MutationResult({
|
|
744
852
|
cas: resp.cas,
|
|
745
|
-
})
|
|
746
|
-
});
|
|
747
|
-
}
|
|
853
|
+
});
|
|
854
|
+
}, callback);
|
|
855
|
+
}
|
|
856
|
+
catch (e) {
|
|
857
|
+
obsReqHandler.endWithError(e);
|
|
858
|
+
throw e;
|
|
859
|
+
}
|
|
748
860
|
}
|
|
749
861
|
/**
|
|
750
862
|
* Locks a document and retrieves the value of that document at the time it is locked.
|
|
@@ -762,31 +874,36 @@ class Collection {
|
|
|
762
874
|
if (!options) {
|
|
763
875
|
options = {};
|
|
764
876
|
}
|
|
765
|
-
const
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
this.
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
877
|
+
const obsReqHandler = new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.GetAndLock, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
878
|
+
try {
|
|
879
|
+
const cppDocId = this._cppDocId(key);
|
|
880
|
+
const transcoder = options.transcoder || this.transcoder;
|
|
881
|
+
const timeout = options.timeout || this.cluster.kvTimeout;
|
|
882
|
+
obsReqHandler.setRequestKeyValueAttributes(cppDocId);
|
|
883
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
884
|
+
const [err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.getAndLock.bind(this._conn), {
|
|
885
|
+
id: cppDocId,
|
|
886
|
+
lock_time: lockTime,
|
|
887
|
+
timeout,
|
|
888
|
+
partition: 0,
|
|
889
|
+
opaque: 0,
|
|
890
|
+
}, obsReqHandler);
|
|
776
891
|
if (err) {
|
|
777
|
-
|
|
892
|
+
obsReqHandler.endWithError(err);
|
|
893
|
+
throw err;
|
|
778
894
|
}
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
cas: resp.cas,
|
|
785
|
-
content: content,
|
|
786
|
-
}));
|
|
895
|
+
const content = transcoder.decode(resp.value, resp.flags);
|
|
896
|
+
obsReqHandler.end();
|
|
897
|
+
return new crudoptypes_1.GetResult({
|
|
898
|
+
content: content,
|
|
899
|
+
cas: resp.cas,
|
|
787
900
|
});
|
|
788
|
-
});
|
|
789
|
-
}
|
|
901
|
+
}, callback);
|
|
902
|
+
}
|
|
903
|
+
catch (e) {
|
|
904
|
+
obsReqHandler.endWithError(e);
|
|
905
|
+
throw e;
|
|
906
|
+
}
|
|
790
907
|
}
|
|
791
908
|
/**
|
|
792
909
|
* Unlocks a previously locked document.
|
|
@@ -804,22 +921,30 @@ class Collection {
|
|
|
804
921
|
if (!options) {
|
|
805
922
|
options = {};
|
|
806
923
|
}
|
|
807
|
-
const
|
|
808
|
-
|
|
809
|
-
this.
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
924
|
+
const obsReqHandler = new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.Unlock, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
925
|
+
try {
|
|
926
|
+
const cppDocId = this._cppDocId(key);
|
|
927
|
+
const timeout = options.timeout || this.cluster.kvTimeout;
|
|
928
|
+
obsReqHandler.setRequestKeyValueAttributes(cppDocId);
|
|
929
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
930
|
+
const [err, _] = await (0, observability_1.wrapObservableBindingCall)(this._conn.unlock.bind(this._conn), {
|
|
931
|
+
id: cppDocId,
|
|
932
|
+
cas,
|
|
933
|
+
timeout,
|
|
934
|
+
partition: 0,
|
|
935
|
+
opaque: 0,
|
|
936
|
+
}, obsReqHandler);
|
|
817
937
|
if (err) {
|
|
818
|
-
|
|
938
|
+
obsReqHandler.endWithError(err);
|
|
939
|
+
throw err;
|
|
819
940
|
}
|
|
820
|
-
|
|
821
|
-
});
|
|
822
|
-
}
|
|
941
|
+
obsReqHandler.end();
|
|
942
|
+
}, callback);
|
|
943
|
+
}
|
|
944
|
+
catch (e) {
|
|
945
|
+
obsReqHandler.endWithError(e);
|
|
946
|
+
throw e;
|
|
947
|
+
}
|
|
823
948
|
}
|
|
824
949
|
/**
|
|
825
950
|
* @internal
|
|
@@ -942,71 +1067,74 @@ class Collection {
|
|
|
942
1067
|
if (!options) {
|
|
943
1068
|
options = {};
|
|
944
1069
|
}
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
this.
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
value,
|
|
984
|
-
}));
|
|
1070
|
+
const obsReqHandler = new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.LookupIn, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
1071
|
+
try {
|
|
1072
|
+
if (specs.length === 0) {
|
|
1073
|
+
throw new errors_1.InvalidArgumentError(new Error('At least one lookup spec must be provided.'));
|
|
1074
|
+
}
|
|
1075
|
+
const cppDocId = this._cppDocId(key);
|
|
1076
|
+
const cppSpecs = [];
|
|
1077
|
+
for (let i = 0; i < specs.length; ++i) {
|
|
1078
|
+
cppSpecs.push({
|
|
1079
|
+
opcode_: specs[i]._op,
|
|
1080
|
+
flags_: specs[i]._flags,
|
|
1081
|
+
path_: specs[i]._path,
|
|
1082
|
+
original_index_: i,
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
const timeout = options.timeout || this.cluster.kvTimeout;
|
|
1086
|
+
const accessDeleted = options.accessDeleted || false;
|
|
1087
|
+
obsReqHandler.setRequestKeyValueAttributes(cppDocId);
|
|
1088
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
1089
|
+
const [err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.lookupIn.bind(this._conn), {
|
|
1090
|
+
id: cppDocId,
|
|
1091
|
+
specs: cppSpecs,
|
|
1092
|
+
timeout,
|
|
1093
|
+
partition: 0,
|
|
1094
|
+
opaque: 0,
|
|
1095
|
+
access_deleted: accessDeleted,
|
|
1096
|
+
}, obsReqHandler);
|
|
1097
|
+
if (err) {
|
|
1098
|
+
obsReqHandler.endWithError(err);
|
|
1099
|
+
throw err;
|
|
1100
|
+
}
|
|
1101
|
+
const content = [];
|
|
1102
|
+
for (let i = 0; i < resp.fields.length; ++i) {
|
|
1103
|
+
const itemRes = resp.fields[i];
|
|
1104
|
+
const error = (0, bindingutilities_1.errorFromCpp)(itemRes.ec);
|
|
1105
|
+
let value = undefined;
|
|
1106
|
+
if (itemRes.value && itemRes.value.length > 0) {
|
|
1107
|
+
value = this._subdocDecode(itemRes.value);
|
|
985
1108
|
}
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
1109
|
+
if (itemRes.opcode === binding_1.default.protocol_subdoc_opcode.exists) {
|
|
1110
|
+
value = itemRes.exists;
|
|
1111
|
+
}
|
|
1112
|
+
content.push(new crudoptypes_1.LookupInResultEntry({
|
|
1113
|
+
error,
|
|
1114
|
+
value,
|
|
989
1115
|
}));
|
|
990
|
-
return;
|
|
991
1116
|
}
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1117
|
+
obsReqHandler.end();
|
|
1118
|
+
return new crudoptypes_1.LookupInResult({
|
|
1119
|
+
content: content,
|
|
1120
|
+
cas: resp.cas,
|
|
1121
|
+
});
|
|
1122
|
+
}, callback);
|
|
1123
|
+
}
|
|
1124
|
+
catch (e) {
|
|
1125
|
+
obsReqHandler.endWithError(e);
|
|
1126
|
+
throw e;
|
|
1127
|
+
}
|
|
995
1128
|
}
|
|
996
1129
|
/**
|
|
997
1130
|
* @internal
|
|
998
1131
|
*/
|
|
999
|
-
_lookupInReplica(key,
|
|
1000
|
-
if (options instanceof Function) {
|
|
1001
|
-
callback = arguments[3];
|
|
1002
|
-
options = undefined;
|
|
1003
|
-
}
|
|
1004
|
-
if (!options) {
|
|
1005
|
-
options = {};
|
|
1006
|
-
}
|
|
1132
|
+
_lookupInReplica(key, obsReqHandler, specs, options, callback) {
|
|
1007
1133
|
if (specs.length === 0) {
|
|
1008
1134
|
throw new errors_1.InvalidArgumentError(new Error('At least one lookup spec must be provided.'));
|
|
1009
1135
|
}
|
|
1136
|
+
const cppDocId = this._cppDocId(key);
|
|
1137
|
+
obsReqHandler.setRequestKeyValueAttributes(cppDocId);
|
|
1010
1138
|
const emitter = new streamablepromises_1.StreamableReplicasPromise((replicas) => replicas);
|
|
1011
1139
|
const cppSpecs = [];
|
|
1012
1140
|
for (let i = 0; i < specs.length; ++i) {
|
|
@@ -1018,15 +1146,17 @@ class Collection {
|
|
|
1018
1146
|
});
|
|
1019
1147
|
}
|
|
1020
1148
|
const timeout = options.timeout || this.cluster.kvTimeout;
|
|
1021
|
-
if (
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1149
|
+
if (obsReqHandler.opType == observabilitytypes_1.KeyValueOp.LookupInAllReplicas) {
|
|
1150
|
+
utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
1151
|
+
const [err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.lookupInAllReplicas.bind(this._conn), {
|
|
1152
|
+
id: cppDocId,
|
|
1153
|
+
specs: cppSpecs,
|
|
1154
|
+
timeout: timeout,
|
|
1155
|
+
read_preference: (0, bindingutilities_1.readPreferenceToCpp)(options.readPreference),
|
|
1156
|
+
access_deleted: false, // only used in core transactions; false otherwise
|
|
1157
|
+
}, obsReqHandler);
|
|
1029
1158
|
if (err) {
|
|
1159
|
+
obsReqHandler.endWithError(err);
|
|
1030
1160
|
emitter.emit('error', err);
|
|
1031
1161
|
emitter.emit('end');
|
|
1032
1162
|
return;
|
|
@@ -1054,19 +1184,21 @@ class Collection {
|
|
|
1054
1184
|
isReplica: replica.is_replica,
|
|
1055
1185
|
}));
|
|
1056
1186
|
});
|
|
1187
|
+
obsReqHandler.end();
|
|
1057
1188
|
emitter.emit('end');
|
|
1058
|
-
return;
|
|
1059
1189
|
});
|
|
1060
1190
|
}
|
|
1061
1191
|
else {
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1192
|
+
utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
1193
|
+
const [err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.lookupInAnyReplica.bind(this._conn), {
|
|
1194
|
+
id: cppDocId,
|
|
1195
|
+
specs: cppSpecs,
|
|
1196
|
+
timeout: timeout,
|
|
1197
|
+
read_preference: (0, bindingutilities_1.readPreferenceToCpp)(options.readPreference),
|
|
1198
|
+
access_deleted: false, // only used in core transactions; false otherwise
|
|
1199
|
+
}, obsReqHandler);
|
|
1069
1200
|
if (err) {
|
|
1201
|
+
obsReqHandler.endWithError(err);
|
|
1070
1202
|
emitter.emit('error', err);
|
|
1071
1203
|
emitter.emit('end');
|
|
1072
1204
|
return;
|
|
@@ -1092,8 +1224,8 @@ class Collection {
|
|
|
1092
1224
|
cas: resp.cas,
|
|
1093
1225
|
isReplica: resp.is_replica,
|
|
1094
1226
|
}));
|
|
1227
|
+
obsReqHandler.end();
|
|
1095
1228
|
emitter.emit('end');
|
|
1096
|
-
return;
|
|
1097
1229
|
});
|
|
1098
1230
|
}
|
|
1099
1231
|
return utilities_1.PromiseHelper.wrapAsync(() => emitter, callback);
|
|
@@ -1113,10 +1245,20 @@ class Collection {
|
|
|
1113
1245
|
callback = arguments[2];
|
|
1114
1246
|
options = undefined;
|
|
1115
1247
|
}
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1248
|
+
if (!options) {
|
|
1249
|
+
options = {};
|
|
1250
|
+
}
|
|
1251
|
+
const obsReqHandler = new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.LookupInAnyReplica, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
1252
|
+
try {
|
|
1253
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
1254
|
+
const replicas = await this._lookupInReplica(key, obsReqHandler, specs, options);
|
|
1255
|
+
return replicas[0];
|
|
1256
|
+
}, callback);
|
|
1257
|
+
}
|
|
1258
|
+
catch (e) {
|
|
1259
|
+
obsReqHandler.endWithError(e);
|
|
1260
|
+
throw e;
|
|
1261
|
+
}
|
|
1120
1262
|
}
|
|
1121
1263
|
/**
|
|
1122
1264
|
* Performs a lookup-in operation against a document, fetching individual fields or
|
|
@@ -1129,7 +1271,21 @@ class Collection {
|
|
|
1129
1271
|
* @param callback A node-style callback to be invoked after execution.
|
|
1130
1272
|
*/
|
|
1131
1273
|
lookupInAllReplicas(key, specs, options, callback) {
|
|
1132
|
-
|
|
1274
|
+
if (options instanceof Function) {
|
|
1275
|
+
callback = arguments[2];
|
|
1276
|
+
options = undefined;
|
|
1277
|
+
}
|
|
1278
|
+
if (!options) {
|
|
1279
|
+
options = {};
|
|
1280
|
+
}
|
|
1281
|
+
const obsReqHandler = new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.LookupInAllReplicas, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
1282
|
+
try {
|
|
1283
|
+
return this._lookupInReplica(key, obsReqHandler, specs, options, callback);
|
|
1284
|
+
}
|
|
1285
|
+
catch (e) {
|
|
1286
|
+
obsReqHandler.endWithError(e);
|
|
1287
|
+
throw e;
|
|
1288
|
+
}
|
|
1133
1289
|
}
|
|
1134
1290
|
/**
|
|
1135
1291
|
* Performs a mutate-in operation against a document. Allowing atomic modification of
|
|
@@ -1148,34 +1304,43 @@ class Collection {
|
|
|
1148
1304
|
if (!options) {
|
|
1149
1305
|
options = {};
|
|
1150
1306
|
}
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1307
|
+
const obsReqHandler = new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.MutateIn, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
1308
|
+
try {
|
|
1309
|
+
if (specs.length === 0) {
|
|
1310
|
+
throw new errors_1.InvalidArgumentError(new Error('At least one lookup spec must be provided.'));
|
|
1311
|
+
}
|
|
1312
|
+
const cppDocId = this._cppDocId(key);
|
|
1313
|
+
const cppDurability = (0, bindingutilities_1.durabilityToCpp)(options.durabilityLevel);
|
|
1314
|
+
const cppSpecs = [];
|
|
1315
|
+
for (let i = 0; i < specs.length; ++i) {
|
|
1316
|
+
let value = undefined;
|
|
1317
|
+
if (specs[i]._data) {
|
|
1318
|
+
const [bytesValue, _] = obsReqHandler.maybeAddEncodingSpan(() => {
|
|
1319
|
+
const encoded = this._subdocEncode(specs[i]._data);
|
|
1320
|
+
return [encoded, 0]; // Flags are not needed for subdoc mutations
|
|
1321
|
+
});
|
|
1322
|
+
value = bytesValue;
|
|
1323
|
+
}
|
|
1324
|
+
cppSpecs.push({
|
|
1325
|
+
opcode_: specs[i]._op,
|
|
1326
|
+
flags_: specs[i]._flags,
|
|
1327
|
+
path_: specs[i]._path,
|
|
1328
|
+
value_: value,
|
|
1329
|
+
original_index_: 0,
|
|
1330
|
+
});
|
|
1331
|
+
}
|
|
1332
|
+
const storeSemantics = options.upsertDocument
|
|
1333
|
+
? generaltypes_1.StoreSemantics.Upsert
|
|
1334
|
+
: options.storeSemantics;
|
|
1335
|
+
const expiry = (0, utilities_1.parseExpiry)(options.expiry);
|
|
1336
|
+
const preserveExpiry = options.preserveExpiry;
|
|
1337
|
+
const cas = options.cas;
|
|
1338
|
+
const persistTo = options.durabilityPersistTo;
|
|
1339
|
+
const replicateTo = options.durabilityReplicateTo;
|
|
1340
|
+
const timeout = options.timeout || this._mutationTimeout(options.durabilityLevel);
|
|
1341
|
+
obsReqHandler.setRequestKeyValueAttributes(cppDocId, cppDurability);
|
|
1177
1342
|
const mutateInReq = {
|
|
1178
|
-
id:
|
|
1343
|
+
id: cppDocId,
|
|
1179
1344
|
store_semantics: (0, bindingutilities_1.storeSemanticToCpp)(storeSemantics),
|
|
1180
1345
|
specs: cppSpecs,
|
|
1181
1346
|
expiry,
|
|
@@ -1187,43 +1352,51 @@ class Collection {
|
|
|
1187
1352
|
access_deleted: false,
|
|
1188
1353
|
create_as_deleted: false,
|
|
1189
1354
|
};
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1355
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
1356
|
+
let err = null;
|
|
1357
|
+
let resp = null;
|
|
1358
|
+
if (persistTo || replicateTo) {
|
|
1359
|
+
;
|
|
1360
|
+
[err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.mutateInWithLegacyDurability.bind(this._conn), {
|
|
1361
|
+
...mutateInReq,
|
|
1362
|
+
persist_to: (0, bindingutilities_1.persistToToCpp)(persistTo),
|
|
1363
|
+
replicate_to: (0, bindingutilities_1.replicateToToCpp)(replicateTo),
|
|
1364
|
+
}, obsReqHandler);
|
|
1365
|
+
}
|
|
1366
|
+
else {
|
|
1367
|
+
;
|
|
1368
|
+
[err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.mutateIn.bind(this._conn), {
|
|
1369
|
+
...mutateInReq,
|
|
1370
|
+
durability_level: cppDurability,
|
|
1371
|
+
}, obsReqHandler);
|
|
1372
|
+
}
|
|
1373
|
+
if (err) {
|
|
1374
|
+
obsReqHandler.endWithError(err);
|
|
1375
|
+
throw err;
|
|
1376
|
+
}
|
|
1377
|
+
const content = [];
|
|
1378
|
+
for (let i = 0; i < resp.fields.length; ++i) {
|
|
1379
|
+
const itemRes = resp.fields[i];
|
|
1380
|
+
let value = undefined;
|
|
1381
|
+
if (itemRes.value && itemRes.value.length > 0) {
|
|
1382
|
+
value = this._subdocDecode(itemRes.value);
|
|
1203
1383
|
}
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
cas: resp.cas,
|
|
1207
|
-
token: resp.token,
|
|
1384
|
+
content.push(new crudoptypes_1.MutateInResultEntry({
|
|
1385
|
+
value,
|
|
1208
1386
|
}));
|
|
1209
|
-
return;
|
|
1210
1387
|
}
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
durability_level: (0, bindingutilities_1.durabilityToCpp)(durabilityLevel),
|
|
1224
|
-
}, mutateInCallback);
|
|
1225
|
-
}
|
|
1226
|
-
}, callback);
|
|
1388
|
+
obsReqHandler.end();
|
|
1389
|
+
return new crudoptypes_1.MutateInResult({
|
|
1390
|
+
content: content,
|
|
1391
|
+
cas: resp.cas,
|
|
1392
|
+
token: resp.token,
|
|
1393
|
+
});
|
|
1394
|
+
}, callback);
|
|
1395
|
+
}
|
|
1396
|
+
catch (e) {
|
|
1397
|
+
obsReqHandler.endWithError(e);
|
|
1398
|
+
throw e;
|
|
1399
|
+
}
|
|
1227
1400
|
}
|
|
1228
1401
|
/**
|
|
1229
1402
|
* Returns a CouchbaseList permitting simple list storage in a document.
|
|
@@ -1275,15 +1448,18 @@ class Collection {
|
|
|
1275
1448
|
if (!options) {
|
|
1276
1449
|
options = {};
|
|
1277
1450
|
}
|
|
1278
|
-
const
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1451
|
+
const obsReqHandler = new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.Increment, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
1452
|
+
try {
|
|
1453
|
+
const cppDocId = this._cppDocId(key);
|
|
1454
|
+
const cppDurability = (0, bindingutilities_1.durabilityToCpp)(options.durabilityLevel);
|
|
1455
|
+
const initial_value = options.initial;
|
|
1456
|
+
const expiry = (0, utilities_1.parseExpiry)(options.expiry);
|
|
1457
|
+
const persistTo = options.durabilityPersistTo;
|
|
1458
|
+
const replicateTo = options.durabilityReplicateTo;
|
|
1459
|
+
const timeout = options.timeout || this.cluster.kvTimeout;
|
|
1460
|
+
obsReqHandler.setRequestKeyValueAttributes(cppDocId, cppDurability);
|
|
1285
1461
|
const incrementReq = {
|
|
1286
|
-
id:
|
|
1462
|
+
id: cppDocId,
|
|
1287
1463
|
delta,
|
|
1288
1464
|
initial_value,
|
|
1289
1465
|
expiry: expiry,
|
|
@@ -1291,31 +1467,40 @@ class Collection {
|
|
|
1291
1467
|
partition: 0,
|
|
1292
1468
|
opaque: 0,
|
|
1293
1469
|
};
|
|
1294
|
-
|
|
1295
|
-
|
|
1470
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
1471
|
+
let err = null;
|
|
1472
|
+
let resp = null;
|
|
1473
|
+
if (persistTo || replicateTo) {
|
|
1474
|
+
;
|
|
1475
|
+
[err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.incrementWithLegacyDurability.bind(this._conn), {
|
|
1476
|
+
...incrementReq,
|
|
1477
|
+
persist_to: (0, bindingutilities_1.persistToToCpp)(persistTo),
|
|
1478
|
+
replicate_to: (0, bindingutilities_1.replicateToToCpp)(replicateTo),
|
|
1479
|
+
}, obsReqHandler);
|
|
1480
|
+
}
|
|
1481
|
+
else {
|
|
1482
|
+
;
|
|
1483
|
+
[err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.increment.bind(this._conn), {
|
|
1484
|
+
...incrementReq,
|
|
1485
|
+
durability_level: cppDurability,
|
|
1486
|
+
}, obsReqHandler);
|
|
1487
|
+
}
|
|
1296
1488
|
if (err) {
|
|
1297
|
-
|
|
1489
|
+
obsReqHandler.endWithError(err);
|
|
1490
|
+
throw err;
|
|
1298
1491
|
}
|
|
1299
|
-
|
|
1492
|
+
obsReqHandler.end();
|
|
1493
|
+
return new crudoptypes_1.CounterResult({
|
|
1300
1494
|
cas: resp.cas,
|
|
1301
1495
|
token: resp.token,
|
|
1302
1496
|
value: resp.content,
|
|
1303
|
-
})
|
|
1304
|
-
};
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
}, incrementCallback);
|
|
1311
|
-
}
|
|
1312
|
-
else {
|
|
1313
|
-
this._conn.increment({
|
|
1314
|
-
...incrementReq,
|
|
1315
|
-
durability_level: (0, bindingutilities_1.durabilityToCpp)(durabilityLevel),
|
|
1316
|
-
}, incrementCallback);
|
|
1317
|
-
}
|
|
1318
|
-
}, callback);
|
|
1497
|
+
});
|
|
1498
|
+
}, callback);
|
|
1499
|
+
}
|
|
1500
|
+
catch (e) {
|
|
1501
|
+
obsReqHandler.endWithError(e);
|
|
1502
|
+
throw e;
|
|
1503
|
+
}
|
|
1319
1504
|
}
|
|
1320
1505
|
/**
|
|
1321
1506
|
* @internal
|
|
@@ -1328,15 +1513,18 @@ class Collection {
|
|
|
1328
1513
|
if (!options) {
|
|
1329
1514
|
options = {};
|
|
1330
1515
|
}
|
|
1331
|
-
const
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1516
|
+
const obsReqHandler = new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.Decrement, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
1517
|
+
try {
|
|
1518
|
+
const cppDocId = this._cppDocId(key);
|
|
1519
|
+
const cppDurability = (0, bindingutilities_1.durabilityToCpp)(options.durabilityLevel);
|
|
1520
|
+
const initial_value = options.initial;
|
|
1521
|
+
const expiry = (0, utilities_1.parseExpiry)(options.expiry);
|
|
1522
|
+
const persistTo = options.durabilityPersistTo;
|
|
1523
|
+
const replicateTo = options.durabilityReplicateTo;
|
|
1524
|
+
const timeout = options.timeout || this.cluster.kvTimeout;
|
|
1525
|
+
obsReqHandler.setRequestKeyValueAttributes(cppDocId, cppDurability);
|
|
1338
1526
|
const decrementReq = {
|
|
1339
|
-
id:
|
|
1527
|
+
id: cppDocId,
|
|
1340
1528
|
delta,
|
|
1341
1529
|
initial_value,
|
|
1342
1530
|
expiry: expiry,
|
|
@@ -1344,31 +1532,40 @@ class Collection {
|
|
|
1344
1532
|
partition: 0,
|
|
1345
1533
|
opaque: 0,
|
|
1346
1534
|
};
|
|
1347
|
-
|
|
1348
|
-
|
|
1535
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
1536
|
+
let err = null;
|
|
1537
|
+
let resp = null;
|
|
1538
|
+
if (persistTo || replicateTo) {
|
|
1539
|
+
;
|
|
1540
|
+
[err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.decrementWithLegacyDurability.bind(this._conn), {
|
|
1541
|
+
...decrementReq,
|
|
1542
|
+
persist_to: (0, bindingutilities_1.persistToToCpp)(persistTo),
|
|
1543
|
+
replicate_to: (0, bindingutilities_1.replicateToToCpp)(replicateTo),
|
|
1544
|
+
}, obsReqHandler);
|
|
1545
|
+
}
|
|
1546
|
+
else {
|
|
1547
|
+
;
|
|
1548
|
+
[err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.decrement.bind(this._conn), {
|
|
1549
|
+
...decrementReq,
|
|
1550
|
+
durability_level: cppDurability,
|
|
1551
|
+
}, obsReqHandler);
|
|
1552
|
+
}
|
|
1349
1553
|
if (err) {
|
|
1350
|
-
|
|
1554
|
+
obsReqHandler.endWithError(err);
|
|
1555
|
+
throw err;
|
|
1351
1556
|
}
|
|
1352
|
-
|
|
1557
|
+
obsReqHandler.end();
|
|
1558
|
+
return new crudoptypes_1.CounterResult({
|
|
1353
1559
|
cas: resp.cas,
|
|
1354
1560
|
token: resp.token,
|
|
1355
1561
|
value: resp.content,
|
|
1356
|
-
})
|
|
1357
|
-
};
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
}, decrementCallback);
|
|
1364
|
-
}
|
|
1365
|
-
else {
|
|
1366
|
-
this._conn.decrement({
|
|
1367
|
-
...decrementReq,
|
|
1368
|
-
durability_level: (0, bindingutilities_1.durabilityToCpp)(durabilityLevel),
|
|
1369
|
-
}, decrementCallback);
|
|
1370
|
-
}
|
|
1371
|
-
}, callback);
|
|
1562
|
+
});
|
|
1563
|
+
}, callback);
|
|
1564
|
+
}
|
|
1565
|
+
catch (e) {
|
|
1566
|
+
obsReqHandler.endWithError(e);
|
|
1567
|
+
throw e;
|
|
1568
|
+
}
|
|
1372
1569
|
}
|
|
1373
1570
|
/**
|
|
1374
1571
|
* @internal
|
|
@@ -1381,47 +1578,59 @@ class Collection {
|
|
|
1381
1578
|
if (!options) {
|
|
1382
1579
|
options = {};
|
|
1383
1580
|
}
|
|
1384
|
-
const
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1581
|
+
const obsReqHandler = new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.Append, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
1582
|
+
try {
|
|
1583
|
+
const cppDocId = this._cppDocId(key);
|
|
1584
|
+
const cppDurability = (0, bindingutilities_1.durabilityToCpp)(options.durabilityLevel);
|
|
1585
|
+
const persistTo = options.durabilityPersistTo;
|
|
1586
|
+
const replicateTo = options.durabilityReplicateTo;
|
|
1587
|
+
const cas = options.cas;
|
|
1588
|
+
const timeout = options.timeout || this.cluster.kvTimeout;
|
|
1589
|
+
obsReqHandler.setRequestKeyValueAttributes(cppDocId, cppDurability);
|
|
1390
1590
|
if (!Buffer.isBuffer(value)) {
|
|
1391
1591
|
value = Buffer.from(value);
|
|
1392
1592
|
}
|
|
1393
1593
|
const appendReq = {
|
|
1394
|
-
id:
|
|
1594
|
+
id: cppDocId,
|
|
1395
1595
|
value,
|
|
1396
1596
|
cas: cas || binding_1.zeroCas,
|
|
1397
1597
|
timeout,
|
|
1398
1598
|
partition: 0,
|
|
1399
1599
|
opaque: 0,
|
|
1400
1600
|
};
|
|
1401
|
-
|
|
1402
|
-
|
|
1601
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
1602
|
+
let err = null;
|
|
1603
|
+
let resp = null;
|
|
1604
|
+
if (persistTo || replicateTo) {
|
|
1605
|
+
;
|
|
1606
|
+
[err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.appendWithLegacyDurability.bind(this._conn), {
|
|
1607
|
+
...appendReq,
|
|
1608
|
+
persist_to: (0, bindingutilities_1.persistToToCpp)(persistTo),
|
|
1609
|
+
replicate_to: (0, bindingutilities_1.replicateToToCpp)(replicateTo),
|
|
1610
|
+
}, obsReqHandler);
|
|
1611
|
+
}
|
|
1612
|
+
else {
|
|
1613
|
+
;
|
|
1614
|
+
[err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.append.bind(this._conn), {
|
|
1615
|
+
...appendReq,
|
|
1616
|
+
durability_level: cppDurability,
|
|
1617
|
+
}, obsReqHandler);
|
|
1618
|
+
}
|
|
1403
1619
|
if (err) {
|
|
1404
|
-
|
|
1620
|
+
obsReqHandler.endWithError(err);
|
|
1621
|
+
throw err;
|
|
1405
1622
|
}
|
|
1406
|
-
|
|
1623
|
+
obsReqHandler.end();
|
|
1624
|
+
return new crudoptypes_1.MutationResult({
|
|
1407
1625
|
cas: resp.cas,
|
|
1408
1626
|
token: resp.token,
|
|
1409
|
-
})
|
|
1410
|
-
};
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
}, appendCallback);
|
|
1417
|
-
}
|
|
1418
|
-
else {
|
|
1419
|
-
this._conn.append({
|
|
1420
|
-
...appendReq,
|
|
1421
|
-
durability_level: (0, bindingutilities_1.durabilityToCpp)(durabilityLevel),
|
|
1422
|
-
}, appendCallback);
|
|
1423
|
-
}
|
|
1424
|
-
}, callback);
|
|
1627
|
+
});
|
|
1628
|
+
}, callback);
|
|
1629
|
+
}
|
|
1630
|
+
catch (e) {
|
|
1631
|
+
obsReqHandler.endWithError(e);
|
|
1632
|
+
throw e;
|
|
1633
|
+
}
|
|
1425
1634
|
}
|
|
1426
1635
|
/**
|
|
1427
1636
|
* @internal
|
|
@@ -1434,47 +1643,59 @@ class Collection {
|
|
|
1434
1643
|
if (!options) {
|
|
1435
1644
|
options = {};
|
|
1436
1645
|
}
|
|
1437
|
-
const
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1646
|
+
const obsReqHandler = new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.KeyValueOp.Prepend, this.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
|
|
1647
|
+
try {
|
|
1648
|
+
const cppDocId = this._cppDocId(key);
|
|
1649
|
+
const cppDurability = (0, bindingutilities_1.durabilityToCpp)(options.durabilityLevel);
|
|
1650
|
+
const persistTo = options.durabilityPersistTo;
|
|
1651
|
+
const replicateTo = options.durabilityReplicateTo;
|
|
1652
|
+
const cas = options.cas;
|
|
1653
|
+
const timeout = options.timeout || this.cluster.kvTimeout;
|
|
1654
|
+
obsReqHandler.setRequestKeyValueAttributes(cppDocId, cppDurability);
|
|
1443
1655
|
if (!Buffer.isBuffer(value)) {
|
|
1444
1656
|
value = Buffer.from(value);
|
|
1445
1657
|
}
|
|
1446
1658
|
const prependReq = {
|
|
1447
|
-
id:
|
|
1659
|
+
id: cppDocId,
|
|
1448
1660
|
value,
|
|
1449
1661
|
cas: cas || binding_1.zeroCas,
|
|
1450
1662
|
timeout,
|
|
1451
1663
|
partition: 0,
|
|
1452
1664
|
opaque: 0,
|
|
1453
1665
|
};
|
|
1454
|
-
|
|
1455
|
-
|
|
1666
|
+
return utilities_1.PromiseHelper.wrapAsync(async () => {
|
|
1667
|
+
let err = null;
|
|
1668
|
+
let resp = null;
|
|
1669
|
+
if (persistTo || replicateTo) {
|
|
1670
|
+
;
|
|
1671
|
+
[err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.prependWithLegacyDurability.bind(this._conn), {
|
|
1672
|
+
...prependReq,
|
|
1673
|
+
persist_to: (0, bindingutilities_1.persistToToCpp)(persistTo),
|
|
1674
|
+
replicate_to: (0, bindingutilities_1.replicateToToCpp)(replicateTo),
|
|
1675
|
+
}, obsReqHandler);
|
|
1676
|
+
}
|
|
1677
|
+
else {
|
|
1678
|
+
;
|
|
1679
|
+
[err, resp] = await (0, observability_1.wrapObservableBindingCall)(this._conn.prepend.bind(this._conn), {
|
|
1680
|
+
...prependReq,
|
|
1681
|
+
durability_level: cppDurability,
|
|
1682
|
+
}, obsReqHandler);
|
|
1683
|
+
}
|
|
1456
1684
|
if (err) {
|
|
1457
|
-
|
|
1685
|
+
obsReqHandler.endWithError(err);
|
|
1686
|
+
throw err;
|
|
1458
1687
|
}
|
|
1459
|
-
|
|
1688
|
+
obsReqHandler.end();
|
|
1689
|
+
return new crudoptypes_1.MutationResult({
|
|
1460
1690
|
cas: resp.cas,
|
|
1461
1691
|
token: resp.token,
|
|
1462
|
-
})
|
|
1463
|
-
};
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
}, prependCallback);
|
|
1470
|
-
}
|
|
1471
|
-
else {
|
|
1472
|
-
this._conn.prepend({
|
|
1473
|
-
...prependReq,
|
|
1474
|
-
durability_level: (0, bindingutilities_1.durabilityToCpp)(durabilityLevel),
|
|
1475
|
-
}, prependCallback);
|
|
1476
|
-
}
|
|
1477
|
-
}, callback);
|
|
1692
|
+
});
|
|
1693
|
+
}, callback);
|
|
1694
|
+
}
|
|
1695
|
+
catch (e) {
|
|
1696
|
+
obsReqHandler.endWithError(e);
|
|
1697
|
+
throw e;
|
|
1698
|
+
}
|
|
1478
1699
|
}
|
|
1479
1700
|
/**
|
|
1480
1701
|
* Returns a CollectionQueryIndexManager which can be used to manage the query indexes
|