couchbase 4.2.5-dev.3 → 4.2.6-dev

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. package/README.md +81 -9
  2. package/deps/couchbase-cxx-client/CMakeLists.txt +9 -1
  3. package/deps/couchbase-cxx-client/bin/api.rb +234 -0
  4. package/deps/couchbase-cxx-client/bin/create-search-index +18 -135
  5. package/deps/couchbase-cxx-client/bin/init-cluster +17 -139
  6. package/deps/couchbase-cxx-client/bin/load-sample-buckets +54 -0
  7. package/deps/couchbase-cxx-client/core/cluster.hxx +33 -12
  8. package/deps/couchbase-cxx-client/core/cluster_options.hxx +3 -0
  9. package/deps/couchbase-cxx-client/core/crud_component.cxx +51 -22
  10. package/deps/couchbase-cxx-client/core/impl/build_deferred_query_indexes.cxx +115 -50
  11. package/deps/couchbase-cxx-client/core/impl/cluster.cxx +6 -0
  12. package/deps/couchbase-cxx-client/core/impl/create_bucket.cxx +155 -0
  13. package/deps/couchbase-cxx-client/core/impl/create_query_index.cxx +172 -59
  14. package/deps/couchbase-cxx-client/core/impl/dns_srv_tracker.cxx +2 -1
  15. package/deps/couchbase-cxx-client/core/impl/drop_bucket.cxx +66 -0
  16. package/deps/couchbase-cxx-client/core/impl/drop_query_index.cxx +138 -59
  17. package/deps/couchbase-cxx-client/core/impl/flush_bucket.cxx +66 -0
  18. package/deps/couchbase-cxx-client/core/impl/get_all_buckets.cxx +163 -0
  19. package/deps/couchbase-cxx-client/core/impl/get_all_query_indexes.cxx +67 -37
  20. package/deps/couchbase-cxx-client/core/impl/get_bucket.cxx +153 -0
  21. package/deps/couchbase-cxx-client/core/impl/internal_manager_error_context.cxx +113 -0
  22. package/deps/couchbase-cxx-client/core/impl/internal_manager_error_context.hxx +60 -0
  23. package/deps/couchbase-cxx-client/core/impl/key_value_error_category.cxx +2 -4
  24. package/deps/couchbase-cxx-client/core/impl/manager_error_context.cxx +100 -0
  25. package/deps/couchbase-cxx-client/core/impl/query.cxx +1 -0
  26. package/deps/couchbase-cxx-client/core/impl/update_bucket.cxx +130 -0
  27. package/deps/couchbase-cxx-client/core/impl/watch_query_indexes.cxx +53 -29
  28. package/deps/couchbase-cxx-client/core/io/dns_client.cxx +71 -38
  29. package/deps/couchbase-cxx-client/core/io/dns_config.cxx +5 -4
  30. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +5 -6
  31. package/deps/couchbase-cxx-client/core/meta/features.hxx +6 -0
  32. package/deps/couchbase-cxx-client/core/operations/document_query.cxx +11 -0
  33. package/deps/couchbase-cxx-client/core/operations/document_query.hxx +1 -0
  34. package/deps/couchbase-cxx-client/core/origin.cxx +270 -0
  35. package/deps/couchbase-cxx-client/core/origin.hxx +2 -0
  36. package/deps/couchbase-cxx-client/core/protocol/status.cxx +2 -2
  37. package/deps/couchbase-cxx-client/core/range_scan_options.cxx +3 -27
  38. package/deps/couchbase-cxx-client/core/range_scan_options.hxx +13 -17
  39. package/deps/couchbase-cxx-client/core/range_scan_orchestrator.cxx +367 -170
  40. package/deps/couchbase-cxx-client/core/range_scan_orchestrator.hxx +13 -2
  41. package/deps/couchbase-cxx-client/core/range_scan_orchestrator_options.hxx +5 -3
  42. package/deps/couchbase-cxx-client/core/scan_options.hxx +0 -19
  43. package/deps/couchbase-cxx-client/core/scan_result.cxx +19 -5
  44. package/deps/couchbase-cxx-client/core/scan_result.hxx +5 -2
  45. package/deps/couchbase-cxx-client/core/timeout_defaults.hxx +2 -3
  46. package/deps/couchbase-cxx-client/core/topology/capabilities.hxx +1 -0
  47. package/deps/couchbase-cxx-client/core/topology/capabilities_fmt.hxx +2 -0
  48. package/deps/couchbase-cxx-client/core/topology/collections_manifest_fmt.hxx +1 -1
  49. package/deps/couchbase-cxx-client/core/topology/configuration.hxx +5 -0
  50. package/deps/couchbase-cxx-client/core/topology/configuration_json.hxx +2 -0
  51. package/deps/couchbase-cxx-client/core/utils/connection_string.cxx +4 -0
  52. package/deps/couchbase-cxx-client/couchbase/behavior_options.hxx +19 -2
  53. package/deps/couchbase-cxx-client/couchbase/bucket_manager.hxx +135 -0
  54. package/deps/couchbase-cxx-client/couchbase/build_query_index_options.hxx +0 -30
  55. package/deps/couchbase-cxx-client/couchbase/cluster.hxx +14 -0
  56. package/deps/couchbase-cxx-client/couchbase/collection_query_index_manager.hxx +7 -48
  57. package/deps/couchbase-cxx-client/couchbase/create_bucket_options.hxx +41 -0
  58. package/deps/couchbase-cxx-client/couchbase/create_primary_query_index_options.hxx +0 -29
  59. package/deps/couchbase-cxx-client/couchbase/create_query_index_options.hxx +0 -33
  60. package/deps/couchbase-cxx-client/couchbase/drop_bucket_options.hxx +41 -0
  61. package/deps/couchbase-cxx-client/couchbase/drop_primary_query_index_options.hxx +0 -30
  62. package/deps/couchbase-cxx-client/couchbase/drop_query_index_options.hxx +0 -31
  63. package/deps/couchbase-cxx-client/couchbase/error_codes.hxx +1 -2
  64. package/deps/couchbase-cxx-client/couchbase/flush_bucket_options.hxx +41 -0
  65. package/deps/couchbase-cxx-client/couchbase/get_all_buckets_options.hxx +44 -0
  66. package/deps/couchbase-cxx-client/couchbase/get_all_query_indexes_options.hxx +0 -30
  67. package/deps/couchbase-cxx-client/couchbase/get_bucket_options.hxx +43 -0
  68. package/deps/couchbase-cxx-client/couchbase/management/bucket_settings.hxx +116 -0
  69. package/deps/couchbase-cxx-client/couchbase/manager_error_context.hxx +29 -53
  70. package/deps/couchbase-cxx-client/couchbase/query_index_manager.hxx +16 -83
  71. package/deps/couchbase-cxx-client/couchbase/query_options.hxx +18 -0
  72. package/deps/couchbase-cxx-client/couchbase/security_options.hxx +15 -0
  73. package/deps/couchbase-cxx-client/couchbase/update_bucket_options.hxx +41 -0
  74. package/deps/couchbase-cxx-client/couchbase/watch_query_indexes_options.hxx +0 -31
  75. package/deps/couchbase-cxx-client/docs/cbc-analytics.md +1 -0
  76. package/deps/couchbase-cxx-client/docs/cbc-get.md +1 -0
  77. package/deps/couchbase-cxx-client/docs/cbc-pillowfight.md +1 -0
  78. package/deps/couchbase-cxx-client/docs/cbc-query.md +1 -0
  79. package/deps/couchbase-cxx-client/docs/cbc.md +10 -0
  80. package/deps/couchbase-cxx-client/test/CMakeLists.txt +1 -0
  81. package/deps/couchbase-cxx-client/test/test_integration_collections.cxx +6 -0
  82. package/deps/couchbase-cxx-client/test/test_integration_crud.cxx +5 -0
  83. package/deps/couchbase-cxx-client/test/test_integration_examples.cxx +137 -1
  84. package/deps/couchbase-cxx-client/test/test_integration_management.cxx +709 -266
  85. package/deps/couchbase-cxx-client/test/test_integration_query.cxx +19 -7
  86. package/deps/couchbase-cxx-client/test/test_integration_range_scan.cxx +351 -112
  87. package/deps/couchbase-cxx-client/test/test_integration_search.cxx +10 -1
  88. package/deps/couchbase-cxx-client/test/test_transaction_public_async_api.cxx +13 -12
  89. package/deps/couchbase-cxx-client/test/test_transaction_public_blocking_api.cxx +27 -21
  90. package/deps/couchbase-cxx-client/test/test_unit_query.cxx +75 -0
  91. package/deps/couchbase-cxx-client/test/utils/server_version.hxx +5 -0
  92. package/deps/couchbase-cxx-client/test/utils/wait_until.cxx +29 -10
  93. package/deps/couchbase-cxx-client/test/utils/wait_until.hxx +3 -1
  94. package/deps/couchbase-cxx-client/tools/utils.cxx +4 -1
  95. package/dist/binding.d.ts +21 -16
  96. package/dist/binding.js +1 -4
  97. package/dist/bindingutilities.d.ts +6 -1
  98. package/dist/bindingutilities.js +36 -1
  99. package/dist/collection.d.ts +65 -3
  100. package/dist/collection.js +107 -0
  101. package/dist/crudoptypes.d.ts +34 -0
  102. package/dist/crudoptypes.js +18 -1
  103. package/dist/queryexecutor.js +1 -0
  104. package/dist/querytypes.d.ts +7 -0
  105. package/dist/rangeScan.d.ts +107 -0
  106. package/dist/rangeScan.js +91 -0
  107. package/dist/streamablepromises.d.ts +6 -0
  108. package/dist/streamablepromises.js +25 -1
  109. package/package.json +13 -14
  110. package/scripts/createPlatformPackages.js +1 -4
  111. package/src/addondata.hpp +1 -0
  112. package/src/binding.cpp +5 -2
  113. package/src/connection.cpp +108 -2
  114. package/src/connection.hpp +1 -0
  115. package/src/constants.cpp +2 -12
  116. package/src/jstocbpp_autogen.hpp +49 -22
  117. package/src/jstocbpp_basic.hpp +2 -8
  118. package/src/mutationtoken.cpp +13 -0
  119. package/src/scan_iterator.cpp +90 -0
  120. package/src/scan_iterator.hpp +30 -0
  121. package/tools/gen-bindings-json.py +9 -8
  122. package/deps/couchbase-cxx-client/core/impl/collection_query_index_manager.cxx +0 -93
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.errorFromCpp = exports.contextFromCpp = exports.pingStateFromCpp = exports.txnOpExeptionFromCpp = exports.txnExternalExceptionStringFromCpp = exports.endpointStateFromCpp = exports.serviceTypeFromCpp = exports.serviceTypeToCpp = exports.mutationStateToCpp = exports.searchHighlightStyleToCpp = exports.searchScanConsistencyToCpp = exports.analyticsStatusFromCpp = exports.analyticsScanConsistencyToCpp = exports.queryProfileToCpp = exports.queryScanConsistencyToCpp = exports.viewOrderingToCpp = exports.viewScanConsistencyToCpp = exports.storeSemanticToCpp = exports.replicateToToCpp = exports.persistToToCpp = exports.durabilityToCpp = void 0;
29
+ exports.scanTypeToCpp = exports.errorFromCpp = exports.contextFromCpp = exports.pingStateFromCpp = exports.txnOpExeptionFromCpp = exports.txnExternalExceptionStringFromCpp = exports.endpointStateFromCpp = exports.serviceTypeFromCpp = exports.serviceTypeToCpp = exports.mutationStateToCpp = exports.searchHighlightStyleToCpp = exports.searchScanConsistencyToCpp = exports.analyticsStatusFromCpp = exports.analyticsScanConsistencyToCpp = exports.queryProfileToCpp = exports.queryScanConsistencyToCpp = exports.viewOrderingToCpp = exports.viewScanConsistencyToCpp = exports.storeSemanticToCpp = exports.replicateToToCpp = exports.persistToToCpp = exports.durabilityToCpp = void 0;
30
30
  const analyticstypes_1 = require("./analyticstypes");
