couchbase 4.2.6-dev.1 → 4.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. package/CONTRIBUTING.md +97 -0
  2. package/deps/couchbase-cxx-client/.github/workflows/windows.yml +0 -3
  3. package/deps/couchbase-cxx-client/CMakeLists.txt +4 -0
  4. package/deps/couchbase-cxx-client/bin/build-tests.rb +1 -1
  5. package/deps/couchbase-cxx-client/core/impl/lookup_in.cxx +1 -0
  6. package/deps/couchbase-cxx-client/core/impl/lookup_in_all_replicas.cxx +176 -0
  7. package/deps/couchbase-cxx-client/core/impl/lookup_in_all_replicas.hxx +80 -0
  8. package/deps/couchbase-cxx-client/core/impl/lookup_in_any_replica.cxx +167 -0
  9. package/deps/couchbase-cxx-client/core/impl/lookup_in_any_replica.hxx +75 -0
  10. package/deps/couchbase-cxx-client/core/impl/lookup_in_replica.cxx +97 -0
  11. package/deps/couchbase-cxx-client/core/impl/lookup_in_replica.hxx +67 -0
  12. package/deps/couchbase-cxx-client/core/io/dns_client.cxx +48 -10
  13. package/deps/couchbase-cxx-client/core/io/http_session.hxx +24 -1
  14. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +22 -1
  15. package/deps/couchbase-cxx-client/core/logger/custom_rotating_file_sink.cxx +1 -1
  16. package/deps/couchbase-cxx-client/core/logger/logger.cxx +80 -20
  17. package/deps/couchbase-cxx-client/core/logger/logger.hxx +31 -0
  18. package/deps/couchbase-cxx-client/core/meta/features.hxx +19 -0
  19. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_all_replicas.hxx +192 -0
  20. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_any_replica.hxx +188 -0
  21. package/deps/couchbase-cxx-client/core/operations.hxx +2 -0
  22. package/deps/couchbase-cxx-client/core/protocol/cmd_hello.hxx +1 -0
  23. package/deps/couchbase-cxx-client/core/protocol/cmd_lookup_in_replica.cxx +107 -0
  24. package/deps/couchbase-cxx-client/core/protocol/cmd_lookup_in_replica.hxx +137 -0
  25. package/deps/couchbase-cxx-client/core/protocol/hello_feature.hxx +6 -0
  26. package/deps/couchbase-cxx-client/core/protocol/hello_feature_fmt.hxx +3 -0
  27. package/deps/couchbase-cxx-client/core/range_scan_orchestrator.cxx +22 -1
  28. package/deps/couchbase-cxx-client/core/topology/capabilities.hxx +2 -0
  29. package/deps/couchbase-cxx-client/core/topology/capabilities_fmt.hxx +6 -0
  30. package/deps/couchbase-cxx-client/core/topology/configuration.hxx +10 -0
  31. package/deps/couchbase-cxx-client/core/topology/configuration_json.hxx +4 -1
  32. package/deps/couchbase-cxx-client/couchbase/collection.hxx +111 -0
  33. package/deps/couchbase-cxx-client/couchbase/get_and_lock_options.hxx +2 -2
  34. package/deps/couchbase-cxx-client/couchbase/get_and_touch_options.hxx +2 -2
  35. package/deps/couchbase-cxx-client/couchbase/get_options.hxx +2 -2
  36. package/deps/couchbase-cxx-client/couchbase/insert_options.hxx +3 -3
  37. package/deps/couchbase-cxx-client/couchbase/lookup_in_all_replicas_options.hxx +109 -0
  38. package/deps/couchbase-cxx-client/couchbase/lookup_in_any_replica_options.hxx +101 -0
  39. package/deps/couchbase-cxx-client/couchbase/lookup_in_options.hxx +2 -2
  40. package/deps/couchbase-cxx-client/couchbase/lookup_in_replica_result.hxx +74 -0
  41. package/deps/couchbase-cxx-client/couchbase/lookup_in_result.hxx +26 -0
  42. package/deps/couchbase-cxx-client/couchbase/mutate_in_options.hxx +2 -2
  43. package/deps/couchbase-cxx-client/couchbase/remove_options.hxx +2 -2
  44. package/deps/couchbase-cxx-client/couchbase/replace_options.hxx +3 -3
  45. package/deps/couchbase-cxx-client/couchbase/touch_options.hxx +2 -2
  46. package/deps/couchbase-cxx-client/couchbase/unlock_options.hxx +2 -2
  47. package/deps/couchbase-cxx-client/couchbase/upsert_options.hxx +3 -3
  48. package/deps/couchbase-cxx-client/docs/cbc-analytics.md +3 -2
  49. package/deps/couchbase-cxx-client/docs/cbc-get.md +3 -2
  50. package/deps/couchbase-cxx-client/docs/cbc-pillowfight.md +3 -2
  51. package/deps/couchbase-cxx-client/docs/cbc-query.md +3 -2
  52. package/deps/couchbase-cxx-client/test/test_integration_subdoc.cxx +655 -0
  53. package/deps/couchbase-cxx-client/test/utils/logger.cxx +7 -0
  54. package/deps/couchbase-cxx-client/tools/utils.cxx +9 -2
  55. package/dist/binding.d.ts +47 -0
  56. package/dist/collection.d.ts +53 -1
  57. package/dist/collection.js +139 -1
  58. package/dist/couchbase.d.ts +15 -0
  59. package/dist/couchbase.js +22 -1
  60. package/dist/crudoptypes.d.ts +24 -0
  61. package/dist/crudoptypes.js +14 -1
  62. package/package.json +13 -13
  63. package/src/binding.cpp +28 -0
  64. package/src/connection.cpp +4 -0
  65. package/src/connection.hpp +2 -0
  66. package/src/connection_autogen.cpp +28 -0
  67. package/src/jstocbpp_autogen.hpp +262 -0
