couchbase 4.2.11 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/deps/couchbase-cxx-cache/mozilla-ca-bundle.crt +49 -2
  2. package/deps/couchbase-cxx-cache/mozilla-ca-bundle.sha256 +1 -1
  3. package/deps/couchbase-cxx-client/core/impl/cluster.cxx +51 -5
  4. package/deps/couchbase-cxx-client/core/impl/collection.cxx +224 -209
  5. package/deps/couchbase-cxx-client/core/impl/query_error_context.cxx +2 -2
  6. package/deps/couchbase-cxx-client/core/impl/query_index_manager.cxx +1 -0
  7. package/deps/couchbase-cxx-client/core/io/dns_client.cxx +4 -0
  8. package/deps/couchbase-cxx-client/core/io/dns_config.cxx +15 -4
  9. package/deps/couchbase-cxx-client/core/io/dns_config.hxx +1 -1
  10. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +84 -53
  11. package/deps/couchbase-cxx-client/core/mcbp/operation_queue.cxx +1 -0
  12. package/deps/couchbase-cxx-client/core/meta/features.hxx +5 -0
  13. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_all_replicas.hxx +116 -105
  14. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_any_replica.hxx +116 -108
  15. package/deps/couchbase-cxx-client/core/operations/document_search.cxx +97 -81
  16. package/deps/couchbase-cxx-client/core/operations/document_search.hxx +5 -0
  17. package/deps/couchbase-cxx-client/core/range_scan_orchestrator_options.hxx +2 -1
  18. package/deps/couchbase-cxx-client/core/transactions/atr_cleanup_entry.cxx +16 -7
  19. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.cxx +578 -483
  20. package/deps/couchbase-cxx-client/core/transactions/attempt_context_testing_hooks.cxx +51 -50
  21. package/deps/couchbase-cxx-client/core/transactions/attempt_context_testing_hooks.hxx +4 -2
  22. package/deps/couchbase-cxx-client/core/transactions/cleanup_testing_hooks.cxx +6 -6
  23. package/deps/couchbase-cxx-client/core/transactions/cleanup_testing_hooks.hxx +3 -2
  24. package/deps/couchbase-cxx-client/core/transactions/internal/transactions_cleanup.hxx +2 -0
  25. package/deps/couchbase-cxx-client/core/transactions/internal/utils.hxx +5 -1
  26. package/deps/couchbase-cxx-client/core/transactions/staged_mutation.cxx +222 -179
  27. package/deps/couchbase-cxx-client/core/transactions/staged_mutation.hxx +23 -12
  28. package/deps/couchbase-cxx-client/core/transactions/transactions.cxx +61 -24
  29. package/deps/couchbase-cxx-client/core/transactions/transactions_cleanup.cxx +36 -16
  30. package/deps/couchbase-cxx-client/core/transactions/utils.cxx +9 -0
  31. package/deps/couchbase-cxx-client/core/transactions.hxx +40 -7
  32. package/deps/couchbase-cxx-client/couchbase/cluster.hxx +19 -0
  33. package/deps/couchbase-cxx-client/couchbase/fork_event.hxx +39 -0
  34. package/dist/binding.d.ts +8 -0
  35. package/dist/bindingutilities.d.ts +6 -1
  36. package/dist/bindingutilities.js +15 -1
  37. package/dist/bucketmanager.d.ts +0 -12
  38. package/dist/cluster.d.ts +0 -2
  39. package/dist/cluster.js +0 -2
  40. package/dist/collection.d.ts +3 -3
  41. package/dist/collection.js +3 -1
  42. package/dist/querytypes.d.ts +0 -2
  43. package/dist/rangeScan.d.ts +0 -8
  44. package/dist/rangeScan.js +0 -8
  45. package/dist/scope.d.ts +0 -5
  46. package/dist/scope.js +0 -5
  47. package/dist/scopesearchindexmanager.d.ts +0 -2
  48. package/dist/scopesearchindexmanager.js +0 -2
  49. package/dist/searchexecutor.js +3 -1
  50. package/dist/searchtypes.d.ts +16 -6
  51. package/dist/searchtypes.js +2 -6
  52. package/dist/transactions.d.ts +23 -0
  53. package/dist/transactions.js +16 -10
  54. package/dist/vectorsearch.d.ts +8 -8
  55. package/dist/vectorsearch.js +7 -7
  56. package/package.json +7 -7
  57. package/src/instance.cpp +11 -1
  58. package/src/instance.hpp +1 -0
  59. package/src/jstocbpp_autogen.hpp +8 -0
  60. package/src/jstocbpp_transactions.hpp +40 -3
  61. package/src/transactions.cpp +12 -1
  62. package/tools/gen-bindings-json.py +0 -1