31
31
  const binding_1 = __importDefault(require("./binding"));
32
32
  const diagnosticstypes_1 = require("./diagnosticstypes");
@@ -34,6 +34,7 @@ const errctxs = __importStar(require("./errorcontexts"));
34
34
  const errs = __importStar(require("./errors"));
35
35
  const generaltypes_1 = require("./generaltypes");
36
36
  const querytypes_1 = require("./querytypes");
37
+ const rangeScan_1 = require("./rangeScan");
37
38
  const searchtypes_1 = require("./searchtypes");
38
39
  const viewtypes_1 = require("./viewtypes");
39
40
  /**
@@ -755,3 +756,37 @@ function errorFromCpp(err) {
755
756
  return baseErr;
756
757
  }
757
758
  exports.errorFromCpp = errorFromCpp;
759
+ /**
760
+ * @internal
761
+ */
762
+ function scanTypeToCpp(scanType) {
763
+ var _a, _b, _c, _d;
764
+ if (scanType instanceof rangeScan_1.RangeScan) {
765
+ return {
766
+ from: scanType.start !== undefined
767
+ ? {
768
+ term: scanType.start.term,
769
+ exclusive: (_b = (_a = scanType.start) === null || _a === void 0 ? void 0 : _a.exclusive) !== null && _b !== void 0 ? _b : false,
770
+ }
771
+ : undefined,
772
+ to: scanType.end !== undefined
773
+ ? {
774
+ term: scanType.end.term,
775
+ exclusive: (_d = (_c = scanType.end) === null || _c === void 0 ? void 0 : _c.exclusive) !== null && _d !== void 0 ? _d : false,
776
+ }
777
+ : undefined,
778
+ };
779
+ }
780
+ else if (scanType instanceof rangeScan_1.SamplingScan) {
781
+ return {
782
+ limit: scanType.limit,
783
+ seed: scanType.seed,
784
+ };
785
+ }
786
+ else {
787
+ return {
788
+ prefix: scanType.prefix,
789
+ };
790
+ }
791
+ }
792
+ exports.scanTypeToCpp = scanTypeToCpp;
@@ -1,14 +1,16 @@
1
1
  /// <reference types="node" />