@@ -367,8 +367,9 @@ usage_block_for_logger() -> std::string
367
367
 
368
368
  return fmt::format(R"(
369
369
  Logger options:
370
- --log-level=LEVEL Log level (allowed values are: {allowed_levels}). CBC_LOG_LEVEL. [default: {log_level}]
371
- --log-output=PATH File to send logs (when is not set, logs will be written to STDERR).
370
+ --log-level=LEVEL Log level (allowed values are: {allowed_levels}). CBC_LOG_LEVEL. [default: {log_level}]
371
+ --log-output=PATH File to send logs (when is not set, logs will be written to STDERR).
372
+ --log-protocol=PATH File to send protocol logs.
372
373
  )",
373
374
  fmt::arg("allowed_levels", fmt::join(allowed_log_levels, ", ")),
374
375
  fmt::arg("log_level", default_log_level()));
@@ -393,6 +394,12 @@ apply_logger_options(const docopt::Options& options)
393
394
  couchbase::core::logger::create_file_logger(configuration);
394
395
  }
395
396
 
397
+ if (options.find("--log-protocol") != options.end() && options.at("--log-protocol")) {
398
+ couchbase::core::logger::configuration configuration{};
399
+ configuration.filename = options.at("--log-protocol").asString();
400
+ couchbase::core::logger::create_protocol_logger(configuration);
401
+ }
402
+
396
403
  spdlog::set_level(spdlog::level::from_str(log_level));
397
404
  couchbase::core::logger::set_log_levels(level);
398
405
  }
package/dist/binding.d.ts CHANGED
@@ -677,6 +677,29 @@ export interface CppGetRequest {
677
677
  opaque: number;
678
678
  timeout?: CppMilliseconds;
679
679
  }