package/dist/rangeScan.js CHANGED
@@ -4,8 +4,6 @@ exports.PrefixScan = exports.SamplingScan = exports.RangeScan = exports.ScanTerm
4
4
  /**
5
5
  * Represents a search term for a RangeScan.
6
6
  *
7
- * Volatile: This API is subject to change at any time.
8
- *
9
7
  * @see {@link RangeScan}
10
8
  * @category Key-Value
11
9
  */
@@ -23,8 +21,6 @@ exports.ScanTerm = ScanTerm;
23
21
  * A RangeScan performs a scan on a range of keys with the range specified through
24
22
  * a start and end ScanTerm.
25
23
  *
26
- * Volatile: This API is subject to change at any time.
27
- *
28
24
  * @category Key-Value
29
25
  */
30
26
  class RangeScan {
@@ -47,8 +43,6 @@ exports.RangeScan = RangeScan;
47
43
  * A SamplingScan performs a scan on a random sampling of keys with the sampling bounded by
48
44
  * a limit.
49
45
  *
50
- * Volatile: This API is subject to change at any time.
51
- *
52
46
  * @category Key-Value
53
47
  */
54
48
  class SamplingScan {
@@ -70,8 +64,6 @@ exports.SamplingScan = SamplingScan;
70
64
  /**
71
65
  * A PrefixScan scan type selects every document whose ID starts with a certain prefix.
72
66
  *
73
- * Volatile: This API is subject to change at any time.
74
- *
75
67
  * @category key-value
76
68
  */
77
69
  class PrefixScan {
package/dist/scope.d.ts CHANGED
@@ -56,9 +56,6 @@ export declare class Scope {
56
56
  /**
57
57
  * Returns a SearchIndexManager which can be used to manage the search
58
58
  * indexes of this scope.
59
- *
60
- * Volatile: This API is subject to change at any time.
61
- *
62
59
  */
63
60
  searchIndexes(): ScopeSearchIndexManager;
64
61
  /**
@@ -80,8 +77,6 @@ export declare class Scope {
80
77
  /**
81
78
  * Executes a search query against the scope.
82
79
  *
83
- * Volatile: This API is subject to change at any time.
84
- *
85
80
  * @param indexName The name of the index to query.
86
81
  * @param request The SearchRequest describing the search to execute.
87
82
  * @param options Optional parameters for this operation.
package/dist/scope.js CHANGED
@@ -69,9 +69,6 @@ class Scope {
69
69
  /**
70
70
  * Returns a SearchIndexManager which can be used to manage the search
71
71
  * indexes of this scope.
72
- *
73
- * Volatile: This API is subject to change at any time.
74
- *
75
72
  */
76
73
  searchIndexes() {
77
74
  return new scopesearchindexmanager_1.ScopeSearchIndexManager(this.cluster, this.bucket.name, this._name);
@@ -125,8 +122,6 @@ class Scope {
125
122
  /**
126
123
  * Executes a search query against the scope.
127
124
  *
128
- * Volatile: This API is subject to change at any time.
129
- *
130
125
  * @param indexName The name of the index to query.
131
126
  * @param request The SearchRequest describing the search to execute.
132
127
  * @param options Optional parameters for this operation.
@@ -5,8 +5,6 @@ import { GetSearchIndexOptions, GetAllSearchIndexesOptions, UpsertSearchIndexOpt
5
5
  * SearchIndexManager provides an interface for managing the
6
6
  * search indexes on the cluster.
7
7
  *
8
- * Volatile: This API is subject to change at any time.
9
- *
10
8
  * @category Management
11
9
  */
12
10
  export declare class ScopeSearchIndexManager {
@@ -8,8 +8,6 @@ const searchindexmanager_1 = require("./searchindexmanager");
8
8
  * SearchIndexManager provides an interface for managing the
9
9
  * search indexes on the cluster.
10
10
  *
11
- * Volatile: This API is subject to change at any time.
12
- *
13
11
  * @category Management
14
12
  */
15
13
  class ScopeSearchIndexManager {
@@ -67,9 +67,11 @@ class SearchExecutor {
67
67
  .map(([k, v]) => [k, JSON.stringify(v)]))
68
68
  : {},
69
69
  body_str: '',
70
+ show_request: options.showRequest || false,
71
+ log_request: options.logRequest || false,
72
+ log_response: options.logResponse || false,
70
73
  };
71
74
  if (query instanceof searchtypes_1.SearchRequest) {
72
- request.show_request = false;
73
75
  if (query.vectorSearch) {
74
76
  request.vector_search = JSON.stringify(query.vectorSearch.queries);
75
77
  if (query.vectorSearch.options &&
@@ -146,12 +146,24 @@ export interface SearchQueryOptions {
146
146
  * The timeout for this operation, represented in milliseconds.
147
147
  */
148
148
  timeout?: number;
149
+ /**
150
+ * Specifies that the search response should include the request JSON.
151
+ */
152
+ showRequest?: boolean;
153
+ /**
154
+ * Uncommitted: This API is subject to change in the future.
155
+ * Specifies that the search request should appear in the log.
156
+ */
157
+ logRequest?: boolean;
158
+ /**
159
+ * Uncommitted: This API is subject to change in the future.
160
+ * Specifies that the search response should appear in the log.
161
+ */
162
+ logResponse?: boolean;
149
163
  }
150
164
  /**
151
165
  * Represents a search query and/or vector search to execute via the Couchbase Full Text Search (FTS) service.
152
166
  *
153
- * Volatile: This API is subject to change at any time.
154
- *
155
167
  * @category Full Text Search
156
168
  */
157
169
  export declare class SearchRequest {
@@ -169,7 +181,7 @@ export declare class SearchRequest {
169
181
  /**
170
182
  * Adds a search query to the request if the request does not already have a search query.
171
183
  *
172
- * Volatile: This API is subject to change at any time.
184
+ * Uncommitted: This API is subject to change in the future.
173
185
  *
174
186
  * @param query A SearchQuery to add to the request.
175
187
  */
@@ -177,7 +189,7 @@ export declare class SearchRequest {
177
189
  /**
178
190
  * Adds a vector search to the request if the request does not already have a vector search.
179
191
  *
180
- * Volatile: This API is subject to change at any time.
192
+ * Uncommitted: This API is subject to change in the future.
181
193
  *
182
194
  * @param search A VectorSearch to add to the request.
183
195
  */
@@ -185,8 +197,6 @@ export declare class SearchRequest {
185
197
  /**
186
198
  * Creates a search request.
187
199
  *
188
- * Volatile: This API is subject to change at any time.
189
- *
190
200
  * @param query Either a SearchQuery or VectorSearch to add to the search request.
191
201
  */
192
202
  static create(query: SearchQuery | VectorSearch): SearchRequest;
@@ -73,8 +73,6 @@ var SearchScanConsistency;
73
73
  /**
74
74
  * Represents a search query and/or vector search to execute via the Couchbase Full Text Search (FTS) service.
75
75
  *
76
- * Volatile: This API is subject to change at any time.
77
- *
78
76
  * @category Full Text Search
79
77
  */
80
78
  class SearchRequest {
@@ -104,7 +102,7 @@ class SearchRequest {
104
102
  /**
105
103
  * Adds a search query to the request if the request does not already have a search query.
106
104
  *
107
- * Volatile: This API is subject to change at any time.
105
+ * Uncommitted: This API is subject to change in the future.
108
106
  *
109
107
  * @param query A SearchQuery to add to the request.
110
108
  */
@@ -121,7 +119,7 @@ class SearchRequest {
121
119
  /**
122
120
  * Adds a vector search to the request if the request does not already have a vector search.
123
121
  *
124
- * Volatile: This API is subject to change at any time.
122
+ * Uncommitted: This API is subject to change in the future.
125
123
  *
126
124
  * @param search A VectorSearch to add to the request.
127
125
  */
@@ -138,8 +136,6 @@ class SearchRequest {
138
136
  /**
139
137
  * Creates a search request.
140
138
  *
141
- * Volatile: This API is subject to change at any time.
142
- *
143
139
  * @param query Either a SearchQuery or VectorSearch to add to the search request.
144
140
  */
145
141
  static create(query) {
@@ -29,6 +29,25 @@ export declare class DocumentId {
29
29
  */
30
30
  key: string;
31
31
  }
32
+ /**
33
+ * Specifies the configuration options for a Transaction Keyspace.
34
+ *
35
+ * @category Transactions
36
+ */
37
+ export interface TransactionKeyspace {
38
+ /**
39
+ * The name of the bucket for the Keyspace.
40
+ */
41
+ bucket: string;
42
+ /**
43
+ * The name of the scope for the Keyspace.
44
+ */
45
+ scope?: string;
46
+ /**
47
+ * The name of the collection for the Keyspace.
48
+ */
49
+ collection?: string;
50
+ }
32
51
  /**
33
52
  * Specifies the configuration options for Transactions cleanup.
34
53
  *
@@ -87,6 +106,10 @@ export interface TransactionsConfig {
87
106
  * Specifies the configuration for the cleanup system.
88
107
  */
89
108
  cleanupConfig?: TransactionsCleanupConfig;
109
+ /**
110
+ * Specifies the Keyspace (bucket, scope & collection) for the transaction metadata.
111
+ */
112
+ metadataCollection?: TransactionKeyspace;
90
113
  }
91
114
  /**
92
115
  * Specifies the configuration options for a Transaction.
@@ -311,16 +311,22 @@ class Transactions {
311
311
  config.queryConfig = {};
312
312
  }
313
313
  const connImpl = cluster.conn;
314
- const txnsImpl = new binding_1.default.Transactions(connImpl, {
315
- durability_level: (0, bindingutilities_1.durabilityToCpp)(config.durabilityLevel),
316
- timeout: config.timeout,
317
- query_scan_consistency: (0, bindingutilities_1.queryScanConsistencyToCpp)(config.queryConfig.scanConsistency),
318
- cleanup_window: config.cleanupConfig.cleanupWindow,
319
- cleanup_lost_attempts: !config.cleanupConfig.disableLostAttemptCleanup,
320
- cleanup_client_attempts: !config.cleanupConfig.disableClientAttemptCleanup,
321
- });
322
- this._cluster = cluster;
323
- this._impl = txnsImpl;
314
+ try {
315
+ const txnsImpl = new binding_1.default.Transactions(connImpl, {
316
+ durability_level: (0, bindingutilities_1.durabilityToCpp)(config.durabilityLevel),
317
+ timeout: config.timeout,
318
+ query_scan_consistency: (0, bindingutilities_1.queryScanConsistencyToCpp)(config.queryConfig.scanConsistency),
319
+ cleanup_window: config.cleanupConfig.cleanupWindow,
320
+ cleanup_lost_attempts: !config.cleanupConfig.disableLostAttemptCleanup,
321
+ cleanup_client_attempts: !config.cleanupConfig.disableClientAttemptCleanup,
322
+ metadata_collection: (0, bindingutilities_1.transactionKeyspaceToCpp)(config.metadataCollection),
323
+ });
324
+ this._cluster = cluster;
325
+ this._impl = txnsImpl;
326
+ }
327
+ catch (err) {
328
+ throw (0, bindingutilities_1.errorFromCpp)(err);
329
+ }
324
330
  }
325
331
  /**
326
332
  @internal
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Specifies how multiple vector searches are combined.
3
3
  *
4
- * Volatile: This API is subject to change at any time.
4
+ * Uncommitted: This API is subject to change in the future.
5
5
  *
6
6
  * @category Full Text Search
7
7
  */
@@ -16,7 +16,7 @@ export declare enum VectorQueryCombination {
16
16
  OR = "or"
17
17
  }
18
18
  /**
19
- * Volatile: This API is subject to change at any time.
19
+ * Uncommitted: This API is subject to change in the future.
20
20
  *
21
21
  * @category Full Text Search
22
22
  */
@@ -29,7 +29,7 @@ export interface VectorSearchOptions {
29
29
  /**
30
30
  * Represents a vector query.
31
31
  *
32
- * Volatile: This API is subject to change at any time.
32
+ * Uncommitted: This API is subject to change in the future.
33
33
  *
34
34
  * @category Full Text Search
35
35
  */
@@ -46,7 +46,7 @@ export declare class VectorQuery {
46
46
  /**
47
47
  * Adds boost option to vector query.
48
48
  *
49
- * Volatile: This API is subject to change at any time.
49
+ * Uncommitted: This API is subject to change in the future.
50
50
  *
51
51
  * @param boost A floating point value.
52
52
  */
@@ -54,7 +54,7 @@ export declare class VectorQuery {
54
54
  /**
55
55
  * Adds numCandidates option to vector query. Value must be >= 1.
56
56
  *
57
- * Volatile: This API is subject to change at any time.
57
+ * Uncommitted: This API is subject to change in the future.
58
58
  *
59
59
  * @param numCandidates An integer value.
60
60
  */
@@ -62,7 +62,7 @@ export declare class VectorQuery {
62
62
  /**
63
63
  * Creates a vector query.
64
64
  *
65
- * Volatile: This API is subject to change at any time.
65
+ * Uncommitted: This API is subject to change in the future.
66
66
  *
67
67
  * @param fieldName The name of the field in the JSON document that holds the vector.
68
68
  * @param vector List of floating point values that represent the vector.
@@ -72,7 +72,7 @@ export declare class VectorQuery {
72
72
  /**
73
73
  * Represents a vector search.
74
74
  *
75
- * Volatile: This API is subject to change at any time.
75
+ * Uncommitted: This API is subject to change in the future.
76
76
  *
77
77
  * @category Full Text Search
78
78
  */
@@ -91,7 +91,7 @@ export declare class VectorSearch {
91
91
  /**
92
92
  * Creates a vector search.
93
93
  *
94
- * Volatile: This API is subject to change at any time.
94
+ * Uncommitted: This API is subject to change in the future.
95
95
  *
96
96
  * @param query A vectory query that should be a part of the vector search.
97
97
  */
@@ -5,7 +5,7 @@ const errors_1 = require("./errors");
5
5
  /**
6
6
  * Specifies how multiple vector searches are combined.
7
7
  *
8
- * Volatile: This API is subject to change at any time.
8
+ * Uncommitted: This API is subject to change in the future.
9
9
  *
10
10
  * @category Full Text Search
11
11
  */
@@ -23,7 +23,7 @@ var VectorQueryCombination;
23
23
  /**
24
24
  * Represents a vector query.
25
25
  *
26
- * Volatile: This API is subject to change at any time.
26
+ * Uncommitted: This API is subject to change in the future.
27
27
  *
28
28
  * @category Full Text Search
29
29
  */
@@ -53,7 +53,7 @@ class VectorQuery {
53
53
  /**
54
54
  * Adds boost option to vector query.
55
55
  *
56
- * Volatile: This API is subject to change at any time.
56
+ * Uncommitted: This API is subject to change in the future.
57
57
  *
58
58
  * @param boost A floating point value.
59
59
  */
@@ -64,7 +64,7 @@ class VectorQuery {
64
64
  /**
65
65
  * Adds numCandidates option to vector query. Value must be >= 1.
66
66
  *
67
- * Volatile: This API is subject to change at any time.
67
+ * Uncommitted: This API is subject to change in the future.
68
68
  *
69
69
  * @param numCandidates An integer value.
70
70
  */
@@ -78,7 +78,7 @@ class VectorQuery {
78
78
  /**
79
79
  * Creates a vector query.
80
80
  *
81
- * Volatile: This API is subject to change at any time.
81
+ * Uncommitted: This API is subject to change in the future.
82
82
  *
83
83
  * @param fieldName The name of the field in the JSON document that holds the vector.
84
84
  * @param vector List of floating point values that represent the vector.
@@ -91,7 +91,7 @@ exports.VectorQuery = VectorQuery;
91
91
  /**
92
92
  * Represents a vector search.
93
93
  *
94
- * Volatile: This API is subject to change at any time.
94
+ * Uncommitted: This API is subject to change in the future.
95
95
  *
96
96
  * @category Full Text Search
97
97
  */
@@ -121,7 +121,7 @@ class VectorSearch {
121
121
  /**
122
122
  * Creates a vector search.
123
123
  *
124
- * Volatile: This API is subject to change at any time.
124
+ * Uncommitted: This API is subject to change in the future.
125
125
  *
126
126
  * @param query A vectory query that should be a part of the vector search.
127
127
  */
package/package.json CHANGED
@@ -54,7 +54,7 @@
54
54
  "type": "git",
55
55
  "url": "http://github.com/couchbase/couchnode.git"
56
56
  },
57
- "version": "4.2.11",
57
+ "version": "4.3.0",
58
58
  "config": {
59
59
  "native": false
60
60
  },
@@ -79,12 +79,12 @@
79
79
  ]
80
80
  },
81
81
  "optionalDependencies": {
82
- "@couchbase/couchbase-darwin-arm64-napi": "4.2.11",
83
- "@couchbase/couchbase-darwin-x64-napi": "4.2.11",
84
- "@couchbase/couchbase-linux-arm64-napi": "4.2.11",
85
- "@couchbase/couchbase-linuxmusl-x64-napi": "4.2.11",
86
- "@couchbase/couchbase-linux-x64-napi": "4.2.11",
87
- "@couchbase/couchbase-win32-x64-napi": "4.2.11"
82
+ "@couchbase/couchbase-darwin-arm64-napi": "4.3.0",
83
+ "@couchbase/couchbase-darwin-x64-napi": "4.3.0",
84
+ "@couchbase/couchbase-linux-arm64-napi": "4.3.0",
85
+ "@couchbase/couchbase-linuxmusl-x64-napi": "4.3.0",
86
+ "@couchbase/couchbase-linux-x64-napi": "4.3.0",
87
+ "@couchbase/couchbase-win32-x64-napi": "4.3.0"
88
88
  },
89
89
  "files": [
90
90
  "LICENSE",
package/src/instance.cpp CHANGED
@@ -6,7 +6,17 @@ namespace couchnode
6
6
  Instance::Instance()
7
7
  : _cluster(couchbase::core::cluster(_io))
8
8
  {
9
- _ioThread = std::thread([this]() { _io.run(); });
9
+ _ioThread = std::thread([this]() {
10
+ try {
11
+ _io.run();
12
+ } catch (const std::exception &e) {
13
+ CB_LOG_ERROR(e.what());
14
+ throw;
15
+ } catch (...) {
16
+ CB_LOG_ERROR("Unknown exception");
17
+ throw;
18
+ }
19
+ });
10
20
  }
11
21
 
12
22
  Instance::~Instance()
package/src/instance.hpp CHANGED
@@ -1,6 +1,7 @@
1
1
  #pragma once
2
2
  #include <asio/io_context.hpp>
3
3
  #include <core/cluster.hxx>
4
+ #include <core/logger/logger.hxx>
4
5
  #include <memory>
5
6
  #include <thread>
6
7
 
@@ -3916,6 +3916,10 @@ struct js_to_cbpp_t<couchbase::core::operations::search_request> {
3916
3916
  jsObj.Get("client_context_id"));
3917
3917
  js_to_cbpp<std::optional<std::chrono::milliseconds>>(
3918
3918
  cppObj.timeout, jsObj.Get("timeout"));
3919
+ js_to_cbpp<std::optional<bool>>(cppObj.log_request,
3920
+ jsObj.Get("log_request"));
3921
+ js_to_cbpp<std::optional<bool>>(cppObj.log_response,
3922
+ jsObj.Get("log_response"));
3919
3923
  js_to_cbpp<std::string>(cppObj.body_str, jsObj.Get("body_str"));
3920
3924
  // parent_span
3921
3925
  return cppObj;
@@ -3984,6 +3988,10 @@ struct js_to_cbpp_t<couchbase::core::operations::search_request> {
3984
3988
  resObj.Set("timeout",
3985
3989
  cbpp_to_js<std::optional<std::chrono::milliseconds>>(
3986
3990
  env, cppObj.timeout));
3991
+ resObj.Set("log_request",
3992
+ cbpp_to_js<std::optional<bool>>(env, cppObj.log_request));
3993
+ resObj.Set("log_response",
3994
+ cbpp_to_js<std::optional<bool>>(env, cppObj.log_response));
3987
3995
  resObj.Set("body_str", cbpp_to_js<std::string>(env, cppObj.body_str));
3988
3996
  // parent_span
3989
3997
  return resObj;
@@ -47,7 +47,8 @@ struct js_to_cbpp_t<cbtxns::transactions_config> {
47
47
  cppObj.durability_level(durability_level.value());
48
48
  }
49
49
 
50
- auto timeout = js_to_cbpp<std::optional<std::chrono::milliseconds>>(jsObj.Get("timeout"));
50
+ auto timeout = js_to_cbpp<std::optional<std::chrono::milliseconds>>(
51
+ jsObj.Get("timeout"));
51
52
  if (timeout.has_value()) {
52
53
  cppObj.timeout(timeout.value());
53
54
  }
@@ -81,6 +82,12 @@ struct js_to_cbpp_t<cbtxns::transactions_config> {
81
82
  cleanup_client_attempts.value());
82
83
  }
83
84
 
85
+ auto keyspace = js_to_cbpp<std::optional<cbtxns::transaction_keyspace>>(
86
+ jsObj.Get("metadata_collection"));
87
+ if (keyspace.has_value()) {
88
+ cppObj.metadata_collection(keyspace.value());
89
+ }
90
+
84
91
  return cppObj;
85
92
  }
86
93
  };
@@ -99,7 +106,8 @@ struct js_to_cbpp_t<cbtxns::transaction_options> {
99
106
  cppObj.durability_level(durability_level.value());
100
107
  }
101
108
 
102
- auto timeout = js_to_cbpp<std::optional<std::chrono::milliseconds>>(jsObj.Get("timeout"));
109
+ auto timeout = js_to_cbpp<std::optional<std::chrono::milliseconds>>(
110
+ jsObj.Get("timeout"));
103
111
  if (timeout.has_value()) {
104
112
  cppObj.timeout(timeout.value());
105
113
  }
@@ -197,6 +205,34 @@ struct js_to_cbpp_t<cbcoretxns::document_metadata> {
197
205
  }
198
206
  };
199
207
 
208
+ template <>
209
+ struct js_to_cbpp_t<cbtxns::transaction_keyspace> {
210
+ static inline cbtxns::transaction_keyspace from_js(Napi::Value jsVal)
211
+ {
212
+ auto jsObj = jsVal.ToObject();
213
+ auto bucket_name = js_to_cbpp<std::string>(jsObj.Get("bucket_name"));
214
+ auto scope_name =
215
+ js_to_cbpp<std::optional<std::string>>(jsObj.Get("scope_name"));
216
+ auto collection_name = js_to_cbpp<std::optional<std::string>>(
217
+ jsObj.Get("collection_name"));
218
+ if (scope_name.has_value() && collection_name.has_value()) {
219
+ return cbtxns::transaction_keyspace(bucket_name, scope_name.value(),
220
+ collection_name.value());
221
+ }
222
+ return cbtxns::transaction_keyspace(bucket_name);
223
+ }
224
+
225
+ static inline Napi::Value to_js(Napi::Env env,
226
+ const cbtxns::transaction_keyspace &res)
227
+ {
228
+ auto resObj = Napi::Object::New(env);
229
+ resObj.Set("bucket", cbpp_to_js(env, res.bucket));
230
+ resObj.Set("scope", cbpp_to_js(env, res.scope));
231
+ resObj.Set("collection", cbpp_to_js(env, res.collection));
232
+ return resObj;
233
+ }
234
+ };
235
+
200
236
  template <>
201
237
  struct js_to_cbpp_t<cbcoretxns::transaction_get_result> {
202
238
  static inline cbcoretxns::transaction_get_result from_js(Napi::Value jsVal)
@@ -387,7 +423,8 @@ struct js_to_cbpp_t<cbcoretxns::op_exception> {
387
423
  const cbcoretxns::op_exception &err)
388
424
  {
389
425
  Napi::Error jsErr = Napi::Error::New(env, "transaction_exception");
390
- jsErr.Set("ctxtype", Napi::String::New(env, "transaction_op_exception"));
426
+ jsErr.Set("ctxtype",
427
+ Napi::String::New(env, "transaction_op_exception"));
391
428
  jsErr.Set("ctx", cbpp_to_js(env, err.ctx()));
392
429
  jsErr.Set("cause", cbpp_to_js(env, err.cause()));
393
430
  return jsErr.Value();
@@ -32,7 +32,18 @@ Transactions::Transactions(const Napi::CallbackInfo &info)
32
32
  auto cluster = Connection::Unwrap(clusterJsObj)->cluster();
33
33
 
34
34
  auto txnsConfig = jsToCbpp<cbtxns::transactions_config>(configJsObj);
35
- _impl.reset(new cbcoretxns::transactions(cluster, txnsConfig));
35
+ std::future<
36
+ std::pair<std::error_code, std::shared_ptr<cbcoretxns::transactions>>>
37
+ future = cbcoretxns::transactions::create(cluster, txnsConfig);
38
+ std::pair<std::error_code, std::shared_ptr<cbcoretxns::transactions>>
39
+ result = future.get();
40
+ if (result.first.value()) {
41
+ Napi::Error err = Napi::Error::New(info.Env(), result.first.message());
42
+ err.Set("code", Napi::Number::New(info.Env(), result.first.value()));
43
+ throw err;
44
+ }
45
+ _impl.reset();
46
+ _impl = std::move(result.second);
36
47
  }
37
48
 
38
49
  Transactions::~Transactions()
@@ -69,7 +69,6 @@ fileList = [
69
69
  "couchbase/persist_to.hxx",
70
70
  "couchbase/replicate_to.hxx",
71
71
  "core/range_scan_options.hxx",
72
- "core/scan_options.hxx",
73
72
  "core/range_scan_orchestrator_options.hxx",
74
73
  "core/query_context.hxx",
75
74
  "core/vector_query_combination.hxx",