2
2
  import { IncrementOptions, DecrementOptions, AppendOptions, PrependOptions, BinaryCollection } from './binarycollection';
3
- import { CppDocumentId, CppConnection } from './binding';
3
+ import { CppDocumentId, CppConnection, CppScanIterator, CppRangeScanOrchestratorOptions } from './binding';
4
4
  import { Cluster } from './cluster';
5
- import { CounterResult, ExistsResult, GetReplicaResult, GetResult, LookupInResult, MutateInResult, MutationResult } from './crudoptypes';
5
+ import { CounterResult, ExistsResult, GetReplicaResult, GetResult, LookupInResult, MutateInResult, MutationResult, ScanResult } from './crudoptypes';
6
6
  import { CouchbaseList, CouchbaseMap, CouchbaseQueue, CouchbaseSet } from './datastructures';
7
7
  import { DurabilityLevel, StoreSemantics } from './generaltypes';
8
+ import { MutationState } from './mutationstate';
8
9
  import { CollectionQueryIndexManager } from './queryindexmanager';
10
+ import { RangeScan, SamplingScan, PrefixScan } from './rangeScan';
9
11
  import { Scope } from './scope';
10
12
  import { LookupInSpec, MutateInSpec } from './sdspecs';
11
- import { StreamableReplicasPromise } from './streamablepromises';
13
+ import { StreamableReplicasPromise, StreamableScanPromise } from './streamablepromises';
12
14
  import { Transcoder } from './transcoders';