680
+ export interface CppLookupInAllReplicasResponse {
681
+ entries: CppLookupInAllReplicasResponseEntry[];
682
+ }
683
+ export interface CppLookupInAllReplicasResponseEntry {
684
+ fields: CppLookupInAllReplicasResponseEntryLookupInEntry[];
685
+ cas: CppCas;
686
+ deleted: boolean;
687
+ is_replica: boolean;
688
+ }
689
+ export interface CppLookupInAllReplicasResponseEntryLookupInEntry {
690
+ path: string;
691
+ value: Buffer;
692
+ original_index: number;
693
+ exists: boolean;
694
+ opcode: CppProtocolSubdocOpcode;
695
+ status: CppKeyValueStatusCode;
696
+ ec: CppError;
697
+ }
698
+ export interface CppLookupInAllReplicasRequest {
699
+ id: CppDocumentId;
700
+ specs: CppImplSubdocCommand[];
701
+ timeout?: CppMilliseconds;
702
+ }
680
703
  export interface CppAnalyticsResponse {
681
704
  meta: CppAnalyticsResponseAnalyticsMetaData;
682
705
  rows: string[];
@@ -970,6 +993,26 @@ export interface CppInsertWithLegacyDurabilityRequest {
970
993
  persist_to: CppPersistTo;
971
994
  replicate_to: CppReplicateTo;
972
995
  }
996
+ export interface CppLookupInAnyReplicaResponse {
997
+ cas: CppCas;
998
+ fields: CppLookupInAnyReplicaResponseEntry[];
999
+ deleted: boolean;
1000
+ is_replica: boolean;
1001
+ }
1002
+ export interface CppLookupInAnyReplicaResponseEntry {
1003
+ path: string;
1004
+ value: Buffer;
1005
+ original_index: number;
1006
+ exists: boolean;
1007
+ opcode: CppProtocolSubdocOpcode;
1008
+ status: CppKeyValueStatusCode;
1009
+ ec: CppError;
1010
+ }
1011
+ export interface CppLookupInAnyReplicaRequest {
1012
+ id: CppDocumentId;
1013
+ specs: CppImplSubdocCommand[];
1014
+ timeout?: CppMilliseconds;
1015
+ }
973
1016
  export interface CppMutateInResponse {
974
1017
  cas: CppCas;
975
1018
  token: CppMutationToken;
@@ -1884,6 +1927,7 @@ export interface CppConnectionAutogen {
1884
1927
  remove(options: CppRemoveRequest, callback: (err: CppError | null, result: CppRemoveResponse) => void): void;
1885
1928
  removeWithLegacyDurability(options: CppRemoveWithLegacyDurabilityRequest, callback: (err: CppError | null, result: CppRemoveResponse) => void): void;
1886
1929
  get(options: CppGetRequest, callback: (err: CppError | null, result: CppGetResponse) => void): void;
1930
+ lookupInAllReplicas(options: CppLookupInAllReplicasRequest, callback: (err: CppError | null, result: CppLookupInAllReplicasResponse) => void): void;
1887
1931
  analytics(options: CppAnalyticsRequest, callback: (err: CppError | null, result: CppAnalyticsResponse) => void): void;
1888
1932
  getProjected(options: CppGetProjectedRequest, callback: (err: CppError | null, result: CppGetProjectedResponse) => void): void;
1889
1933
  decrement(options: CppDecrementRequest, callback: (err: CppError | null, result: CppDecrementResponse) => void): void;
@@ -1895,6 +1939,7 @@ export interface CppConnectionAutogen {
1895
1939
  getAndLock(options: CppGetAndLockRequest, callback: (err: CppError | null, result: CppGetAndLockResponse) => void): void;
1896
1940
  insert(options: CppInsertRequest, callback: (err: CppError | null, result: CppInsertResponse) => void): void;
1897
1941
  insertWithLegacyDurability(options: CppInsertWithLegacyDurabilityRequest, callback: (err: CppError | null, result: CppInsertResponse) => void): void;
1942
+ lookupInAnyReplica(options: CppLookupInAnyReplicaRequest, callback: (err: CppError | null, result: CppLookupInAnyReplicaResponse) => void): void;
1898
1943
  mutateIn(options: CppMutateInRequest, callback: (err: CppError | null, result: CppMutateInResponse) => void): void;
1899
1944
  mutateInWithLegacyDurability(options: CppMutateInWithLegacyDurabilityRequest, callback: (err: CppError | null, result: CppMutateInResponse) => void): void;
1900
1945
  increment(options: CppIncrementRequest, callback: (err: CppError | null, result: CppIncrementResponse) => void): void;
@@ -2671,6 +2716,8 @@ export interface CppTransaction {
2671
2716
  export interface CppBinding extends CppBindingAutogen {
2672
2717
  cbppVersion: string;
2673
2718
  cbppMetadata: string;
2719
+ enableProtocolLogger: (filename: string) => void;
2720
+ shutdownLogger: () => void;
2674
2721
  Connection: {
2675
2722
  new (): CppConnection;
2676
2723
  };
@@ -2,7 +2,7 @@
2
2
  import { IncrementOptions, DecrementOptions, AppendOptions, PrependOptions, BinaryCollection } from './binarycollection';
3
3
  import { CppDocumentId, CppConnection, CppScanIterator, CppRangeScanOrchestratorOptions } from './binding';
4
4
  import { Cluster } from './cluster';
5
- import { CounterResult, ExistsResult, GetReplicaResult, GetResult, LookupInResult, MutateInResult, MutationResult, ScanResult } from './crudoptypes';
5
+ import { CounterResult, ExistsResult, GetReplicaResult, GetResult, LookupInResult, LookupInReplicaResult, MutateInResult, MutationResult, ScanResult } from './crudoptypes';
6
6
  import { CouchbaseList, CouchbaseMap, CouchbaseQueue, CouchbaseSet } from './datastructures';
7
7
  import { DurabilityLevel, StoreSemantics } from './generaltypes';
8
8
  import { MutationState } from './mutationstate';
@@ -270,6 +270,30 @@ export interface LookupInOptions {
270
270
  * The timeout for this operation, represented in milliseconds.
271
271
  */
272
272
  timeout?: number;
273
+ /**
274
+ * For internal use only - allows access to deleted documents that are in 'tombstone' form
275
+ *
276
+ * @internal
277
+ */
278
+ accessDeleted?: boolean;
279
+ }
280
+ /**
281
+ * @category Key-Value
282
+ */
283
+ export interface LookupInAnyReplicaOptions {
284
+ /**
285
+ * The timeout for this operation, represented in milliseconds.
286
+ */
287
+ timeout?: number;
288
+ }
289
+ /**
290
+ * @category Key-Value
291
+ */
292
+ export interface LookupInAllReplicasOptions {
293
+ /**
294
+ * The timeout for this operation, represented in milliseconds.
295
+ */
296
+ timeout?: number;
273
297
  }
274
298
  /**
275
299
  * @category Key-Value
@@ -567,6 +591,34 @@ export declare class Collection {
567
591
  * @param callback A node-style callback to be invoked after execution.
568
592
  */
569
593
  lookupIn(key: string, specs: LookupInSpec[], options?: LookupInOptions, callback?: NodeCallback<LookupInResult>): Promise<LookupInResult>;
594
+ /**
595
+ * @internal
596
+ */
597
+ _lookupInReplica(key: string, lookupInAllReplicas: boolean, specs: LookupInSpec[], options?: {
598
+ timeout?: number;
599
+ }, callback?: NodeCallback<LookupInReplicaResult[]>): StreamableReplicasPromise<LookupInReplicaResult[], LookupInReplicaResult>;
600
+ /**
601
+ * Performs a lookup-in operation against a document, fetching individual fields or
602
+ * information about specific fields inside the document value from any of the available
603
+ * replicas in the cluster.
604
+ *
605
+ * @param key The document key to look in.
606
+ * @param specs A list of specs describing the data to fetch from the document.
607
+ * @param options Optional parameters for this operation.
608
+ * @param callback A node-style callback to be invoked after execution.
609
+ */
610
+ lookupInAnyReplica(key: string, specs: LookupInSpec[], options?: LookupInOptions, callback?: NodeCallback<LookupInReplicaResult>): Promise<LookupInReplicaResult>;
611
+ /**
612
+ * Performs a lookup-in operation against a document, fetching individual fields or
613
+ * information about specific fields inside the document value from all available replicas.
614
+ * Note that as replication is asynchronous, each node may return a different value.
615
+ *
616
+ * @param key The document key to look in.
617
+ * @param specs A list of specs describing the data to fetch from the document.
618
+ * @param options Optional parameters for this operation.
619
+ * @param callback A node-style callback to be invoked after execution.
620
+ */
621
+ lookupInAllReplicas(key: string, specs: LookupInSpec[], options?: LookupInOptions, callback?: NodeCallback<LookupInReplicaResult[]>): Promise<LookupInReplicaResult[]>;
570
622
  /**
571
623
  * Performs a mutate-in operation against a document. Allowing atomic modification of
572
624
  * specific fields within a document. Also enables access to document extended-attributes.
@@ -939,6 +939,7 @@ class Collection {
939
939
  });
940
940
  }
941
941
  const timeout = options.timeout || this.cluster.kvTimeout;
942
+ const accessDeleted = options.accessDeleted || false;
942
943
  return utilities_1.PromiseHelper.wrap((wrapCallback) => {
943
944
  this._conn.lookupIn({
944
945
  id: this._cppDocId(key),
@@ -946,7 +947,7 @@ class Collection {
946
947
  timeout,
947
948
  partition: 0,
948
949
  opaque: 0,
949
- access_deleted: false,
950
+ access_deleted: accessDeleted,
950
951
  }, (cppErr, resp) => {
951
952
  const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
952
953
  if (resp && resp.fields) {
@@ -978,6 +979,143 @@ class Collection {
978
979
  });
979
980
  }, callback);
980
981
  }
982
+ /**
983
+ * @internal
984
+ */
985
+ _lookupInReplica(key, lookupInAllReplicas, specs, options, callback) {
986
+ if (options instanceof Function) {
987
+ callback = arguments[3];
988
+ options = undefined;
989
+ }
990
+ if (!options) {
991
+ options = {};
992
+ }
993
+ const emitter = new streamablepromises_1.StreamableReplicasPromise((replicas) => replicas);
994
+ const cppSpecs = [];
995
+ for (let i = 0; i < specs.length; ++i) {
996
+ cppSpecs.push({
997
+ opcode_: specs[i]._op,
998
+ flags_: specs[i]._flags,
999
+ path_: specs[i]._path,
1000
+ original_index_: i,
1001
+ });
1002
+ }
1003
+ const timeout = options.timeout || this.cluster.kvTimeout;
1004
+ if (lookupInAllReplicas) {
1005
+ this._conn.lookupInAllReplicas({
1006
+ id: this._cppDocId(key),
1007
+ specs: cppSpecs,
1008
+ timeout: timeout,
1009
+ }, (cppErr, resp) => {
1010
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
1011
+ if (err) {
1012
+ emitter.emit('error', err);
1013
+ emitter.emit('end');
1014
+ return;
1015
+ }
1016
+ resp.entries.forEach((replica) => {
1017
+ const content = [];
1018
+ for (let i = 0; i < replica.fields.length; ++i) {
1019
+ const itemRes = replica.fields[i];
1020
+ let error = (0, bindingutilities_1.errorFromCpp)(itemRes.ec);
1021
+ let value = undefined;
1022
+ if (itemRes.value && itemRes.value.length > 0) {
1023
+ value = this._subdocDecode(itemRes.value);
1024
+ }
1025
+ // BUG(JSCBC-1016): Should remove this workaround when the underlying bug is resolved.
1026
+ if (itemRes.opcode === binding_1.default.protocol_subdoc_opcode.exists) {
1027
+ error = null;
1028
+ value = itemRes.exists;
1029
+ }
1030
+ content.push(new crudoptypes_1.LookupInResultEntry({
1031
+ error,
1032
+ value,
1033
+ }));
1034
+ }
1035
+ emitter.emit('replica', new crudoptypes_1.LookupInReplicaResult(({
1036
+ content: content,
1037
+ cas: replica.cas,
1038
+ isReplica: replica.is_replica
1039
+ })));
1040
+ });
1041
+ emitter.emit('end');
1042
+ return;
1043
+ });
1044
+ }
1045
+ else {
1046
+ this._conn.lookupInAnyReplica({
1047
+ id: this._cppDocId(key),
1048
+ specs: cppSpecs,
1049
+ timeout: timeout,
1050
+ }, (cppErr, resp) => {
1051
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
1052
+ if (err) {
1053
+ emitter.emit('error', err);
1054
+ emitter.emit('end');
1055
+ return;
1056
+ }
1057
+ const content = [];
1058
+ for (let i = 0; i < resp.fields.length; ++i) {
1059
+ const itemRes = resp.fields[i];
1060
+ let error = (0, bindingutilities_1.errorFromCpp)(itemRes.ec);
1061
+ let value = undefined;
1062
+ if (itemRes.value && itemRes.value.length > 0) {
1063
+ value = this._subdocDecode(itemRes.value);
1064
+ }
1065
+ // BUG(JSCBC-1016): Should remove this workaround when the underlying bug is resolved.
1066
+ if (itemRes.opcode === binding_1.default.protocol_subdoc_opcode.exists) {
1067
+ error = null;
1068
+ value = itemRes.exists;
1069
+ }
1070
+ content.push(new crudoptypes_1.LookupInResultEntry({
1071
+ error,
1072
+ value,
1073
+ }));
1074
+ }
1075
+ emitter.emit('replica', new crudoptypes_1.GetReplicaResult({
1076
+ content: content,
1077
+ cas: resp.cas,
1078
+ isReplica: resp.is_replica,
1079
+ }));
1080
+ emitter.emit('end');
1081
+ return;
1082
+ });
1083
+ }
1084
+ return utilities_1.PromiseHelper.wrapAsync(() => emitter, callback);
1085
+ }
1086
+ /**
1087
+ * Performs a lookup-in operation against a document, fetching individual fields or
1088
+ * information about specific fields inside the document value from any of the available
1089
+ * replicas in the cluster.
1090
+ *
1091
+ * @param key The document key to look in.
1092
+ * @param specs A list of specs describing the data to fetch from the document.
1093
+ * @param options Optional parameters for this operation.
1094
+ * @param callback A node-style callback to be invoked after execution.
1095
+ */
1096
+ lookupInAnyReplica(key, specs, options, callback) {
1097
+ if (options instanceof Function) {
1098
+ callback = arguments[2];
1099
+ options = undefined;
1100
+ }
1101
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
1102
+ const replicas = await this._lookupInReplica(key, false, specs, options);
1103
+ return replicas[0];
1104
+ }, callback);
1105
+ }
1106
+ /**
1107
+ * Performs a lookup-in operation against a document, fetching individual fields or
1108
+ * information about specific fields inside the document value from all available replicas.
1109
+ * Note that as replication is asynchronous, each node may return a different value.
1110
+ *
1111
+ * @param key The document key to look in.
1112
+ * @param specs A list of specs describing the data to fetch from the document.
1113
+ * @param options Optional parameters for this operation.
1114
+ * @param callback A node-style callback to be invoked after execution.
1115
+ */
1116
+ lookupInAllReplicas(key, specs, options, callback) {
1117
+ return this._lookupInReplica(key, true, specs, options, callback);
1118
+ }
981
1119
  /**
982
1120
  * Performs a mutate-in operation against a document. Allowing atomic modification of
983
1121
  * specific fields within a document. Also enables access to document extended-attributes.
@@ -23,6 +23,21 @@ export declare const lcbVersion: string;
23
23
  */
24
24
  export declare const cbppVersion: string;
25
25
  export declare const cbppMetadata: string;
26
+ /**
27
+ * Volatile: This API is subject to change at any time.
28
+ *
29
+ * Exposes the underlying couchbase++ library protocol logger. This method is for
30
+ * logging/debugging purposes and must be used with caution as network details will
31
+ * be logged to the provided file.
32
+ */
33
+ export declare function enableProtocolLoggerToSaveNetworkTrafficToFile(filename: string): void;
34
+ /**
35
+ * Volatile: This API is subject to change at any time.
36
+ *
37
+ * Shutdowns the underlying couchbase++ logger.
38
+ *
39
+ */
40
+ export declare function shutdownLogger(): void;
26
41
  export * from './analyticsindexmanager';
27
42
  export * from './analyticstypes';
28
43
  export * from './authenticators';
package/dist/couchbase.js CHANGED
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.cbppMetadata = exports.cbppVersion = exports.lcbVersion = exports.connect = void 0;
20
+ exports.shutdownLogger = exports.enableProtocolLoggerToSaveNetworkTrafficToFile = exports.cbppMetadata = exports.cbppVersion = exports.lcbVersion = exports.connect = void 0;
21
21
  const binding_1 = __importDefault(require("./binding"));
22
22
  const cluster_1 = require("./cluster");
23
23
  /**
@@ -46,6 +46,27 @@ exports.lcbVersion = binding_1.default.cbppVersion;
46
46
  */
47
47
  exports.cbppVersion = binding_1.default.cbppVersion;
48
48
  exports.cbppMetadata = binding_1.default.cbppMetadata;
49
+ /**
50
+ * Volatile: This API is subject to change at any time.
51
+ *
52
+ * Exposes the underlying couchbase++ library protocol logger. This method is for
53
+ * logging/debugging purposes and must be used with caution as network details will
54
+ * be logged to the provided file.
55
+ */
56
+ function enableProtocolLoggerToSaveNetworkTrafficToFile(filename) {
57
+ binding_1.default.enableProtocolLogger(filename);
58
+ }
59
+ exports.enableProtocolLoggerToSaveNetworkTrafficToFile = enableProtocolLoggerToSaveNetworkTrafficToFile;
60
+ /**
61
+ * Volatile: This API is subject to change at any time.
62
+ *
63
+ * Shutdowns the underlying couchbase++ logger.
64
+ *
65
+ */
66
+ function shutdownLogger() {
67
+ binding_1.default.shutdownLogger();
68
+ }
69
+ exports.shutdownLogger = shutdownLogger;
49
70
  __exportStar(require("./analyticsindexmanager"), exports);
50
71
  __exportStar(require("./analyticstypes"), exports);
51
72
  __exportStar(require("./authenticators"), exports);
@@ -189,6 +189,30 @@ export declare class LookupInResult {
189
189
  get results(): LookupInResultEntry[];
190
190
  set results(v: LookupInResultEntry[]);
191
191
  }
192
+ /**
193
+ * Contains the results of a lookup-in replica operation.
194
+ *
195
+ * @category Key-Value
196
+ */
197
+ export declare class LookupInReplicaResult {
198
+ /**
199
+ * A list of result entries for each sub-operation performed.
200
+ */
201
+ content: LookupInResultEntry[];
202
+ /**
203
+ * The cas of the document.
204
+ */
205
+ cas: Cas;
206
+ /**
207
+ * Indicates whether this result came from a replica or the primary.
208
+ */
209
+ isReplica: boolean;
210
+ constructor(data: {
211
+ content: LookupInResultEntry[];
212
+ cas: Cas;
213
+ isReplica: boolean;
214
+ });
215
+ }
192
216
  /**
193
217
  * Contains the results of a specific sub-operation within a mutate-in operation.
194
218
  *
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CounterResult = exports.MutateInResult = exports.MutateInResultEntry = exports.LookupInResult = exports.LookupInResultEntry = exports.GetReplicaResult = exports.MutationResult = exports.ExistsResult = exports.ScanResult = exports.GetResult = void 0;
3
+ exports.CounterResult = exports.MutateInResult = exports.MutateInResultEntry = exports.LookupInReplicaResult = exports.LookupInResult = exports.LookupInResultEntry = exports.GetReplicaResult = exports.MutationResult = exports.ExistsResult = exports.ScanResult = exports.GetResult = void 0;
4
4
  /**
5
5
  * Contains the results of a Get operation.
6
6
  *
@@ -140,6 +140,19 @@ class LookupInResult {
140
140
  }
141
141
  }
142
142
  exports.LookupInResult = LookupInResult;
143
+ /**
144
+ * Contains the results of a lookup-in replica operation.
145
+ *
146
+ * @category Key-Value
147
+ */
148
+ class LookupInReplicaResult {
149
+ constructor(data) {
150
+ this.content = data.content;
151
+ this.cas = data.cas;
152
+ this.isReplica = data.isReplica;
153
+ }
154
+ }
155
+ exports.LookupInReplicaResult = LookupInReplicaResult;
143
156
  /**
144
157
  * Contains the results of a specific sub-operation within a mutate-in operation.
145
158
  *
package/package.json CHANGED
@@ -55,7 +55,7 @@
55
55
  "type": "git",
56
56
  "url": "http://github.com/couchbase/couchnode.git"
57
57
  },
58
- "version": "4.2.6-dev.1",
58
+ "version": "4.2.7",
59
59
  "config": {
60
60
  "native": false
61
61
  },
@@ -80,17 +80,17 @@
80
80
  ]
81
81
  },
82
82
  "optionalDependencies": {
83
- "@couchbase/couchbase-darwin-arm64-openssl1": "4.2.6-dev.1",
84
- "@couchbase/couchbase-darwin-arm64-openssl3": "4.2.6-dev.1",
85
- "@couchbase/couchbase-darwin-x64-openssl1": "4.2.6-dev.1",
86
- "@couchbase/couchbase-darwin-x64-openssl3": "4.2.6-dev.1",
87
- "@couchbase/couchbase-linux-arm64-openssl1": "4.2.6-dev.1",
88
- "@couchbase/couchbase-linux-arm64-openssl3": "4.2.6-dev.1",
89
- "@couchbase/couchbase-linux-x64-openssl1": "4.2.6-dev.1",
90
- "@couchbase/couchbase-linux-x64-openssl3": "4.2.6-dev.1",
91
- "@couchbase/couchbase-linuxmusl-x64-openssl1": "4.2.6-dev.1",
92
- "@couchbase/couchbase-linuxmusl-x64-openssl3": "4.2.6-dev.1",
93
- "@couchbase/couchbase-win32-x64-openssl1": "4.2.6-dev.1",
94
- "@couchbase/couchbase-win32-x64-openssl3": "4.2.6-dev.1"
83
+ "@couchbase/couchbase-darwin-arm64-openssl1": "4.2.7",
84
+ "@couchbase/couchbase-darwin-arm64-openssl3": "4.2.7",
85
+ "@couchbase/couchbase-darwin-x64-openssl1": "4.2.7",
86
+ "@couchbase/couchbase-darwin-x64-openssl3": "4.2.7",
87
+ "@couchbase/couchbase-linux-arm64-openssl1": "4.2.7",
88
+ "@couchbase/couchbase-linux-arm64-openssl3": "4.2.7",
89
+ "@couchbase/couchbase-linux-x64-openssl1": "4.2.7",
90
+ "@couchbase/couchbase-linux-x64-openssl3": "4.2.7",
91
+ "@couchbase/couchbase-linuxmusl-x64-openssl1": "4.2.7",
92
+ "@couchbase/couchbase-linuxmusl-x64-openssl3": "4.2.7",
93
+ "@couchbase/couchbase-win32-x64-openssl1": "4.2.7",
94
+ "@couchbase/couchbase-win32-x64-openssl3": "4.2.7"
95
95
  }
96
96
  }
package/src/binding.cpp CHANGED
@@ -6,12 +6,36 @@
6
6
  #include "scan_iterator.hpp"
7
7
  #include "transaction.hpp"
8
8
  #include "transactions.hpp"
9
+ #include <core/logger/configuration.hxx>
9
10
  #include <napi.h>
10
11
  #include <spdlog/spdlog.h>
11
12
 
12
13
  namespace couchnode
13
14
  {
14
15
 
16
+ Napi::Value enable_protocol_logger(const Napi::CallbackInfo &info)
17
+ {
18
+ try {
19
+ auto filename = info[0].ToString().Utf8Value();
20
+ couchbase::core::logger::configuration configuration{};
21
+ configuration.filename = filename;
22
+ couchbase::core::logger::create_protocol_logger(configuration);
23
+ } catch (...) {
24
+ return Napi::Error::New(info.Env(), "Unexpected C++ error").Value();
25
+ }
26
+ return info.Env().Null();
27
+ }
28
+
29
+ Napi::Value shutdown_logger(const Napi::CallbackInfo &info)
30
+ {
31
+ try {
32
+ couchbase::core::logger::shutdown();
33
+ } catch (...) {
34
+ return Napi::Error::New(info.Env(), "Unexpected C++ error").Value();
35
+ }
36
+ return info.Env().Null();
37
+ }
38
+
15
39
  Napi::Object Init(Napi::Env env, Napi::Object exports)
16
40
  {
17
41
  spdlog::set_pattern("[%Y-%m-%d %T.%e] [%P,%t] [%^%l%$] %oms, %v");
@@ -63,6 +87,10 @@ Napi::Object Init(Napi::Env env, Napi::Object exports)
63
87
  exports.Set(
64
88
  Napi::String::New(env, "cbppMetadata"),
65
89
  Napi::String::New(env, couchbase::core::meta::sdk_build_info_json()));
90
+ exports.Set(Napi::String::New(env, "enableProtocolLogger"),
91
+ Napi::Function::New<enable_protocol_logger>(env));
92
+ exports.Set(Napi::String::New(env, "shutdownLogger"),
93
+ Napi::Function::New<shutdown_logger>(env));
66
94
  return exports;
67
95
  }
68
96
 
@@ -65,6 +65,8 @@ void Connection::Init(Napi::Env env, Napi::Object exports)
65
65
  InstanceMethod<&Connection::jsRemoveWithLegacyDurability>(
66
66
  "removeWithLegacyDurability"),
67
67
  InstanceMethod<&Connection::jsGet>("get"),
68
+ InstanceMethod<&Connection::jsLookupInAllReplicas>(
69
+ "lookupInAllReplicas"),
68
70
  InstanceMethod<&Connection::jsAnalytics>("analytics"),
69
71
  InstanceMethod<&Connection::jsGetProjected>("getProjected"),
70
72
  InstanceMethod<&Connection::jsDecrement>("decrement"),
@@ -78,6 +80,8 @@ void Connection::Init(Napi::Env env, Napi::Object exports)
78
80
  InstanceMethod<&Connection::jsInsert>("insert"),
79
81
  InstanceMethod<&Connection::jsInsertWithLegacyDurability>(
80
82
  "insertWithLegacyDurability"),
83
+ InstanceMethod<&Connection::jsLookupInAnyReplica>(
84
+ "lookupInAnyReplica"),
81
85
  InstanceMethod<&Connection::jsMutateIn>("mutateIn"),
82
86
  InstanceMethod<&Connection::jsMutateInWithLegacyDurability>(
83
87
  "mutateInWithLegacyDurability"),
@@ -91,6 +91,7 @@ public:
91
91
  Napi::Value jsRemove(const Napi::CallbackInfo &info);
92
92
  Napi::Value jsRemoveWithLegacyDurability(const Napi::CallbackInfo &info);
93
93
  Napi::Value jsGet(const Napi::CallbackInfo &info);
94
+ Napi::Value jsLookupInAllReplicas(const Napi::CallbackInfo &info);
94
95
  Napi::Value jsAnalytics(const Napi::CallbackInfo &info);
95
96
  Napi::Value jsGetProjected(const Napi::CallbackInfo &info);
96
97
  Napi::Value jsDecrement(const Napi::CallbackInfo &info);
@@ -102,6 +103,7 @@ public:
102
103
  Napi::Value jsGetAndLock(const Napi::CallbackInfo &info);
103
104
  Napi::Value jsInsert(const Napi::CallbackInfo &info);
104
105
  Napi::Value jsInsertWithLegacyDurability(const Napi::CallbackInfo &info);
106
+ Napi::Value jsLookupInAnyReplica(const Napi::CallbackInfo &info);
105
107
  Napi::Value jsMutateIn(const Napi::CallbackInfo &info);
106
108
  Napi::Value jsMutateInWithLegacyDurability(const Napi::CallbackInfo &info);
107
109
  Napi::Value jsIncrement(const Napi::CallbackInfo &info);
@@ -242,6 +242,20 @@ Napi::Value Connection::jsGet(const Napi::CallbackInfo &info)
242
242
  return info.Env().Null();
243
243
  }
244
244
 
245
+ Napi::Value Connection::jsLookupInAllReplicas(const Napi::CallbackInfo &info)
246
+ {
247
+ auto optsJsObj = info[0].As<Napi::Object>();
248
+ auto callbackJsFn = info[1].As<Napi::Function>();
249
+
250
+ executeOp(
251
+ "lookupInAllReplicas",
252
+ jsToCbpp<couchbase::core::operations::lookup_in_all_replicas_request>(
253
+ optsJsObj),
254
+ callbackJsFn);
255
+
256
+ return info.Env().Null();
257
+ }
258
+
245
259
  Napi::Value Connection::jsAnalytics(const Napi::CallbackInfo &info)
246
260
  {
247
261
  auto optsJsObj = info[0].As<Napi::Object>();
@@ -386,6 +400,20 @@ Connection::jsInsertWithLegacyDurability(const Napi::CallbackInfo &info)
386
400
  return info.Env().Null();
387
401
  }
388
402
 
403
+ Napi::Value Connection::jsLookupInAnyReplica(const Napi::CallbackInfo &info)
404
+ {
405
+ auto optsJsObj = info[0].As<Napi::Object>();
406
+ auto callbackJsFn = info[1].As<Napi::Function>();
407
+
408
+ executeOp(
409
+ "lookupInAnyReplica",
410
+ jsToCbpp<couchbase::core::operations::lookup_in_any_replica_request>(
411
+ optsJsObj),
412
+ callbackJsFn);
413
+
414
+ return info.Env().Null();
415
+ }
416
+
389
417
  Napi::Value Connection::jsMutateIn(const Napi::CallbackInfo &info)
390
418
  {
391
419
  auto optsJsObj = info[0].As<Napi::Object>();