13
15
  import { NodeCallback, Cas } from './utilities';
14
16
  /**
@@ -318,6 +320,45 @@ export interface MutateInOptions {
318
320
  */
319
321
  upsertDocument?: boolean;
320
322
  }
323
+ /**
324
+ * Volatile: This API is subject to change at any time.
325
+ *
326
+ * @category Key-Value
327
+ */
328
+ export interface ScanOptions {
329
+ /**
330
+ * Specifies an explicit transcoder to use for this specific operation.
331
+ */
332
+ transcoder?: Transcoder;
333
+ /**
334
+ * The timeout for this operation, represented in milliseconds.
335
+ */
336
+ timeout?: number;
337
+ /**
338
+ * If the scan should only return document ids.
339
+ */
340
+ idsOnly?: boolean;
341
+ /**
342
+ * The limit applied to the number of bytes returned from the server
343
+ * for each partition batch.
344
+ */
345
+ batchByteLimit?: number;
346
+ /**
347
+ * The limit applied to the number of items returned from the server
348
+ * for each partition batch.
349
+ */
350
+ batchItemLimit?: number;
351
+ /**
352
+ * Specifies a MutationState which the scan should be consistent with.
353
+ *
354
+ * @see {@link MutationState}
355
+ */
356
+ consistentWith?: MutationState;
357
+ /**
358
+ * Specifies the number of vBuckets which the client should scan in parallel.
359
+ */
360
+ concurrency?: number;
361
+ }
321
362
  /**
322
363
  * Exposes the operations which are available to be performed against a collection.
323
364
  * Namely the ability to perform KV operations.
@@ -332,6 +373,9 @@ export declare class Collection {
332
373
  private _scope;
333
374
  private _name;
334
375
  private _conn;
376
+ private _kvScanTimeout;
377
+ private _scanBatchItemLimit;
378
+ private _scanBatchByteLimit;
335
379
  /**
336
380
  @internal
337
381
  */
@@ -495,6 +539,24 @@ export declare class Collection {
495
539
  * @param callback A node-style callback to be invoked after execution.
496
540
  */
497
541
  unlock(key: string, cas: Cas, options?: UnlockOptions, callback?: NodeCallback<void>): Promise<void>;
542
+ /**
543
+ * @internal
544
+ */
545
+ _continueScan(iterator: CppScanIterator, transcoder: Transcoder, emitter: StreamableScanPromise<ScanResult[], ScanResult>): void;
546
+ /**
547
+ * @internal
548
+ */
549
+ _doScan(scanType: RangeScan | SamplingScan | PrefixScan, options: CppRangeScanOrchestratorOptions, transcoder: Transcoder, callback?: NodeCallback<ScanResult[]>): StreamableScanPromise<ScanResult[], ScanResult>;
550
+ /**
551
+ * Performs a key-value scan operation.
552
+ *
553
+ * Volatile: This API is subject to change at any time.
554
+ *
555
+ * @param scanType The type of scan to execute.
556
+ * @param options Optional parameters for the scan operation.
557
+ * @param callback A node-style callback to be invoked after execution.
558
+ */
559
+ scan(scanType: RangeScan | SamplingScan | PrefixScan, options?: ScanOptions, callback?: NodeCallback<ScanResult[]>): Promise<ScanResult[]>;
498
560
  /**
499
561
  * Performs a lookup-in operation against a document, fetching individual fields or
500
562
  * information about specific fields inside the document value.
@@ -29,8 +29,10 @@ const binding_1 = __importStar(require("./binding"));
29
29
  const bindingutilities_1 = require("./bindingutilities");
30
30
  const crudoptypes_1 = require("./crudoptypes");
31
31
  const datastructures_1 = require("./datastructures");
32
+ const errors_1 = require("./errors");
32
33
  const generaltypes_1 = require("./generaltypes");
33
34
  const queryindexmanager_1 = require("./queryindexmanager");
35
+ const rangeScan_1 = require("./rangeScan");
34
36
  const sdspecs_1 = require("./sdspecs");
35
37
  const sdutils_1 = require("./sdutils");
36
38
  const streamablepromises_1 = require("./streamablepromises");
@@ -55,6 +57,9 @@ class Collection {
55
57
  this._scope = scope;
56
58
  this._name = collectionName;
57
59
  this._conn = scope.conn;
60
+ this._kvScanTimeout = 75000;
61
+ this._scanBatchByteLimit = 15000;
62
+ this._scanBatchItemLimit = 50;
58
63
  }
59
64
  /**
60
65
  @internal
@@ -805,6 +810,108 @@ class Collection {
805
810
  });
806
811
  }, callback);
807
812
  }
813
+ /**
814
+ * @internal
815
+ */
816
+ _continueScan(iterator, transcoder, emitter) {
817
+ iterator.next((cppErr, resp) => {
818
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
819
+ if (err) {
820
+ emitter.emit('error', err);
821
+ emitter.emit('end');
822
+ return;
823
+ }
824
+ if (typeof resp === 'undefined') {
825
+ emitter.emit('end');
826
+ return;
827
+ }
828
+ const key = resp.key;
829
+ if (typeof resp.body !== 'undefined') {
830
+ const cas = resp.body.cas;
831
+ const expiry = resp.body.expiry;
832
+ this._decodeDoc(transcoder, resp.body.value, resp.body.flags, (err, content) => {
833
+ if (err) {
834
+ emitter.emit('error', err);
835
+ emitter.emit('end');
836
+ return;
837
+ }
838
+ emitter.emit('result', new crudoptypes_1.ScanResult({
839
+ id: key,
840
+ content: content,
841
+ cas: cas,
842
+ expiryTime: expiry,
843
+ }));
844
+ });
845
+ }
846
+ else {
847
+ emitter.emit('result', new crudoptypes_1.ScanResult({
848
+ id: key,
849
+ }));
850
+ }
851
+ if (emitter.cancelRequested && !iterator.cancelled) {
852
+ iterator.cancel();
853
+ }
854
+ this._continueScan(iterator, transcoder, emitter);
855
+ return;
856
+ });
857
+ }
858
+ /**
859
+ * @internal
860
+ */
861
+ _doScan(scanType, options, transcoder, callback) {
862
+ const bucketName = this._scope.bucket.name;
863
+ const scopeName = this._scope.name;
864
+ const collectionName = this._name;
865
+ return utilities_1.PromiseHelper.wrapAsync(() => {
866
+ const { cppErr, result } = this._conn.scan(bucketName, scopeName, collectionName, scanType.getScanType(), (0, bindingutilities_1.scanTypeToCpp)(scanType), options);
867
+ const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
868
+ if (err) {
869
+ throw err;
870
+ }
871
+ const emitter = new streamablepromises_1.StreamableScanPromise((results) => results);
872
+ this._continueScan(result, transcoder, emitter);
873
+ return emitter;
874
+ }, callback);
875
+ }
876
+ /**
877
+ * Performs a key-value scan operation.
878
+ *
879
+ * Volatile: This API is subject to change at any time.
880
+ *
881
+ * @param scanType The type of scan to execute.
882
+ * @param options Optional parameters for the scan operation.
883
+ * @param callback A node-style callback to be invoked after execution.
884
+ */
885
+ scan(scanType, options, callback) {
886
+ if (options instanceof Function) {
887
+ callback = arguments[2];
888
+ options = undefined;
889
+ }
890
+ if (!options) {
891
+ options = {};
892
+ }
893
+ const transcoder = options.transcoder || this.transcoder;
894
+ const timeout = options.timeout || this._kvScanTimeout;
895
+ const idsOnly = options.idsOnly || false;
896
+ const batchByteLimit = options.batchByteLimit || this._scanBatchByteLimit;
897
+ const batchItemLimit = options.batchByteLimit || this._scanBatchItemLimit;
898
+ if (typeof options.concurrency !== 'undefined' && options.concurrency < 1) {
899
+ throw new errors_1.InvalidArgumentError(new Error('Concurrency option must be positive'));
900
+ }
901
+ const concurrency = options.concurrency || 1;
902
+ if (scanType instanceof rangeScan_1.SamplingScan && scanType.limit < 1) {
903
+ throw new errors_1.InvalidArgumentError(new Error('Sampling scan limit must be positive'));
904
+ }
905
+ const orchestratorOptions = {
906
+ ids_only: idsOnly,
907
+ consistent_with: (0, bindingutilities_1.mutationStateToCpp)(options.consistentWith),
908
+ batch_item_limit: batchItemLimit,
909
+ batch_byte_limit: batchByteLimit,
910
+ concurrency: concurrency,
911
+ timeout: timeout,
912
+ };
913
+ return this._doScan(scanType, orchestratorOptions, transcoder, callback);
914
+ }
808
915
  /**
809
916
  * Performs a lookup-in operation against a document, fetching individual fields or
810
917
  * information about specific fields inside the document value.
@@ -42,6 +42,40 @@ export declare class GetResult {
42
42
  */
43
43
  get expiry(): number | undefined;
44
44
  }
45
+ /**
46
+ * Contains the results of a Range or Sampling Scan operation.
47
+ *
48
+ * @category Key-Value
49
+ */
50
+ export declare class ScanResult {
51
+ /**
52
+ * The content of the document.
53
+ */
54
+ id: string;
55
+ /**
56
+ * The content of the document.
57
+ */
58
+ content?: any;
59
+ /**
60
+ * The CAS of the document.
61
+ */
62
+ cas?: Cas;
63
+ /**
64
+ * The expiry of the document, if it was requested.
65
+ *
66
+ * @see {@link GetOptions.withExpiry}
67
+ */
68
+ expiryTime?: number;
69
+ /**
70
+ * @internal
71
+ */
72
+ constructor(data: {
73
+ id: string;
74
+ content?: any;
75
+ cas?: Cas;
76
+ expiryTime?: number;
77
+ });
78
+ }
45
79
  /**
46
80
  * Contains the results of an exists operation.
47
81
  *
@@ -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.GetResult = void 0;
3
+ exports.CounterResult = exports.MutateInResult = exports.MutateInResultEntry = 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
  *
@@ -36,6 +36,23 @@ class GetResult {
36
36
  }
37
37
  }
38
38
  exports.GetResult = GetResult;
39
+ /**
40
+ * Contains the results of a Range or Sampling Scan operation.
41
+ *
42
+ * @category Key-Value
43
+ */
44
+ class ScanResult {
45
+ /**
46
+ * @internal
47
+ */
48
+ constructor(data) {
49
+ this.id = data.id;
50
+ this.content = data.content;
51
+ this.cas = data.cas;
52
+ this.expiryTime = data.expiryTime;
53
+ }
54
+ }
55
+ exports.ScanResult = ScanResult;
39
56
  /**
40
57
  * Contains the results of an exists operation.
41
58
  *
@@ -95,6 +95,7 @@ class QueryExecutor {
95
95
  readonly: options.readOnly || false,
96
96
  flex_index: options.flexIndex || false,
97
97
  preserve_expiry: options.preserveExpiry || false,
98
+ use_replica: options.useReplica,
98
99
  max_parallelism: options.maxParallelism,
99
100
  scan_cap: options.scanCap,
100
101
  scan_wait: options.scanWait,
@@ -280,6 +280,13 @@ export interface QueryOptions {
280
280
  * the ability for the query to make any changes to the data.
281
281
  */
282
282
  readOnly?: boolean;
283
+ /**
284
+ * Uncommitted: This API is subject to change in the future.
285
+ *
286
+ * Specifies whether the query engine should use replica nodes for kv fetches,
287
+ * if the active node is down.
288
+ */
289
+ useReplica?: boolean;
283
290
  /**
284
291
  * Specifies the level of profiling that should be used for the query.
285
292
  */
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Represents a search term for a RangeScan.
3
+ *
4
+ * Volatile: This API is subject to change at any time.
5
+ *
6
+ * @see {@link RangeScan}
7
+ * @category Key-Value
8
+ */
9
+ export declare class ScanTerm {
10
+ /**
11
+ * The scan term.
12
+ *
13
+ * @see {@link MutationState}
14
+ */
15
+ term: string;
16
+ /**
17
+ * Set to true for the scan term to be exclusive. Defaults to false (inclusive).
18
+ */
19
+ exclusive?: boolean;
20
+ /**
21
+ * @internal
22
+ */
23
+ constructor(term: string, exclusive?: boolean);
24
+ }
25
+ /**
26
+ *
27
+ * @internal
28
+ */
29
+ export interface ScanType {
30
+ /**
31
+ * Returns string representation of scan type.
32
+ */
33
+ getScanType(): string;
34
+ }
35
+ /**
36
+ * A RangeScan performs a scan on a range of keys with the range specified through
37
+ * a start and end ScanTerm.
38
+ *
39
+ * Volatile: This API is subject to change at any time.
40
+ *
41
+ * @category Key-Value
42
+ */
43
+ export declare class RangeScan implements ScanType {
44
+ /**
45
+ * RangeScan start term.
46
+ */
47
+ start?: ScanTerm;
48
+ /**
49
+ * RangeScan end term.
50
+ */
51
+ end?: ScanTerm;
52
+ /**
53
+ * @internal
54
+ */
55
+ constructor(start?: ScanTerm, end?: ScanTerm);
56
+ /**
57
+ * Returns string representation of scan type.
58
+ */
59
+ getScanType(): string;
60
+ }
61
+ /**
62
+ * A SamplingScan performs a scan on a random sampling of keys with the sampling bounded by
63
+ * a limit.
64
+ *
65
+ * Volatile: This API is subject to change at any time.
66
+ *
67
+ * @category Key-Value
68
+ */
69
+ export declare class SamplingScan implements ScanType {
70
+ /**
71
+ * SamplingScan limit.
72
+ */
73
+ limit: number;
74
+ /**
75
+ * SamplingScan seed.
76
+ */
77
+ seed?: number;
78
+ /**
79
+ * @internal
80
+ */
81
+ constructor(limit: number, seed?: number);
82
+ /**
83
+ * Returns string representation of scan type.
84
+ */
85
+ getScanType(): string;
86
+ }
87
+ /**
88
+ * A PrefixScan scan type selects every document whose ID starts with a certain prefix.
89
+ *
90
+ * Volatile: This API is subject to change at any time.
91
+ *
92
+ * @category key-value
93
+ */
94
+ export declare class PrefixScan implements ScanType {
95
+ /**
96
+ * PrefixScan prefix.
97
+ */
98
+ prefix: string;
99
+ /**
100
+ * @internal
101
+ */
102
+ constructor(prefix: string);
103
+ /**
104
+ * Returns string representation of scan type.
105
+ */
106
+ getScanType(): string;
107
+ }
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PrefixScan = exports.SamplingScan = exports.RangeScan = exports.ScanTerm = void 0;
4
+ /**
5
+ * Represents a search term for a RangeScan.
6
+ *
7
+ * Volatile: This API is subject to change at any time.
8
+ *
9
+ * @see {@link RangeScan}
10
+ * @category Key-Value
11
+ */
12
+ class ScanTerm {
13
+ /**
14
+ * @internal
15
+ */
16
+ constructor(term, exclusive) {
17
+ this.term = term;
18
+ this.exclusive = exclusive;
19
+ }
20
+ }
21
+ exports.ScanTerm = ScanTerm;
22
+ /**
23
+ * A RangeScan performs a scan on a range of keys with the range specified through
24
+ * a start and end ScanTerm.
25
+ *
26
+ * Volatile: This API is subject to change at any time.
27
+ *
28
+ * @category Key-Value
29
+ */
30
+ class RangeScan {
31
+ /**
32
+ * @internal
33
+ */
34
+ constructor(start, end) {
35
+ this.start = start;
36
+ this.end = end;
37
+ }
38
+ /**
39
+ * Returns string representation of scan type.
40
+ */
41
+ getScanType() {
42
+ return 'range_scan';
43
+ }
44
+ }
45
+ exports.RangeScan = RangeScan;
46
+ /**
47
+ * A SamplingScan performs a scan on a random sampling of keys with the sampling bounded by
48
+ * a limit.
49
+ *
50
+ * Volatile: This API is subject to change at any time.
51
+ *
52
+ * @category Key-Value
53
+ */
54
+ class SamplingScan {
55
+ /**
56
+ * @internal
57
+ */
58
+ constructor(limit, seed) {
59
+ this.limit = limit;
60
+ this.seed = seed;
61
+ }
62
+ /**
63
+ * Returns string representation of scan type.
64
+ */
65
+ getScanType() {
66
+ return 'sampling_scan';
67
+ }
68
+ }
69
+ exports.SamplingScan = SamplingScan;
70
+ /**
71
+ * A PrefixScan scan type selects every document whose ID starts with a certain prefix.
72
+ *
73
+ * Volatile: This API is subject to change at any time.
74
+ *
75
+ * @category key-value
76
+ */
77
+ class PrefixScan {
78
+ /**
79
+ * @internal
80
+ */
81
+ constructor(prefix) {
82
+ this.prefix = prefix;
83
+ }
84
+ /**
85
+ * Returns string representation of scan type.
86
+ */
87
+ getScanType() {
88
+ return 'prefix_scan';
89
+ }
90
+ }
91
+ exports.PrefixScan = PrefixScan;
@@ -39,4 +39,10 @@ export declare class StreamableRowPromise<T, TRow, TMeta> extends StreamableProm
39
39
  export declare class StreamableReplicasPromise<T, TRep> extends StreamablePromise<T> {
40
40
  constructor(fn: (replicas: TRep[]) => T);
41
41
  }
42
+ export declare class StreamableScanPromise<T, TRes> extends StreamablePromise<T> {
43
+ private _cancelRequested;
44
+ constructor(fn: (results: TRes[]) => T);
45
+ get cancelRequested(): boolean;
46
+ cancelStreaming(): void;
47
+ }
42
48
  export {};
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.StreamableReplicasPromise = exports.StreamableRowPromise = exports.StreamablePromise = void 0;
6
+ exports.StreamableScanPromise = exports.StreamableReplicasPromise = exports.StreamableRowPromise = exports.StreamablePromise = void 0;
7
7
  /* eslint jsdoc/require-jsdoc: off */
8
8
  const events_1 = __importDefault(require("events"));
9
9
  /**
@@ -87,3 +87,27 @@ class StreamableReplicasPromise extends StreamablePromise {
87
87
  }
88
88
  }
89
89
  exports.StreamableReplicasPromise = StreamableReplicasPromise;
90
+ class StreamableScanPromise extends StreamablePromise {
91
+ constructor(fn) {
92
+ super((emitter, resolve, reject) => {
93
+ let err;
94
+ const results = [];
95
+ emitter.on('result', (r) => results.push(r));
96
+ emitter.on('error', (e) => (err = e));
97
+ emitter.on('end', () => {
98
+ if (err) {
99
+ return reject(err);
100
+ }
101
+ resolve(fn(results));
102
+ });
103
+ });
104
+ this._cancelRequested = false;
105
+ }
106
+ get cancelRequested() {
107
+ return this._cancelRequested;
108
+ }
109
+ cancelStreaming() {
110
+ this._cancelRequested = true;
111
+ }
112
+ }
113
+ exports.StreamableScanPromise = StreamableScanPromise;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  },
5
5
  "description": "The official Couchbase Node.js Client Library.",
6
6
  "engines": {
7
- "node": ">=12.0.0"
7
+ "node": ">=16"
8
8
  },
9
9
  "homepage": "http://www.couchbase.com/communities/nodejs",
10
10
  "keywords": [
@@ -55,7 +55,7 @@
55
55
  "type": "git",
56
56
  "url": "http://github.com/couchbase/couchnode.git"
57
57
  },
58
- "version": "4.2.5-dev.3",
58
+ "version": "4.2.6-dev",
59
59
  "config": {
60
60
  "native": false
61
61
  },
@@ -80,17 +80,16 @@
80
80
  ]
81
81
  },
82
82
  "optionalDependencies": {
83
- "@couchbase/couchbase-darwin-arm64-openssl1": "4.2.5-dev.3",
84
- "@couchbase/couchbase-darwin-arm64-openssl3": "4.2.5-dev.3",
85
- "@couchbase/couchbase-darwin-x64-openssl1": "4.2.5-dev.3",
86
- "@couchbase/couchbase-darwin-x64-openssl3": "4.2.5-dev.3",
87
- "@couchbase/couchbase-linux-arm64-openssl1": "4.2.5-dev.3",
88
- "@couchbase/couchbase-linux-arm64-openssl3": "4.2.5-dev.3",
89
- "@couchbase/couchbase-linux-x64-openssl1": "4.2.5-dev.3",
90
- "@couchbase/couchbase-linux-x64-openssl3": "4.2.5-dev.3",
91
- "@couchbase/couchbase-linuxmusl-x64-openssl1": "4.2.5-dev.3",
92
- "@couchbase/couchbase-linuxmusl-x64-openssl3": "4.2.5-dev.3",
93
- "@couchbase/couchbase-win32-x64-openssl1": "4.2.5-dev.3",
94
- "@couchbase/couchbase-win32-x64-openssl3": "4.2.5-dev.3"
83
+ "@couchbase/couchbase-darwin-arm64-openssl1": "4.2.6-dev",
84
+ "@couchbase/couchbase-darwin-arm64-openssl3": "4.2.6-dev",
85
+ "@couchbase/couchbase-darwin-x64-openssl1": "4.2.6-dev",
86
+ "@couchbase/couchbase-darwin-x64-openssl3": "4.2.6-dev",
87
+ "@couchbase/couchbase-linux-arm64-openssl1": "4.2.6-dev",
88
+ "@couchbase/couchbase-linux-x64-openssl1": "4.2.6-dev",
89
+ "@couchbase/couchbase-linux-x64-openssl3": "4.2.6-dev",
90
+ "@couchbase/couchbase-linuxmusl-x64-openssl1": "4.2.6-dev",
91
+ "@couchbase/couchbase-linuxmusl-x64-openssl3": "4.2.6-dev",
92
+ "@couchbase/couchbase-win32-x64-openssl1": "4.2.6-dev",
93
+ "@couchbase/couchbase-win32-x64-openssl3": "4.2.6-dev"
95
94
  }
96
95
  }